7 extern float multiplier;
9 extern int environment;
10 extern float texscale;
11 extern Terrain terrain;
12 extern FSOUND_SAMPLE *samp[100];
13 extern int channels[100];
14 extern Sprites sprites;
15 extern int kTextureSize;
16 extern float screenwidth,screenheight;
19 extern float texdetail;
20 extern Objects objects;
22 extern float slomodelay;
23 extern bool floatjump;
25 extern Animation animation[animation_count];
27 extern float texdetail;
28 extern GLubyte bloodText[512*512*3];
29 extern GLubyte wolfbloodText[512*512*3];
30 extern float terraindetail;
31 extern float camerashake;
33 extern float blackout;
34 extern bool cellophane;
35 extern bool musictoggle;
36 extern int difficulty;
37 extern Weapons weapons;
38 extern Person player[maxplayers];
39 extern int numplayers;
40 extern int bloodtoggle;
41 extern bool invertmouse;
43 extern float precipdelay;
44 extern XYZ viewerfacing;
45 extern bool ambientsound;
46 extern bool mousejump;
47 extern float viewdistance;
49 extern bool autoslomo;
50 extern int newnetmessages;
51 extern char netmessages[256];
52 extern bool keyboardfrozen;
53 extern int netdatanew;
54 extern bool loadingstuff;
55 extern char mapname[256];
56 extern XYZ windvector;
57 extern bool buttons[3];
58 extern bool debugmode;
61 extern int oldmainmenu;
62 extern bool visibleloading;
63 extern int loadscreencolor;
64 extern float flashamount,flashr,flashg,flashb;
65 extern int flashdelay;
66 extern XYZ envsound[30];
67 extern float envsoundvol[30];
68 extern int numenvsounds;
69 extern float envsoundlife[30];
70 extern float usermousesensitivity;
71 extern bool ismotionblur;
73 extern bool trilinear;
74 extern bool damageeffects;
75 extern bool showpoints;
76 extern bool texttoggle;
77 extern bool alwaysblur;
78 extern float gamespeed;
81 extern bool immediate;
82 extern bool velocityblur;
85 extern float bonusvalue;
86 extern float bonustotal;
87 extern float bonustime;
88 extern float startbonustotal;
89 extern float tintr,tintg,tintb;
90 extern float bonusnum[100];
91 extern bool skyboxtexture;
95 extern float skyboxlightr;
96 extern float skyboxlightg;
97 extern float skyboxlightb;
98 extern float fadestart;
99 extern float slomospeed;
100 extern float slomofreq;
101 extern int tutoriallevel;
102 extern float smoketex;
103 extern float tutorialstagetime;
104 extern int tutorialstage;
105 extern float tutorialmaxtime;
106 extern float tutorialsuccess;
107 extern bool againbonus;
108 extern bool reversaltrain;
109 extern bool canattack;
110 extern bool cananger;
111 extern float damagedealt;
112 extern float damagetaken;
114 extern int editoractive;
115 extern int editorpathtype;
116 extern bool oldbuttons[3];
118 extern float hostiletime;
120 extern bool gamestarted;
122 extern int numhotspots;
123 extern int winhotspot;
124 extern int windialogue;
125 extern int killhotspot;
126 extern XYZ hotspot[40];
127 extern int hotspottype[40];
128 extern float hotspotsize[40];
129 extern char hotspottext[40][256];
130 extern int currenthotspot;
132 extern int kBitsPerPixel;
135 extern int numaccounts;
136 extern int accountactive;
137 extern int accountdifficulty[10];
138 extern int accountprogress[10];
139 extern float accountpoints[10];
140 extern float accounthighscore[10][50];
141 extern float accountfasttime[10][50];
142 extern bool accountunlocked[10][60];
143 extern char accountname[10][256];
145 extern bool stillloading;
146 extern bool winfreeze;
149 extern int numflipfail;
151 extern int numstaffattack;
152 extern int numswordattack;
153 extern int numknifeattack;
154 extern int numunarmedattack;
155 extern int numescaped;
156 extern int numflipped;
157 extern int numwallflipped;
158 extern int numthrowkill;
159 extern int numafterkill;
160 extern int numreversals;
161 extern int numattacks;
162 extern int maxalarmed;
163 extern int numresponded;
165 extern int numdialogues;
166 extern int numdialogueboxes[max_dialogues];
167 extern int dialoguetype[max_dialogues];
168 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
169 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
170 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
171 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
172 extern char dialoguename[max_dialogues][max_dialoguelength][64];
173 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
174 extern XYZ participantlocation[max_dialogues][10];
175 extern int participantfocus[max_dialogues][max_dialoguelength];
176 extern int participantaction[max_dialogues][max_dialoguelength];
177 extern float participantrotation[max_dialogues][10];
178 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
179 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
180 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
181 extern int indialogue;
182 extern int whichdialogue;
183 extern int directing;
184 extern float dialoguetime;
185 extern int dialoguegonethrough[20];
187 extern bool campaign;
189 extern float oldgamespeed;
191 extern float accountcampaignhighscore[10];
192 extern float accountcampaignfasttime[10];
193 extern float accountcampaignscore[10];
194 extern float accountcampaigntime[10];
196 extern int accountcampaignchoicesmade[10];
197 extern int accountcampaignchoices[10][5000];
198 /********************> Tick() <*****/
199 extern FSOUND_STREAM * strm[10];
200 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
201 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
203 extern void ScreenShot(const char * fname);
204 void Screenshot (void)
207 time_t t = time(NULL);
208 struct tm *tme = localtime(&t);
209 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);
211 mkdir("Screenshots");
212 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
215 GraphicsExportComponent QT_exporter;
216 OSErr MAC_error_code;
217 CGrafPtr MAC_currentPort;
218 GDHandle MAC_currentDevice;
219 unsigned char* MAC_pixels;
220 Rect MAC_picture_rectangle;
221 GWorldPtr MAC_offscreen_graphics_port;
223 static int numscreenshots=0;
226 static char buf[256];
227 if(numscreenshots==0){
258 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
259 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
260 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
261 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
282 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
283 //assert(MAC_gWorld != NULL);
285 // Allocate memory for loading image
286 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
287 if (MAC_pixels == NULL) {
288 //UTIL_Error("Could not create Texture data.");
293 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
295 // Make a picture Rectangle
296 MAC_picture_rectangle.left = 0;
297 MAC_picture_rectangle.right = screenwidth;
298 MAC_picture_rectangle.top = 0;
299 MAC_picture_rectangle.bottom = screenheight;
301 // Create new offscreen GWorld
302 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
303 if (MAC_error_code) {
304 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
306 //UTIL_Error("Could not create offscreen GWorld. ");
311 // Copy OpenGL Context to new GWorld
312 glReadBuffer(GL_FRONT);
313 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
316 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
317 unsigned char temp = MAC_pixels[byte+0];
318 MAC_pixels[byte+0] = MAC_pixels[byte+3];
319 MAC_pixels[byte+3] = MAC_pixels[byte+2];
320 MAC_pixels[byte+2] = MAC_pixels[byte+1];
321 MAC_pixels[byte+1] = temp;
324 // Flip the image :( This could probably be optimized
329 for (int horz = 0; horz < screenwidth; ++horz)
330 for (vert = 0; vert < screenheight / 2; ++vert) {
331 src_index = (screenwidth * vert + horz) * 4;
332 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
334 temp=MAC_pixels[src_index+0];
335 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
336 MAC_pixels[dst_index+0]=temp;
338 temp=MAC_pixels[src_index+1];
339 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
340 MAC_pixels[dst_index+1]=temp;
342 temp=MAC_pixels[src_index+2];
343 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
344 MAC_pixels[dst_index+2]=temp;
346 temp=MAC_pixels[src_index+3];
347 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
348 MAC_pixels[dst_index+3]=temp;
354 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
355 if (MAC_error_code) {
356 //UTIL_Warning("Unable to export screenshot.");
357 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
358 ::DisposeGWorld(MAC_offscreen_graphics_port);
363 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
364 if (MAC_error_code) {
365 ::CloseComponent(QT_exporter);
366 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
367 ::DisposeGWorld(MAC_offscreen_graphics_port);
369 //UTIL_Warning("Unable to export screenshot.");
373 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
374 if (MAC_error_code) {
375 ::CloseComponent(QT_exporter);
376 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
377 ::DisposeGWorld(MAC_offscreen_graphics_port);
379 //UTIL_Warning("Unable to export screenshot.");
383 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
384 if (MAC_error_code) {
385 ::CloseComponent(QT_exporter);
386 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
387 ::DisposeGWorld(MAC_offscreen_graphics_port);
389 //UTIL_Warning("Unable to export screenshot.");
393 ::CloseComponent(QT_exporter);
394 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
395 ::DisposeGWorld(MAC_offscreen_graphics_port);
402 void Game::SetUpLighting(){
403 if(environment==snowyenvironment){
409 light.ambient[2]=.44;
411 if(environment==desertenvironment){
416 light.ambient[1]=.35;
420 if(environment==grassyenvironment){
426 light.ambient[2]=.44;
437 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
438 light.color[0]*=(skyboxlightr+average)/2;
439 light.color[1]*=(skyboxlightg+average)/2;
440 light.color[2]*=(skyboxlightb+average)/2;
441 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
442 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
443 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
447 light.ambient[2]=0; */
450 int Game::findPathDist(int start,int end){
451 int i,j,k,smallestcount,count,connected;
452 int last,last2,last3,last4;
462 while(last!=end&&count<30){
464 for(j=0;j<numpathpoints;j++){
465 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
468 if(numpathpointconnect[j])
469 for(k=0;k<numpathpointconnect[j];k++){
470 if(pathpointconnect[j][k]==last)connected=1;
473 if(numpathpointconnect[last])
474 for(k=0;k<numpathpointconnect[last];k++){
475 if(pathpointconnect[last][k]==j)connected=1;
478 if(closest==-1||Random()%2==0){
489 if(count<smallestcount)smallestcount=count;
491 return smallestcount;
494 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
495 static XYZ colpoint,colviewer,coltarget;
496 static float minx,minz,maxx,maxz,miny,maxy;
505 if(minx>endpoint.x)minx=endpoint.x;
507 if(miny>endpoint.y)miny=endpoint.y;
509 if(minz>endpoint.z)minz=endpoint.z;
512 if(maxx<endpoint.x)maxx=endpoint.x;
514 if(maxy<endpoint.y)maxy=endpoint.y;
516 if(maxz<endpoint.z)maxz=endpoint.z;
525 for(i=0;i<objects.numobjects;i++){
526 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){
527 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
528 colviewer=startpoint;
530 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
535 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
540 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
541 static XYZ colpoint,colviewer,coltarget;
542 static float minx,minz,maxx,maxz,miny,maxy;
551 if(minx>endpoint.x)minx=endpoint.x;
553 if(miny>endpoint.y)miny=endpoint.y;
555 if(minz>endpoint.z)minz=endpoint.z;
558 if(maxx<endpoint.x)maxx=endpoint.x;
560 if(maxy<endpoint.y)maxy=endpoint.y;
562 if(maxz<endpoint.z)maxz=endpoint.z;
572 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){
573 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
574 colviewer=startpoint;
576 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
581 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
586 void Game::Setenvironment(int which)
590 LOG(" Setting environment...");
595 FSOUND_SetPaused(channels[music1snow], TRUE);
596 FSOUND_SetPaused(channels[music1grass], TRUE);
597 FSOUND_SetPaused(channels[music1desert], TRUE);
598 FSOUND_SetPaused(channels[wind], TRUE);
599 FSOUND_SetPaused(channels[desertambient], TRUE);
601 FSOUND_SetPaused(channels[stream_music1snow], TRUE);
602 FSOUND_SetPaused(channels[stream_music1grass], TRUE);
603 FSOUND_SetPaused(channels[stream_music1desert], TRUE);
604 FSOUND_SetPaused(channels[stream_wind], TRUE);
605 FSOUND_SetPaused(channels[stream_desertambient], TRUE);
608 if(environment==snowyenvironment){
612 //PlaySoundEx( wind, samp[wind], NULL, TRUE);
613 PlayStreamEx(stream_wind, strm[stream_wind], 0, TRUE);
614 FSOUND_SetPaused(channels[stream_wind], FALSE);
615 FSOUND_SetVolume(channels[stream_wind], 256);
618 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
619 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
620 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
621 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
623 FSOUND_Sample_Free(samp[footstepsound]);
624 FSOUND_Sample_Free(samp[footstepsound2]);
625 FSOUND_Sample_Free(samp[footstepsound3]);
626 FSOUND_Sample_Free(samp[footstepsound4]);
627 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0);
628 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0);
629 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0);
630 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0);
631 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
632 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
633 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
634 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
636 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
638 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
640 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
645 temptexdetail=texdetail;
646 if(texdetail>1)texdetail=4;
647 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
648 ":Data:Textures:Skybox(snow):Left.jpg",
649 ":Data:Textures:Skybox(snow):Back.jpg",
650 ":Data:Textures:Skybox(snow):Right.jpg",
651 ":Data:Textures:Skybox(snow):Up.jpg",
652 ":Data:Textures:Skybox(snow):Down.jpg",
653 ":Data:Textures:Skybox(snow):Cloud.jpg",
654 ":Data:Textures:Skybox(snow):Reflect.jpg");
659 texdetail=temptexdetail;
661 if(environment==desertenvironment){
664 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
665 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
666 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
667 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
671 //PlaySoundEx( desertambient, samp[desertambient], NULL, TRUE);
672 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, TRUE);
673 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
674 FSOUND_SetVolume(channels[stream_desertambient], 256);
677 FSOUND_Sample_Free(samp[footstepsound]);
678 FSOUND_Sample_Free(samp[footstepsound2]);
679 FSOUND_Sample_Free(samp[footstepsound3]);
680 FSOUND_Sample_Free(samp[footstepsound4]);
681 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0);
682 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0);
683 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0);
684 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0);
685 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
686 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
687 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
688 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
690 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
692 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
694 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
698 temptexdetail=texdetail;
699 if(texdetail>1)texdetail=4;
700 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
701 ":Data:Textures:Skybox(sand):Left.jpg",
702 ":Data:Textures:Skybox(sand):Back.jpg",
703 ":Data:Textures:Skybox(sand):Right.jpg",
704 ":Data:Textures:Skybox(sand):Up.jpg",
705 ":Data:Textures:Skybox(sand):Down.jpg",
706 ":Data:Textures:Skybox(sand):Cloud.jpg",
707 ":Data:Textures:Skybox(sand):Reflect.jpg");
712 texdetail=temptexdetail;
714 if(environment==grassyenvironment){
717 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
718 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
719 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
720 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
723 PlayStreamEx( stream_wind, strm[stream_wind], NULL, TRUE);
724 FSOUND_SetPaused(channels[stream_wind], FALSE);
725 FSOUND_SetVolume(channels[stream_wind], 100);
728 FSOUND_Sample_Free(samp[footstepsound]);
729 FSOUND_Sample_Free(samp[footstepsound2]);
730 FSOUND_Sample_Free(samp[footstepsound3]);
731 FSOUND_Sample_Free(samp[footstepsound4]);
732 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0);
733 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0);
734 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0);
735 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0);
736 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
737 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
738 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
739 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
741 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
743 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
745 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
749 temptexdetail=texdetail;
750 if(texdetail>1)texdetail=4;
751 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
752 ":Data:Textures:Skybox(grass):Left.jpg",
753 ":Data:Textures:Skybox(grass):Back.jpg",
754 ":Data:Textures:Skybox(grass):Right.jpg",
755 ":Data:Textures:Skybox(grass):Up.jpg",
756 ":Data:Textures:Skybox(grass):Down.jpg",
757 ":Data:Textures:Skybox(grass):Cloud.jpg",
758 ":Data:Textures:Skybox(grass):Reflect.jpg");
762 texdetail=temptexdetail;
764 temptexdetail=texdetail;
766 terrain.load(":Data:Textures:heightmap.png");
768 texdetail=temptexdetail;
772 void Game::Loadlevel(int which){
775 if(which==0)Loadlevel((char *)":Data:Maps:map1");
776 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
777 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
778 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
779 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
780 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
781 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
782 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
783 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
784 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
785 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
786 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
787 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
788 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
789 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
790 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
791 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
792 else Loadlevel((char *)":Data:Maps:mapsave");
797 /*char * Game::MD5_string (unsigned char *string){
801 strcpy(temp2,(const char *)string);
802 strcat((char *)temp2,(const char *)"Lugaru");
803 sprintf (temp, "%d",strlen((char *)temp2));
804 strcat((char *)temp2,temp);
807 unsigned int len = strlen ( (char *)temp2);
809 context.update ((unsigned char *)temp2, len);
812 return context.hex_digest();
817 void Game::Loadlevel(char *name){
824 float headprop,legprop,armprop,bodyprop;
828 LOG(std::string("Loading level...") + name);
830 if(!gameon)visibleloading=1;
832 if(stealthloading)visibleloading=0;
834 if(!stillloading)loadtime=0;
839 if(tutoriallevel!=-1)tutoriallevel=0;
840 else tutoriallevel=1;
842 if(tutoriallevel==1)tutorialstage=0;
843 if(tutorialstage==0){
851 FSOUND_SetPaused(channels[whooshsound], TRUE);
852 FSOUND_SetPaused(channels[stream_firesound], TRUE);
856 tfile=fopen( name, "rb" );
859 FSOUND_SetPaused(channels[stream_firesound], TRUE);
870 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
876 dialoguegonethrough[i]=0;
885 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
887 if(difficulty!=2)minimap=1;
924 bonustotal=startbonustotal;
930 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
931 FSOUND_SetVolume(channels[consolesuccesssound], 256);
932 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
940 sprites.numsprites=0;
941 for(i=0;i<objects.numobjects;i++)
943 objects.model[i].numdecals=0;
946 j=objects.numobjects;
949 objects.DeleteObject(0);
950 if(visibleloading){loadscreencolor=4; LoadingScreen();}
953 for(i=0;i<subdivision;i++)
955 for(j=0;j<subdivision;j++)
957 terrain.patchobjectnum[i][j]=0;
960 if(visibleloading){loadscreencolor=4; LoadingScreen();}
963 weapons.numweapons=0;
965 funpackf(tfile, "Bi", &mapvers);
966 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
968 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
969 else maptype=mapkilleveryone;
970 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
972 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
978 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
986 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
989 skyboxlightr=skyboxr;
990 skyboxlightg=skyboxg;
991 skyboxlightb=skyboxb;
993 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);
994 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
995 player[0].originalcoords=player[0].coords;
996 if(player[0].num_weapons>0&&player[0].num_weapons<5)
998 for(j=0;j<player[0].num_weapons;j++)
1000 player[0].weaponids[j]=weapons.numweapons;
1001 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1002 weapons.owner[weapons.numweapons]=0;
1003 weapons.numweapons++;
1007 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1009 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1010 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1011 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1012 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1014 funpackf(tfile, "Bi", &player[0].numclothes);
1018 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1022 player[0].whichskin=0;
1023 player[0].creature=rabbittype;
1026 for(i=0;i<max_dialogues;i++)
1028 for(j=0;j<max_dialoguelength;j++)
1032 dialoguetext[i][j][k]='\0';
1036 dialoguename[i][j][k]='\0';
1041 player[0].lastattack=-1;
1042 player[0].lastattack2=-1;
1043 player[0].lastattack3=-1;
1047 funpackf(tfile, "Bi", &numdialogues);
1050 for(k=0;k<numdialogues;k++)
1052 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1053 funpackf(tfile, "Bi", &dialoguetype[k]);
1056 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1057 funpackf(tfile, "Bf", &participantrotation[k][l]);
1059 if(numdialogueboxes)
1061 for(l=0;l<numdialogueboxes[k];l++)
1063 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1064 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1065 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1066 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1067 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1071 funpackf(tfile, "Bi",&templength);
1072 if(templength>128||templength<=0)templength=128;
1073 for(m=0;m<templength;m++){
1074 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1075 if(dialoguetext[k][l][m]=='\0')break;
1078 funpackf(tfile, "Bi",&templength);
1079 if(templength>64||templength<=0)templength=64;
1080 for(m=0;m<templength;m++){
1081 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1082 if(dialoguename[k][l][m]=='\0'){
1086 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1087 funpackf(tfile, "Bi", &participantfocus[k][l]);
1088 funpackf(tfile, "Bi", &participantaction[k][l]);
1091 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1093 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1099 else numdialogues=0;
1101 if(player[0].numclothes)
1103 for(k=0;k<player[0].numclothes;k++)
1105 funpackf(tfile, "Bi", &templength);
1106 for(l=0;l<templength;l++)
1107 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1108 player[0].clothes[k][templength]='\0';
1109 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1113 funpackf(tfile, "Bi", &environment);
1115 funpackf(tfile, "Bi", &objects.numobjects);
1116 if(objects.numobjects)
1118 for(i=0;i<objects.numobjects;i++)
1120 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]);
1121 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1127 funpackf(tfile, "Bi", &numhotspots);
1130 for(i=0;i<numhotspots;i++)
1132 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1133 funpackf(tfile, "Bi", &templength);
1135 for(l=0;l<templength;l++)
1136 funpackf(tfile, "Bb", &hotspottext[i][l]);
1137 hotspottext[i][templength]='\0';
1138 if(hotspottype[i]==-111)indemo=1;
1144 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1149 for(i=0;i<objects.numobjects;i++)
1151 objects.center+=objects.position[i];
1153 objects.center/=objects.numobjects;
1156 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1158 float maxdistance=0;
1161 for(i=0;i<objects.numobjects;i++)
1163 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1164 if(tempdist>maxdistance)
1167 maxdistance=tempdist;
1170 objects.radius=fast_sqrt(maxdistance);
1173 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1174 //mapcenter=objects.center;
1175 //mapradius=objects.radius;
1177 funpackf(tfile, "Bi", &numplayers);
1178 int howmanyremoved=0;
1179 bool removeanother=0;
1180 if(numplayers>1&&numplayers<maxplayers)
1182 for(i=1;i<numplayers;i++)
1184 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1187 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);
1188 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1189 else player[i-howmanyremoved].howactive=typeactive;
1190 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1191 else player[i-howmanyremoved].scale=-1;
1192 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1193 else player[i-howmanyremoved].immobile=0;
1194 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1195 else player[i-howmanyremoved].rotation=0;
1196 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1197 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1203 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1205 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1207 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1208 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1209 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1210 weapons.numweapons++;
1213 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1214 //player[i-howmanyremoved].numwaypoints=10;
1215 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1217 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1218 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1219 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1220 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1221 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1224 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1225 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1227 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1228 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1229 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1230 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1232 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1240 if(player[i-howmanyremoved].creature==wolftype)
1242 player[i-howmanyremoved].proportionhead=1.1*headprop;
1243 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1244 player[i-howmanyremoved].proportionarms=1.1*armprop;
1245 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1248 if(player[i-howmanyremoved].creature==rabbittype)
1250 player[i-howmanyremoved].proportionhead=1.2*headprop;
1251 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1252 player[i-howmanyremoved].proportionarms=1.00*armprop;
1253 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1254 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1257 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1258 if(player[i-howmanyremoved].numclothes)
1260 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1263 funpackf(tfile, "Bi", &templength);
1264 for(l=0;l<templength;l++)
1265 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1266 player[i-howmanyremoved].clothes[k][templength]='\0';
1267 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1273 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1275 numplayers-=howmanyremoved;
1276 funpackf(tfile, "Bi", &numpathpoints);
1277 if(numpathpoints>30||numpathpoints<0)
1281 for(j=0;j<numpathpoints;j++)
1283 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1284 for(k=0;k<numpathpointconnect[j];k++){
1285 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1289 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1291 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1294 if(environment!=oldenvironment)Setenvironment(environment);
1295 oldenvironment=environment;
1299 j=objects.numobjects;
1300 objects.numobjects=0;
1303 //if(objects.type[i]!=spiketype)
1304 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1305 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1308 //if(skyboxtexture){
1309 terrain.DoShadows();
1310 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1311 objects.DoShadows();
1312 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1314 else terrain.DoLighting();
1320 oldlevel=whichlevel;
1323 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1324 for(i=0;i<numplayers;i++)
1326 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1330 if(i==0||player[i].scale<0)player[i].scale=.2;
1331 player[i].skeleton.free=0;
1332 player[i].skeleton.id=i;
1333 //if(Random()%2==0)player[i].creature=wolftype;
1334 //else player[i].creature=rabbittype;
1335 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1336 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);
1339 if(player[i].creature!=wolftype){
1340 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);
1341 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1343 if(player[i].creature==wolftype){
1344 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);
1350 texsize=512*512*3/texdetail/texdetail;
1351 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1352 //player[i].skeleton.skinText.resize(texsize);
1354 if(player[i].creature==rabbittype)
1356 if(player[i].whichskin==0){
1357 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1359 else if(player[i].whichskin==1){
1360 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1362 else if(player[i].whichskin==2){
1363 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1365 else if(player[i].whichskin==3){
1366 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1368 else if(player[i].whichskin==4){
1369 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1371 else if(player[i].whichskin==5){
1372 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1374 else if(player[i].whichskin==6){
1375 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1377 else if(player[i].whichskin==7){
1378 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1380 else if(player[i].whichskin==8){
1381 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1383 else if(player[i].whichskin==9){
1384 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1387 if(player[i].creature==wolftype)
1389 //k=abs(Random()%3);
1390 if(player[i].whichskin==0){
1391 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1393 else if(player[i].whichskin==1){
1394 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1396 else if(player[i].whichskin==2){
1397 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1401 if(player[i].numclothes)
1403 for(j=0;j<player[i].numclothes;j++)
1405 tintr=player[i].clothestintr[j];
1406 tintg=player[i].clothestintg[j];
1407 tintb=player[i].clothestintb[j];
1408 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1410 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1413 player[i].currentanimation=bounceidleanim;
1414 player[i].targetanimation=bounceidleanim;
1415 player[i].currentframe=0;
1416 player[i].targetframe=1;
1418 player[i].speed=1+(float)(Random()%100)/1000;
1419 if(difficulty==0)player[i].speed-=.2;
1420 if(difficulty==1)player[i].speed-=.1;
1422 player[i].velocity=0;
1423 player[i].oldcoords=player[i].coords;
1424 player[i].realoldcoords=player[i].coords;
1427 player[i].skeleton.id=i;
1428 player[i].updatedelay=0;
1429 player[i].normalsupdatedelay=0;
1431 player[i].aitype=passivetype;
1432 player[i].aitarget=0;
1433 player[i].madskills=0;
1437 player[i].proportionhead=1.2;
1438 player[i].proportionbody=1.05;
1439 player[i].proportionarms=1.00;
1440 player[i].proportionlegs=1.1;
1441 player[i].proportionlegs.y=1.05;
1443 player[i].headless=0;
1444 player[i].currentoffset=0;
1445 player[i].targetoffset=0;
1446 /*player[i].armorhead=1;
1447 player[i].armorhigh=1;
1448 player[i].armorlow=1;
1449 player[i].protectionhead=1;
1450 player[i].protectionhigh=1;
1451 player[i].protectionlow=1;
1452 player[i].metalhead=1;
1453 player[i].metalhigh=1;
1454 player[i].metallow=1;
1456 player[i].speedmult=1;*/
1458 player[i].damagetolerance=200;
1460 if(player[i].creature==wolftype)
1462 /*player[i].proportionhead=1.1;
1463 player[i].proportionbody=1.1;
1464 player[i].proportionarms=1.1;
1465 player[i].proportionlegs=1.1;
1466 player[i].proportionlegs.y=1.1;*/
1467 if(i==0||player[i].scale<0)player[i].scale=.23;
1469 player[i].damagetolerance=300;
1472 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1475 player[i].proportionhead.z=0;
1476 player[i].proportionbody.z=0;
1477 player[i].proportionarms.z=0;
1478 player[i].proportionlegs.z=0;
1481 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1483 player[i].headmorphness=0;
1484 player[i].targetheadmorphness=1;
1485 player[i].headmorphstart=0;
1486 player[i].headmorphend=0;
1488 player[i].pausetime=0;
1491 player[i].jumppower=5;
1493 player[i].permanentdamage=0;
1494 player[i].superpermanentdamage=0;
1496 player[i].forwardkeydown=0;
1497 player[i].leftkeydown=0;
1498 player[i].backkeydown=0;
1499 player[i].rightkeydown=0;
1500 player[i].jumpkeydown=0;
1501 player[i].crouchkeydown=0;
1502 player[i].throwkeydown=0;
1504 player[i].collided=-10;
1506 player[i].bloodloss=0;
1507 player[i].weaponactive=-1;
1508 player[i].weaponstuck=-1;
1509 player[i].bleeding=0;
1510 player[i].deathbleeding=0;
1511 player[i].stunned=0;
1512 player[i].hasvictim=0;
1513 player[i].wentforweapon=0;
1516 player[0].aitype=playercontrolled;
1517 player[0].weaponactive=-1;
1521 //player[0].speedmult=1/.9;
1522 player[0].power=1/.9;
1527 //player[0].speedmult=1/.8;
1528 player[0].power=1/.8;
1531 //player[0].weaponstuck=1;
1533 if(difficulty==1)player[0].damagetolerance=250;
1534 if(difficulty==0)player[0].damagetolerance=300;
1535 if(difficulty==0)player[0].armorhead*=1.5;
1536 if(difficulty==0)player[0].armorhigh*=1.5;
1537 if(difficulty==0)player[0].armorlow*=1.5;
1538 cameraloc=player[0].coords;
1540 rotation=player[0].rotation;
1542 hawkcoords=player[0].coords;
1545 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1546 //weapons.numweapons=numplayers;
1547 for(i=0;i<weapons.numweapons;i++)
1549 weapons.bloody[i]=0;
1550 weapons.blooddrip[i]=0;
1551 weapons.blooddripdelay[i]=0;
1552 weapons.onfire[i]=0;
1553 weapons.flamedelay[i]=0;
1554 weapons.damage[i]=0;
1555 //weapons.type[i]=sword;
1556 if(weapons.type[i]==sword){
1557 weapons.mass[i]=1.5;
1558 weapons.tipmass[i]=1;
1559 weapons.length[i]=.8;
1561 if(weapons.type[i]==staff){
1563 weapons.tipmass[i]=1;
1564 weapons.length[i]=1.5;
1566 if(weapons.type[i]==knife){
1568 weapons.tipmass[i]=1.2;
1569 weapons.length[i]=.25;
1571 weapons.position[i]=-1000;
1572 weapons.tippoint[i]=-1000;
1575 /* for(i=0;i<32;i++){
1577 FSOUND_StopSound(i);
1580 LOG("Starting background music...");
1582 FSOUND_StopSound(FSOUND_ALL);
1583 if(environment==snowyenvironment)
1587 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1588 FSOUND_SetPaused(channels[stream_wind], FALSE);
1589 FSOUND_SetVolume(channels[stream_wind], 256);
1592 else if(environment==desertenvironment)
1596 //PlaySoundEx(desertambient,
1597 // samp[desertambient], NULL, TRUE);
1598 PlayStreamEx(stream_desertambient,
1599 strm[stream_desertambient], NULL, TRUE);
1600 FSOUND_SetPaused(channels[stream_desertambient], FALSE);
1601 FSOUND_SetVolume(channels[stream_desertambient], 256);
1604 else if(environment==grassyenvironment)
1608 //PlaySoundEx(wind, samp[wind], NULL, TRUE);
1609 PlayStreamEx(stream_wind, strm[stream_wind], NULL, TRUE);
1610 FSOUND_SetPaused(channels[stream_wind], FALSE);
1611 FSOUND_SetVolume(channels[stream_wind], 100);
1614 oldmusicvolume[0]=0;
1615 oldmusicvolume[1]=0;
1616 oldmusicvolume[2]=0;
1617 oldmusicvolume[3]=0;
1620 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1621 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1622 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1623 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1624 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1625 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1626 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1627 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1642 static int i,k,j,l,m;
1643 static XYZ facing,flatfacing,absflatfacing;
1644 static XYZ rotatetarget;
1646 static float oldtargetrotation;
1647 static int target, numgood;
1648 static XYZ tempcoords1,tempcoords2;
1651 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1652 static int whichhit;
1653 static bool donesomething;
1654 static bool oldjumpkeydown;
1658 float headprop,bodyprop,armprop,legprop;
1662 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
1663 FSOUND_SetVolume(channels[consolesuccesssound], 256);
1664 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
1668 consoletext[k][j]=consoletext[k-1][j];
1670 consolechars[k]=consolechars[k-1];
1674 displaytext[k][j]=displaytext[k-1][j];
1676 displaychars[k]=displaychars[k-1];
1677 displaytime[k]=displaytime[k-1];
1680 consoletext[1][j]=' ';
1681 displaytext[1][j]=' ';
1683 sprintf (consoletext[1], netmessages);
1684 sprintf (displaytext[1], netmessages);
1685 consolechars[1]=255;
1686 displaychars[1]=255;
1691 displaytime[i]+=multiplier;
1694 static unsigned char theKeyMap[16];
1695 GetKeys( theKeyMap );
1700 static bool mainmenutogglekeydown;
1702 if(mainmenu&&endgame==1)mainmenu=10;
1703 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1705 displaytext[0][j]=' ';
1710 mainmenutogglekeydown=1;
1712 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)){
1714 if(mainmenu==1||mainmenu==2||mainmenu==0){
1715 if(mainmenu==0&&!winfreeze)mainmenu=2;
1716 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1717 else if(mainmenu==0&&winfreeze){
1718 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1720 else stealthloading=0;
1722 if(!stealthloading){
1723 float gLoc[3]={0,0,0};
1724 float vel[3]={0,0,0};
1725 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1726 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
1727 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1728 FSOUND_SetVolume(channels[firestartsound], 256);
1729 FSOUND_SetPaused(channels[firestartsound], FALSE);
1730 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1741 for(i=0;i<campaignnumlevels;i++){
1743 levelhighlight[i]=0;
1748 if(accountcampaignchoicesmade[accountactive])
1749 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1750 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1751 levelvisible[levelorder[i+1]]=1;
1753 int whichlevelstart;
1754 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1755 if(whichlevelstart<0){
1756 campaignchoicenum=1;
1757 campaignchoicewhich[0]=0;
1761 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1762 if(campaignchoicenum)
1763 for(i=0;i<campaignchoicenum;i++){
1764 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1765 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1766 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1773 if(firstload)TickOnceAfter();
1774 if(!firstload)LoadStuff();
1791 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1792 //accountcampaignchoicesmade[accountactive]++;
1795 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1803 FSOUND_SetPaused(channels[music3], TRUE);
1807 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1808 if(mainmenu&&musictoggle){
1809 if(mainmenu==1||mainmenu==2||mainmenu==100){
1810 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
1811 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
1812 FSOUND_SetPaused(channels[stream_music3], FALSE);
1813 FSOUND_SetVolume(channels[stream_music3], 256);
1814 FSOUND_SetPaused(channels[music1], TRUE);
1818 FSOUND_SetPaused(channels[stream_music3], TRUE);
1819 FSOUND_SetPaused(channels[music1], FALSE);
1823 float gLoc[3]={0,0,0};
1824 float vel[3]={0,0,0};
1825 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1826 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1827 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1828 FSOUND_SetVolume(channels[fireendsound], 256);
1829 FSOUND_SetPaused(channels[fireendsound], FALSE);
1830 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1838 if(newdetail>2)newdetail=detail;
1839 if(newdetail<0)newdetail=detail;
1840 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1841 if(newscreenwidth<0)newscreenwidth=screenwidth;
1842 if(newscreenheight>3000)newscreenheight=screenheight;
1843 if(newscreenheight<0)newscreenheight=screenheight;
1845 //ofstream opstream(":Data:config.txt");
1846 ofstream opstream("./Data/config.txt");
1847 opstream << "Screenwidth:\n";
1848 opstream << newscreenwidth;
1849 opstream << "\nScreenheight:\n";
1850 opstream << newscreenheight;
1851 opstream << "\nMouse sensitivity:\n";
1852 opstream << usermousesensitivity;
1853 opstream << "\nBlur(0,1):\n";
1854 opstream << ismotionblur;
1855 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1856 opstream << newdetail;
1857 opstream << "\nFloating jump:\n";
1858 opstream << floatjump;
1859 opstream << "\nMouse jump:\n";
1860 opstream << mousejump;
1861 opstream << "\nAmbient sound:\n";
1862 opstream << ambientsound;
1863 opstream << "\nBlood (0,1,2):\n";
1864 opstream << bloodtoggle;
1865 opstream << "\nAuto slomo:\n";
1866 opstream << autoslomo;
1867 opstream << "\nFoliage:\n";
1868 opstream << foliage;
1869 opstream << "\nMusic:\n";
1870 opstream << musictoggle;
1871 opstream << "\nTrilinear:\n";
1872 opstream << trilinear;
1873 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1875 opstream << "\nInvert mouse:\n";
1876 opstream << invertmouse;
1877 opstream << "\nGamespeed:\n";
1878 if(oldgamespeed==0)oldgamespeed=1;
1879 opstream << oldgamespeed;
1880 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1881 opstream << difficulty;
1882 opstream << "\nDamage effects(blackout, doublevision):\n";
1883 opstream << damageeffects;
1884 opstream << "\nText:\n";
1885 opstream << texttoggle;
1886 opstream << "\nDebug:\n";
1887 opstream << debugmode;
1888 opstream << "\nVBL Sync:\n";
1889 opstream << vblsync;
1890 opstream << "\nShow Points:\n";
1891 opstream << showpoints;
1892 opstream << "\nAlways Blur:\n";
1893 opstream << alwaysblur;
1894 opstream << "\nImmediate mode (turn on on G5):\n";
1895 opstream << immediate;
1896 opstream << "\nVelocity blur:\n";
1897 opstream << velocityblur;
1898 opstream << "\nVolume:\n";
1900 opstream << "\nForward key:\n";
1901 opstream << KeyToChar(forwardkey);
1902 opstream << "\nBack key:\n";
1903 opstream << KeyToChar(backkey);
1904 opstream << "\nLeft key:\n";
1905 opstream << KeyToChar(leftkey);
1906 opstream << "\nRight key:\n";
1907 opstream << KeyToChar(rightkey);
1908 opstream << "\nJump key:\n";
1909 opstream << KeyToChar(jumpkey);
1910 opstream << "\nCrouch key:\n";
1911 opstream << KeyToChar(crouchkey);
1912 opstream << "\nDraw key:\n";
1913 opstream << KeyToChar(drawkey);
1914 opstream << "\nThrow key:\n";
1915 opstream << KeyToChar(throwkey);
1916 opstream << "\nAttack key:\n";
1917 opstream << KeyToChar(attackkey);
1918 opstream << "\nChat key:\n";
1919 opstream << KeyToChar(chatkey);
1922 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1923 float gLoc[3]={0,0,0};
1924 float vel[3]={0,0,0};
1925 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1926 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1927 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1928 FSOUND_SetVolume(channels[fireendsound], 256);
1929 FSOUND_SetPaused(channels[fireendsound], FALSE);
1930 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1938 if(mainmenu==3&&gameon)mainmenu=2;
1939 if(mainmenu==3&&!gameon)mainmenu=1;
1940 if(mainmenu==5&&gameon)mainmenu=2;
1941 if(mainmenu==5&&!gameon)mainmenu=1;
1942 if(mainmenu==4)mainmenu=3;
1943 if(mainmenu==6)mainmenu=5;
1944 if(mainmenu==7)mainmenu=1;
1945 if(mainmenu==9)mainmenu=5;
1946 if(mainmenu==11)mainmenu=5;
1947 if(mainmenu==12)mainmenu=5;
1948 if(mainmenu==13)mainmenu=12;
1949 if(mainmenu==14)mainmenu=13;
1950 if(mainmenu==10)mainmenu=5;
1956 mainmenutogglekeydown=1;
1958 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1959 mainmenutogglekeydown=0;
1963 /*static bool minimaptogglekeydown;
1964 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1966 minimaptogglekeydown=1;
1968 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1969 minimaptogglekeydown=0;
1973 static bool minimaptogglekeydown;
1974 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1975 if(tutorialstage!=51)
1976 tutorialstagetime=tutorialmaxtime;
1977 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
1978 FSOUND_SetVolume(channels[consolefailsound], 128);
1979 FSOUND_SetPaused(channels[consolefailsound], FALSE);
1980 minimaptogglekeydown=1;
1982 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1983 minimaptogglekeydown=0;
1988 if(mainmenu==1||mainmenu==2){
1989 if(Button()&&!oldbutton&&selected==1){
1991 float gLoc[3]={0,0,0};
1992 float vel[3]={0,0,0};
1993 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1994 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
1995 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1996 FSOUND_SetVolume(channels[firestartsound], 256);
1997 FSOUND_SetPaused(channels[firestartsound], FALSE);
1998 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2007 if(accountactive!=-1)mainmenu=5;
2014 if(firstload)TickOnceAfter();
2015 if(!firstload)LoadStuff();
2021 FSOUND_SetPaused(channels[music3], TRUE); */
2027 FSOUND_SetPaused(channels[stream_music3], TRUE);
2028 FSOUND_SetPaused(channels[music1], FALSE);
2032 if(Button()&&!oldbutton&&selected==2){
2033 float gLoc[3]={0,0,0};
2034 float vel[3]={0,0,0};
2035 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2036 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2037 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2038 FSOUND_SetVolume(channels[firestartsound], 256);
2039 FSOUND_SetPaused(channels[firestartsound], FALSE);
2040 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2052 if(newdetail>2)newdetail=detail;
2053 if(newdetail<0)newdetail=detail;
2054 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2055 if(newscreenwidth<0)newscreenwidth=screenwidth;
2056 if(newscreenheight>3000)newscreenheight=screenheight;
2057 if(newscreenheight<0)newscreenheight=screenheight;
2060 if(Button()&&!oldbutton&&selected==3){
2061 float gLoc[3]={0,0,0};
2062 float vel[3]={0,0,0};
2063 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2064 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2065 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2066 FSOUND_SetVolume(channels[fireendsound], 256);
2067 FSOUND_SetPaused(channels[fireendsound], FALSE);
2068 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2079 if(registered)FSOUND_SetPaused(channels[stream_music3], TRUE);
2087 if(Button())oldbutton=1;
2092 if(Button()&&!oldbutton&&selected!=-1){
2093 float gLoc[3]={0,0,0};
2094 float vel[3]={0,0,0};
2095 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2096 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2097 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2098 FSOUND_SetVolume(channels[firestartsound], 256);
2099 FSOUND_SetPaused(channels[firestartsound], FALSE);
2100 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2102 if(Button()&&!oldbutton&&selected==0){
2105 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2106 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2107 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2108 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2109 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2110 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2111 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2112 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2114 if(whichres==-1||whichres==7){
2116 newscreenheight=480;
2120 newscreenheight=600;
2123 newscreenwidth=1024;
2124 newscreenheight=768;
2127 newscreenwidth=1280;
2128 newscreenheight=1024;
2131 newscreenwidth=1600;
2132 newscreenheight=1200;
2136 newscreenheight=524;
2139 newscreenwidth=1024;
2140 newscreenheight=640;
2143 newscreenwidth=1344;
2144 newscreenheight=840;
2147 if(Button()&&!oldbutton&&selected==1){
2149 if(newdetail>2)newdetail=0;
2151 if(Button()&&!oldbutton&&selected==2){
2153 if(bloodtoggle>2)bloodtoggle=0;
2155 if(Button()&&!oldbutton&&selected==3){
2157 if(difficulty>2)difficulty=0;
2159 if(Button()&&!oldbutton&&selected==4){
2160 ismotionblur=1-ismotionblur;
2162 if(Button()&&!oldbutton&&selected==5){
2165 if(Button()&&!oldbutton&&selected==6){
2166 musictoggle=1-musictoggle;
2169 FSOUND_SetPaused(channels[music1], TRUE);
2170 FSOUND_SetPaused(channels[stream_music2], TRUE);
2171 FSOUND_SetPaused(channels[stream_music3], TRUE);
2174 oldmusicvolume[i]=0;
2180 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2181 FSOUND_SetPaused(channels[stream_music3], FALSE);
2182 FSOUND_SetVolume(channels[stream_music3], 256);
2185 if(Button()&&!oldbutton&&selected==9){
2186 invertmouse=1-invertmouse;
2188 if(Button()&&!oldbutton&&selected==10){
2189 usermousesensitivity+=.2;
2190 if(usermousesensitivity>2)usermousesensitivity=.2;
2192 if(Button()&&!oldbutton&&selected==11){
2194 if(volume>1.0001f)volume=0;
2195 FSOUND_SetSFXMasterVolume((int)(volume*255));
2197 if(Button()&&!oldbutton&&selected==7){
2198 /*float gLoc[3]={0,0,0};
2199 float vel[3]={0,0,0};
2200 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2201 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2202 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2203 FSOUND_SetVolume(channels[firestartsound], 256);
2204 FSOUND_SetPaused(channels[firestartsound], FALSE);
2205 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2218 if(Button()&&!oldbutton&&selected==8){
2219 float gLoc[3]={0,0,0};
2220 float vel[3]={0,0,0};
2221 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2222 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2223 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2224 FSOUND_SetVolume(channels[fireendsound], 256);
2225 FSOUND_SetPaused(channels[fireendsound], FALSE);
2226 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2234 if(newdetail>2)newdetail=detail;
2235 if(newdetail<0)newdetail=detail;
2236 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2237 if(newscreenwidth<0)newscreenwidth=screenwidth;
2238 if(newscreenheight>3000)newscreenheight=screenheight;
2239 if(newscreenheight<0)newscreenheight=screenheight;
2242 //ofstream opstream(":Data:config.txt");
2243 ofstream opstream("./Data/config.txt");
2244 opstream << "Screenwidth:\n";
2245 opstream << newscreenwidth;
2246 opstream << "\nScreenheight:\n";
2247 opstream << newscreenheight;
2248 opstream << "\nMouse sensitivity:\n";
2249 opstream << usermousesensitivity;
2250 opstream << "\nBlur(0,1):\n";
2251 opstream << ismotionblur;
2252 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2253 opstream << newdetail;
2254 opstream << "\nFloating jump:\n";
2255 opstream << floatjump;
2256 opstream << "\nMouse jump:\n";
2257 opstream << mousejump;
2258 opstream << "\nAmbient sound:\n";
2259 opstream << ambientsound;
2260 opstream << "\nBlood (0,1,2):\n";
2261 opstream << bloodtoggle;
2262 opstream << "\nAuto slomo:\n";
2263 opstream << autoslomo;
2264 opstream << "\nFoliage:\n";
2265 opstream << foliage;
2266 opstream << "\nMusic:\n";
2267 opstream << musictoggle;
2268 opstream << "\nTrilinear:\n";
2269 opstream << trilinear;
2270 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2272 opstream << "\nInvert mouse:\n";
2273 opstream << invertmouse;
2274 opstream << "\nGamespeed:\n";
2275 if(oldgamespeed==0)oldgamespeed=1;
2276 opstream << oldgamespeed;
2277 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2278 opstream << difficulty;
2279 opstream << "\nDamage effects(blackout, doublevision):\n";
2280 opstream << damageeffects;
2281 opstream << "\nText:\n";
2282 opstream << texttoggle;
2283 opstream << "\nDebug:\n";
2284 opstream << debugmode;
2285 opstream << "\nVBL Sync:\n";
2286 opstream << vblsync;
2287 opstream << "\nShow Points:\n";
2288 opstream << showpoints;
2289 opstream << "\nAlways Blur:\n";
2290 opstream << alwaysblur;
2291 opstream << "\nImmediate mode (turn on on G5):\n";
2292 opstream << immediate;
2293 opstream << "\nVelocity blur:\n";
2294 opstream << velocityblur;
2295 opstream << "\nVolume:\n";
2297 opstream << "\nForward key:\n";
2298 opstream << KeyToChar(forwardkey);
2299 opstream << "\nBack key:\n";
2300 opstream << KeyToChar(backkey);
2301 opstream << "\nLeft key:\n";
2302 opstream << KeyToChar(leftkey);
2303 opstream << "\nRight key:\n";
2304 opstream << KeyToChar(rightkey);
2305 opstream << "\nJump key:\n";
2306 opstream << KeyToChar(jumpkey);
2307 opstream << "\nCrouch key:\n";
2308 opstream << KeyToChar(crouchkey);
2309 opstream << "\nDraw key:\n";
2310 opstream << KeyToChar(drawkey);
2311 opstream << "\nThrow key:\n";
2312 opstream << KeyToChar(throwkey);
2313 opstream << "\nAttack key:\n";
2314 opstream << KeyToChar(attackkey);
2315 opstream << "\nChat key:\n";
2316 opstream << KeyToChar(chatkey);
2319 if(mainmenu==3&&gameon)mainmenu=2;
2320 if(mainmenu==3&&!gameon)mainmenu=1;
2322 if(Button())oldbutton=1;
2326 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2327 float gLoc[3]={0,0,0};
2328 float vel[3]={0,0,0};
2329 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2330 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2331 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2332 FSOUND_SetVolume(channels[firestartsound], 256);
2333 FSOUND_SetPaused(channels[firestartsound], FALSE);
2334 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2336 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2344 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2346 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2347 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2348 float gLoc[3]={0,0,0};
2349 float vel[3]={0,0,0};
2350 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2351 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2352 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2353 FSOUND_SetVolume(channels[fireendsound], 256);
2354 FSOUND_SetPaused(channels[fireendsound], FALSE);
2355 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2359 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2360 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2364 if(keyselect==0)forwardkey=keynum;
2365 if(keyselect==1)backkey=keynum;
2366 if(keyselect==2)leftkey=keynum;
2367 if(keyselect==3)rightkey=keynum;
2368 if(keyselect==4)crouchkey=keynum;
2369 if(keyselect==5)jumpkey=keynum;
2370 if(keyselect==6)drawkey=keynum;
2371 if(keyselect==7)throwkey=keynum;
2372 if(keyselect==8)attackkey=keynum;
2377 if(Button()&&!oldbutton&&selected==9){
2378 float gLoc[3]={0,0,0};
2379 float vel[3]={0,0,0};
2380 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2381 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2382 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2383 FSOUND_SetVolume(channels[fireendsound], 256);
2384 FSOUND_SetPaused(channels[fireendsound], FALSE);
2385 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2395 if(newdetail>2)newdetail=detail;
2396 if(newdetail<0)newdetail=detail;
2397 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2398 if(newscreenwidth<0)newscreenwidth=screenwidth;
2399 if(newscreenheight>3000)newscreenheight=screenheight;
2400 if(newscreenheight<0)newscreenheight=screenheight;
2405 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2406 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
2407 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
2408 FSOUND_SetPaused(channels[stream_music3], FALSE);
2409 FSOUND_SetVolume(channels[stream_music3], 256);
2413 accountcampaignchoicesmade[accountactive]=0;
2414 accountcampaignscore[accountactive]=0;
2415 accountcampaigntime[accountactive]=0;
2417 float gLoc[3]={0,0,0};
2418 float vel[3]={0,0,0};
2419 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2420 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2421 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2422 FSOUND_SetVolume(channels[fireendsound], 256);
2423 FSOUND_SetPaused(channels[fireendsound], FALSE);
2424 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2434 accountcampaignchoicesmade[accountactive]=0;
2435 accountcampaignscore[accountactive]=0;
2436 accountcampaigntime[accountactive]=0;
2440 if(Button()&&!oldbutton&&selected==1){
2441 float gLoc[3]={0,0,0};
2442 float vel[3]={0,0,0};
2443 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2444 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2445 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2446 FSOUND_SetVolume(channels[firestartsound], 256);
2447 FSOUND_SetPaused(channels[firestartsound], FALSE);
2448 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2461 if(firstload)TickOnceAfter();
2462 if(!firstload)LoadStuff();
2469 FSOUND_SetPaused(channels[stream_music3], TRUE);
2471 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2472 float gLoc[3]={0,0,0};
2473 float vel[3]={0,0,0};
2474 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2475 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2476 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2477 FSOUND_SetVolume(channels[firestartsound], 256);
2478 FSOUND_SetPaused(channels[firestartsound], FALSE);
2479 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2492 if(firstload)TickOnceAfter();
2493 if(!firstload)LoadStuff();
2509 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2510 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2514 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2519 FSOUND_SetPaused(channels[stream_music3], TRUE);
2521 if(Button()&&!oldbutton&&selected==4){
2522 float gLoc[3]={0,0,0};
2523 float vel[3]={0,0,0};
2524 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2525 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2526 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2527 FSOUND_SetVolume(channels[fireendsound], 256);
2528 FSOUND_SetPaused(channels[fireendsound], FALSE);
2529 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2537 if(mainmenu==5&&gameon)mainmenu=2;
2538 if(mainmenu==5&&!gameon)mainmenu=1;
2540 if(Button()&&!oldbutton&&selected==5){
2541 float gLoc[3]={0,0,0};
2542 float vel[3]={0,0,0};
2543 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2544 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2545 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2546 FSOUND_SetVolume(channels[fireendsound], 256);
2547 FSOUND_SetPaused(channels[fireendsound], FALSE);
2548 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2558 if(Button()&&!oldbutton&&selected==3){
2559 float gLoc[3]={0,0,0};
2560 float vel[3]={0,0,0};
2561 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2562 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2563 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2564 FSOUND_SetVolume(channels[firestartsound], 256);
2565 FSOUND_SetPaused(channels[firestartsound], FALSE);
2566 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2576 if(Button()&&!oldbutton&&selected==2){
2577 float gLoc[3]={0,0,0};
2578 float vel[3]={0,0,0};
2579 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2580 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2581 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2582 FSOUND_SetVolume(channels[firestartsound], 256);
2583 FSOUND_SetPaused(channels[firestartsound], FALSE);
2584 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2594 if(Button())oldbutton=1;
2598 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2599 float gLoc[3]={0,0,0};
2600 float vel[3]={0,0,0};
2601 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2602 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2603 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2604 FSOUND_SetVolume(channels[firestartsound], 256);
2605 FSOUND_SetPaused(channels[firestartsound], FALSE);
2606 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2618 targetlevel=selected;
2619 if(firstload)TickOnceAfter();
2620 if(!firstload)LoadStuff();
2622 Loadlevel(selected);
2628 FSOUND_SetPaused(channels[stream_music3], TRUE);
2630 if(Button()&&!oldbutton&&selected==numchallengelevels){
2631 float gLoc[3]={0,0,0};
2632 float vel[3]={0,0,0};
2633 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2634 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2635 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2636 FSOUND_SetVolume(channels[fireendsound], 256);
2637 FSOUND_SetPaused(channels[fireendsound], FALSE);
2638 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2648 if(Button())oldbutton=1;
2652 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2653 float gLoc[3]={0,0,0};
2654 float vel[3]={0,0,0};
2655 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2656 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2657 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2658 FSOUND_SetVolume(channels[firestartsound], 256);
2659 FSOUND_SetPaused(channels[firestartsound], FALSE);
2660 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2672 targetlevel=selected;
2673 if(firstload)TickOnceAfter();
2674 if(!firstload)LoadStuff();
2676 Loadlevel(selected);
2682 FSOUND_SetPaused(channels[stream_music3], TRUE);
2684 if(Button()&&!oldbutton&&selected==numchallengelevels){
2685 float gLoc[3]={0,0,0};
2686 float vel[3]={0,0,0};
2687 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2688 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2689 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2690 FSOUND_SetVolume(channels[fireendsound], 256);
2691 FSOUND_SetPaused(channels[fireendsound], FALSE);
2692 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2702 if(Button())oldbutton=1;
2707 if(Button()&&!oldbutton&&selected==3){
2708 float gLoc[3]={0,0,0};
2709 float vel[3]={0,0,0};
2710 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2711 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2712 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2713 FSOUND_SetVolume(channels[fireendsound], 256);
2714 FSOUND_SetPaused(channels[fireendsound], FALSE);
2715 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2725 if(Button())oldbutton=1;
2729 if(mainmenu==15||mainmenu==16){
2730 if(Button()&&!oldbutton&&selected==1){
2731 float gLoc[3]={0,0,0};
2732 float vel[3]={0,0,0};
2733 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2734 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2735 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2736 FSOUND_SetVolume(channels[fireendsound], 256);
2737 FSOUND_SetPaused(channels[fireendsound], FALSE);
2738 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2746 if(mainmenu==15)mainmenu=5;
2749 if(Button())oldbutton=1;
2755 if(Button()&&!oldbutton&&selected==3){
2757 float gLoc[3]={0,0,0};
2758 float vel[3]={0,0,0};
2759 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2760 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2761 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2762 FSOUND_SetVolume(channels[fireendsound], 256);
2763 FSOUND_SetPaused(channels[fireendsound], FALSE);
2764 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2775 if(Button()&&!oldbutton&&selected==4){
2778 float gLoc[3]={0,0,0};
2779 float vel[3]={0,0,0};
2780 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2781 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2782 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2783 FSOUND_SetVolume(channels[fireendsound], 256);
2784 FSOUND_SetPaused(channels[fireendsound], FALSE);
2785 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2795 if(Button()&&!oldbutton&&selected==5){
2797 float gLoc[3]={0,0,0};
2798 float vel[3]={0,0,0};
2799 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2800 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2801 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2802 FSOUND_SetVolume(channels[fireendsound], 256);
2803 FSOUND_SetPaused(channels[fireendsound], FALSE);
2804 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2814 if(Button())oldbutton=1;
2818 if(Button()&&!oldbutton&&selected!=-1){
2819 float gLoc[3]={0,0,0};
2820 float vel[3]={0,0,0};
2821 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2822 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2823 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2824 FSOUND_SetVolume(channels[firestartsound], 256);
2825 FSOUND_SetPaused(channels[firestartsound], FALSE);
2826 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
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[fireendsound], 9999.0f, 99999.0f);
2832 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2833 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2834 FSOUND_SetVolume(channels[fireendsound], 256);
2835 FSOUND_SetPaused(channels[fireendsound], FALSE);
2836 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2844 for(i=accountactive;i<numaccounts-1;i++){
2845 accountdifficulty[i]=accountdifficulty[i+1];
2846 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2847 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2848 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2850 accountpoints[i]=accountpoints[i+1];
2852 accounthighscore[i][j]=accounthighscore[i+1][j];
2853 accountfasttime[i][j]=accountfasttime[i+1][j];
2856 accountunlocked[i][j]=accountunlocked[i+1][j];
2859 accountname[i][j]=accountname[i+1][j];
2861 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2862 accountprogress[i]=accountprogress[i+1];
2863 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2864 accountcampaignscore[i]=accountcampaignscore[i+1];
2865 accountcampaigntime[i]=accountcampaigntime[i+1];
2874 if(Button()&&!oldbutton&&selected==2){
2875 float gLoc[3]={0,0,0};
2876 float vel[3]={0,0,0};
2877 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2878 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2879 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2880 FSOUND_SetVolume(channels[fireendsound], 256);
2881 FSOUND_SetPaused(channels[fireendsound], FALSE);
2882 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2892 if(Button())oldbutton=1;
2896 if(Button()&&!oldbutton&&selected!=-1){
2897 float gLoc[3]={0,0,0};
2898 float vel[3]={0,0,0};
2899 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2900 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2901 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2902 FSOUND_SetVolume(channels[firestartsound], 256);
2903 FSOUND_SetPaused(channels[firestartsound], FALSE);
2904 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2906 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2909 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2910 accountactive=selected-1;
2918 if(Button()&&!oldbutton&&selected==numaccounts+1){
2919 float gLoc[3]={0,0,0};
2920 float vel[3]={0,0,0};
2921 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2922 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
2923 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2924 FSOUND_SetVolume(channels[fireendsound], 256);
2925 FSOUND_SetPaused(channels[fireendsound], FALSE);
2926 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2937 displaytext[0][j]=' ';
2943 if(Button())oldbutton=1;
2947 if(Button()&&!oldbutton&&selected!=-1){
2948 float gLoc[3]={0,0,0};
2949 float vel[3]={0,0,0};
2950 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2951 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
2952 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2953 FSOUND_SetVolume(channels[firestartsound], 256);
2954 FSOUND_SetPaused(channels[firestartsound], FALSE);
2955 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2957 if(selected==0)accountdifficulty[accountactive]=0;
2958 if(selected==1)accountdifficulty[accountactive]=1;
2959 if(selected==2)accountdifficulty[accountactive]=2;
2970 if(Button())oldbutton=1;
2975 if(Button())oldbutton=1;
2978 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2981 if(newdetail>2)newdetail=detail;
2982 if(newdetail<0)newdetail=detail;
2983 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2984 if(newscreenwidth<0)newscreenwidth=screenwidth;
2985 if(newscreenheight>3000)newscreenheight=screenheight;
2986 if(newscreenheight<0)newscreenheight=screenheight;
2988 //ofstream opstream(":Data:config.txt");
2989 ofstream opstream("./Data/config.txt");
2990 opstream << "Screenwidth:\n";
2991 opstream << newscreenwidth;
2992 opstream << "\nScreenheight:\n";
2993 opstream << newscreenheight;
2994 opstream << "\nMouse sensitivity:\n";
2995 opstream << usermousesensitivity;
2996 opstream << "\nBlur(0,1):\n";
2997 opstream << ismotionblur;
2998 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2999 opstream << newdetail;
3000 opstream << "\nFloating jump:\n";
3001 opstream << floatjump;
3002 opstream << "\nMouse jump:\n";
3003 opstream << mousejump;
3004 opstream << "\nAmbient sound:\n";
3005 opstream << ambientsound;
3006 opstream << "\nBlood (0,1,2):\n";
3007 opstream << bloodtoggle;
3008 opstream << "\nAuto slomo:\n";
3009 opstream << autoslomo;
3010 opstream << "\nFoliage:\n";
3011 opstream << foliage;
3012 opstream << "\nMusic:\n";
3013 opstream << musictoggle;
3014 opstream << "\nTrilinear:\n";
3015 opstream << trilinear;
3016 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3018 opstream << "\nInvert mouse:\n";
3019 opstream << invertmouse;
3020 opstream << "\nGamespeed:\n";
3021 if(oldgamespeed==0)oldgamespeed=1;
3022 opstream << oldgamespeed;
3023 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3024 opstream << difficulty;
3025 opstream << "\nDamage effects(blackout, doublevision):\n";
3026 opstream << damageeffects;
3027 opstream << "\nText:\n";
3028 opstream << texttoggle;
3029 opstream << "\nDebug:\n";
3030 opstream << debugmode;
3031 opstream << "\nVBL Sync:\n";
3032 opstream << vblsync;
3033 opstream << "\nShow Points:\n";
3034 opstream << showpoints;
3035 opstream << "\nAlways Blur:\n";
3036 opstream << alwaysblur;
3037 opstream << "\nImmediate mode (turn on on G5):\n";
3038 opstream << immediate;
3039 opstream << "\nVelocity blur:\n";
3040 opstream << velocityblur;
3041 opstream << "\nVolume:\n";
3043 opstream << "\nForward key:\n";
3044 opstream << KeyToChar(forwardkey);
3045 opstream << "\nBack key:\n";
3046 opstream << KeyToChar(backkey);
3047 opstream << "\nLeft key:\n";
3048 opstream << KeyToChar(leftkey);
3049 opstream << "\nRight key:\n";
3050 opstream << KeyToChar(rightkey);
3051 opstream << "\nJump key:\n";
3052 opstream << KeyToChar(jumpkey);
3053 opstream << "\nCrouch key:\n";
3054 opstream << KeyToChar(crouchkey);
3055 opstream << "\nDraw key:\n";
3056 opstream << KeyToChar(drawkey);
3057 opstream << "\nThrow key:\n";
3058 opstream << KeyToChar(throwkey);
3059 opstream << "\nAttack key:\n";
3060 opstream << KeyToChar(attackkey);
3061 opstream << "\nChat key:\n";
3062 opstream << KeyToChar(chatkey);
3067 if(mainmenu==1||mainmenu==2){
3068 if(loaddistrib>4)transition+=multiplier/8;
3076 FSOUND_SetFrequency(channels[stream_music3], 22050);
3078 if(entername||mainmenu==13||mainmenu==14){
3080 if(IsKeyDown(theKeyMap, i)){
3081 togglekeydelay[i]+=multiplier;
3082 if(togglekeydelay[i]>.4){
3084 togglekeydelay[i]=.36;
3087 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3088 for(j=255;j>=displayselected+1;j--){
3089 displaytext[0][j]=displaytext[0][j-1];
3091 displaytext[0][displayselected]=KeyToSingleChar(i);
3092 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3096 if(i==MAC_DELETE_KEY&&displayselected!=0){
3097 for(j=displayselected-1;j<255;j++){
3098 displaytext[0][j]=displaytext[0][j+1];
3100 displaytext[0][255]=' ';
3104 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3107 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3110 if(i==MAC_RETURN_KEY&&entername){
3111 if(displaychars[0]){
3113 strcpy(accountname[numaccounts-1],displaytext[0]);
3114 accountactive=numaccounts-1;
3115 accountdifficulty[accountactive]=1;
3116 accountprogress[accountactive]=0;
3117 accountpoints[accountactive]=0;
3118 accountcampaigntime[accountactive]=0;
3119 accountcampaignscore[accountactive]=0;
3120 accountcampaignfasttime[accountactive]=0;
3121 accountcampaignhighscore[accountactive]=0;
3123 accounthighscore[accountactive][j]=0;
3124 accountfasttime[accountactive][j]=0;
3127 accountunlocked[accountactive][j]=0;
3129 accountcampaignchoicesmade[accountactive]=0;
3132 displaytext[0][j]=' ';
3146 float gLoc[3]={0,0,0};
3147 float vel[3]={0,0,0};
3148 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3149 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3150 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3151 FSOUND_SetVolume(channels[firestartsound], 256);
3152 FSOUND_SetPaused(channels[firestartsound], FALSE);
3153 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3156 displaytext[0][j]=' ';
3164 if(i==MAC_RETURN_KEY&&mainmenu==14){
3165 if(displaychars[0]){
3166 char serialstring[256];
3167 char tempstring[256];
3168 sprintf (tempstring, "%s-windows", registrationname);
3174 longnum = MD5_string ( tempstring);
3175 //longnum = 1111111111111111;
3176 num1 = longnum/100000000;
3177 num2 = longnum%100000000;
3178 sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3182 if(num1/10000>999)numchars+=4;
3183 else if(num1/10000>99)numchars+=3;
3184 else if(num1/10000>9)numchars+=2;
3186 if(num1%10000>999)numchars+=4;
3187 else if(num1%10000>99)numchars+=3;
3188 else if(num1%10000>9)numchars+=2;
3190 if(num2/10000>999)numchars+=4;
3191 else if(num2/10000>99)numchars+=3;
3192 else if(num2/10000>9)numchars+=2;
3194 if(num2%10000>999)numchars+=4;
3195 else if(num2%10000>99)numchars+=3;
3196 else if(num2%10000>9)numchars+=2;
3201 for(j=0;j<numchars;j++){
3202 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3205 if(longnum==5077041556214789)goodcode=-1;
3207 if(goodcode<0)goodcode=0;
3214 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3218 numchars=strlen(registrationname);
3219 fpackf(tfile, "Bb", registered);
3220 fpackf(tfile, "Bi", numchars);
3223 for(j=0;j<numchars;j++)
3225 fpackf(tfile, "Bb", registrationname[j]);
3228 fpackf(tfile, "Bi", num1);
3229 fpackf(tfile, "Bi", num2);
3243 float gLoc[3]={0,0,0};
3244 float vel[3]={0,0,0};
3245 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3246 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3247 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3248 FSOUND_SetVolume(channels[firestartsound], 256);
3249 FSOUND_SetPaused(channels[firestartsound], FALSE);
3250 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3253 displaytext[0][j]=' ';
3259 if(i==MAC_RETURN_KEY&&mainmenu==13){
3260 if(displaychars[0]){
3261 sprintf (registrationname, "%s", displaytext[0]);
3262 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3272 float gLoc[3]={0,0,0};
3273 float vel[3]={0,0,0};
3274 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3275 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
3276 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3277 FSOUND_SetVolume(channels[firestartsound], 256);
3278 FSOUND_SetPaused(channels[firestartsound], FALSE);
3279 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3282 displaytext[0][j]=' ';
3286 /*char tempstring[50];
3287 sprintf (tempstring, registrationname);
3293 longnum = MD5_string ( tempstring);
3294 num1 = longnum/100000000;
3295 num2 = longnum%100000000;
3296 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3298 displaychars[0]=strlen(displaytext[0]);
3307 togglekeydelay[i]=0;
3311 displayblinkdelay-=multiplier;
3312 if(displayblinkdelay<=0){
3313 displayblinkdelay=.3;
3314 displayblink=1-displayblink;
3320 if(hostile==1)hostiletime+=multiplier;
3322 if(!winfreeze)leveltime+=multiplier;
3323 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3330 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3332 chattogglekeydown=1;
3333 togglekey[chatkey]=1;
3334 togglekeydelay[chatkey]=-20;
3337 if(!IsKeyDown(theKeyMap, chatkey)){
3338 chattogglekeydown=0;
3343 if(IsKeyDown(theKeyMap, i)){
3344 togglekeydelay[i]+=multiplier;
3345 if(togglekeydelay[i]>.4){
3347 togglekeydelay[i]=.36;
3350 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3351 for(j=255;j>=displayselected+1;j--){
3352 displaytext[0][j]=displaytext[0][j-1];
3354 displaytext[0][displayselected]=KeyToSingleChar(i);
3355 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3359 if(i==MAC_DELETE_KEY&&displayselected!=0){
3360 for(j=displayselected-1;j<255;j++){
3361 displaytext[0][j]=displaytext[0][j+1];
3363 displaytext[0][255]=' ';
3367 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3370 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3373 if(i==MAC_RETURN_KEY){
3374 if(displaychars[0]){
3375 /*for(j=0;j<displaychars[0];j++){
3376 talkname[j]=displaytext[0][j];
3378 talkname[displaychars[0]]='\0';
3379 sprintf (chatname, "%s: %s",playerName,talkname);
3380 //NetworkSendInformation(chatname);
3383 displaytext[0][j]=' ';
3395 togglekeydelay[i]=0;
3399 displayblinkdelay-=multiplier;
3400 if(displayblinkdelay<=0){
3401 displayblinkdelay=.3;
3402 displayblink=1-displayblink;
3406 if(chatting)keyboardfrozen=1;
3408 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3411 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3413 freezetogglekeydown=1;
3416 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3417 freezetogglekeydown=0;
3420 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3422 if(!console)freeze=0;
3424 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3426 consoletogglekeydown=1;
3429 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3430 consoletogglekeydown=0;
3433 if(console)freeze=1;
3435 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3437 if(IsKeyDown(theKeyMap, i)){
3438 togglekeydelay[i]+=multiplier;
3439 if(togglekeydelay[i]>.4){
3441 togglekeydelay[i]=.36;
3444 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3445 for(j=255;j>=consoleselected+1;j--){
3446 consoletext[0][j]=consoletext[0][j-1];
3448 consoletext[0][consoleselected]=KeyToSingleChar(i);
3449 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3453 else if(i==MAC_ENTER_KEY){
3454 for(j=255;j>=consoleselected+1;j--){
3455 consoletext[0][j]=consoletext[0][j-1];
3457 consoletext[0][consoleselected]='\n';
3461 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3462 for(j=consoleselected-1;j<255;j++){
3463 consoletext[0][j]=consoletext[0][j+1];
3465 consoletext[0][255]=' ';
3469 if(i==MAC_ARROW_UP_KEY){
3470 if(archiveselected<14)archiveselected++;
3472 consolechars[0]=consolechars[archiveselected];
3473 consoletext[0][j]=consoletext[archiveselected][j];
3474 consoleselected=consolechars[0];
3477 if(i==MAC_ARROW_DOWN_KEY){
3478 if(archiveselected>0)archiveselected--;
3480 consolechars[0]=consolechars[archiveselected];
3481 consoletext[0][j]=consoletext[archiveselected][j];
3482 consoleselected=consolechars[0];
3485 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3488 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3491 if(i==MAC_RETURN_KEY){
3494 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3495 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3496 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3497 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3501 /*if(Compare(consoletext[0],"send ",0,4)){
3502 for(j=5;j<consolechars[0];j++){
3503 talkname[j-5]=consoletext[0][j];
3505 talkname[consolechars[0]-5]='\0';
3506 sprintf (chatname, "%s: %s",playerName,talkname);
3507 //NetworkSendInformation(chatname);
3510 if(Compare(consoletext[0],"name ",0,4)){
3512 numchars=consolechars[0]-5;
3513 if(numchars>32)numchars=32;
3514 for(j=5;j<numchars+5;j++){
3515 talkname[j-5]=consoletext[0][j];
3517 talkname[numchars]='\0';
3518 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3519 //NetworkSendInformation(chatname);
3520 sprintf (playerName, "%s",talkname);
3521 //NetworkSendName(playerName);
3524 if(Compare(consoletext[0],"map ",0,3)){
3536 for(j=4;j<consolechars[0];j++){
3537 mapname[j-4+11]=consoletext[0][j];
3539 mapname[consolechars[0]-4+11]='\0';
3545 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3547 unsigned char playerNameStr[32];
3548 char theIPAddress[256];
3550 NMUInt32 port = 25710;
3552 strcpy(playerName, "Client");
3553 GameC2PStr( playerName, playerNameStr );
3555 for(j=0;j<consolechars[0]-8;j++){
3556 theIPAddress[j]=consoletext[0][j+8];
3558 theIPAddress[consolechars[0]-8]='\0';
3560 sprintf( thePort, "%li", port );
3561 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3564 if(consolechars[0]>0){
3567 consoletext[k][j]=consoletext[k-1][j];
3569 consolechars[k]=consolechars[k-1];
3572 consoletext[0][j]=' ';
3574 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3575 else sprintf (consoletext[0], "Could not open connection");
3577 consolechars[0]=255;
3584 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3585 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3586 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3588 if(consolechars[0]>0){
3591 consoletext[k][j]=consoletext[k-1][j];
3593 consolechars[k]=consolechars[k-1];
3596 consoletext[0][j]=' ';
3598 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3600 consolechars[0]=255;
3606 if(Compare(consoletext[0],"host ",0,4)){
3607 unsigned char gameNameStr[32], playerNameStr[32];
3608 char gameName[32];//, playerName[32];
3616 strcpy(gameName, "Host's game");
3617 strcpy(playerName, "Host");
3618 GameC2PStr( gameName, gameNameStr );
3619 GameC2PStr( playerName, playerNameStr );
3621 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3624 if(consolechars[0]>0){
3627 consoletext[k][j]=consoletext[k-1][j];
3629 consolechars[k]=consolechars[k-1];
3632 consoletext[0][j]=' ';
3634 sprintf (consoletext[0], "Error #%d!!!",v);
3636 consolechars[0]=255;
3643 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3644 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3645 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3647 if(consolechars[0]>0){
3650 consoletext[k][j]=consoletext[k-1][j];
3652 consolechars[k]=consolechars[k-1];
3655 consoletext[0][j]=' ';
3657 sprintf (consoletext[0], "Game hosted");
3659 consolechars[0]=255;
3665 if(Compare(consoletext[0],"save ",0,4)){
3677 for(j=5;j<consolechars[0];j++){
3678 mapname[j-5+11]=consoletext[0][j];
3680 mapname[consolechars[0]-5+11]='\0';
3682 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
3683 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3684 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
3691 tfile=fopen( mapname, "wb" );
3692 fpackf(tfile, "Bi", mapvers);
3693 //fpackf(tfile, "Bi", indemo);
3694 fpackf(tfile, "Bi", maptype);
3695 fpackf(tfile, "Bi", hostile);
3696 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3697 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3698 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3699 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);
3700 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3701 for(j=0;j<player[0].num_weapons;j++){
3702 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3705 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3706 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3707 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3708 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3710 fpackf(tfile, "Bi", player[0].numclothes);
3712 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3714 fpackf(tfile, "Bi", numdialogues);
3716 for(k=0;k<numdialogues;k++){
3717 fpackf(tfile, "Bi", numdialogueboxes[k]);
3718 fpackf(tfile, "Bi", dialoguetype[k]);
3720 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3721 fpackf(tfile, "Bf", participantrotation[k][l]);
3723 if(numdialogueboxes)
3724 for(l=0;l<numdialogueboxes[k];l++){
3725 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3726 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3727 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3728 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3729 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3731 templength=strlen(dialoguetext[k][l]);
3732 fpackf(tfile, "Bi",(templength));
3733 for(m=0;m<templength;m++){
3734 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3735 if(dialoguetext[k][l][m]=='\0')break;
3738 templength=strlen(dialoguename[k][l]);
3739 fpackf(tfile, "Bi",templength);
3740 for(m=0;m<templength;m++){
3741 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3742 if(dialoguename[k][l][m]=='\0')break;
3745 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3746 fpackf(tfile, "Bi", participantfocus[k][l]);
3747 fpackf(tfile, "Bi", participantaction[k][l]);
3750 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3752 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3756 if(player[0].numclothes)
3757 for(k=0;k<player[0].numclothes;k++){
3758 templength=strlen(player[0].clothes[k]);
3759 fpackf(tfile, "Bi", templength);
3760 for(l=0;l<templength;l++)
3761 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3762 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3765 fpackf(tfile, "Bi", environment);
3767 fpackf(tfile, "Bi", objects.numobjects);
3769 if(objects.numobjects)
3770 for(k=0;k<objects.numobjects;k++){
3771 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]);
3774 fpackf(tfile, "Bi", numhotspots);
3776 for(i=0;i<numhotspots;i++){
3777 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3778 templength=strlen(hotspottext[i]);
3779 fpackf(tfile, "Bi",templength);
3780 for(l=0;l<templength;l++)
3781 fpackf(tfile, "Bb", hotspottext[i][l]);
3784 fpackf(tfile, "Bi", numplayers);
3785 if(numplayers>1&&numplayers<maxplayers)
3786 for(j=1;j<numplayers;j++){
3787 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);
3788 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3789 for(k=0;k<player[j].num_weapons;k++){
3790 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3792 if(player[j].numwaypoints<30){
3793 fpackf(tfile, "Bi", player[j].numwaypoints);
3794 for(k=0;k<player[j].numwaypoints;k++){
3795 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3796 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3797 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3798 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3800 fpackf(tfile, "Bi", player[j].waypoint);
3803 player[j].numwaypoints=0;
3804 player[j].waypoint=0;
3805 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3808 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3809 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3810 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3811 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3813 if(player[j].creature==wolftype){
3814 headprop=player[j].proportionhead.x/1.1;
3815 bodyprop=player[j].proportionbody.x/1.1;
3816 armprop=player[j].proportionarms.x/1.1;
3817 legprop=player[j].proportionlegs.x/1.1;
3820 if(player[j].creature==rabbittype){
3821 headprop=player[j].proportionhead.x/1.2;
3822 bodyprop=player[j].proportionbody.x/1.05;
3823 armprop=player[j].proportionarms.x/1.00;
3824 legprop=player[j].proportionlegs.x/1.1;
3827 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3831 fpackf(tfile, "Bi", player[j].numclothes);
3832 if(player[j].numclothes)
3833 for(k=0;k<player[j].numclothes;k++){
3835 templength=strlen(player[j].clothes[k]);
3836 fpackf(tfile, "Bi", templength);
3837 for(l=0;l<templength;l++)
3838 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3839 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3843 fpackf(tfile, "Bi", numpathpoints);
3845 for(j=0;j<numpathpoints;j++){
3846 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3847 for(k=0;k<numpathpointconnect[j];k++){
3848 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3852 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3860 tfile=fopen( mapname, "wb" );
3861 fwrite( &mapvers, 1, sizeof(int), tfile );
3862 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3863 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3864 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3865 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3866 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3867 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3868 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3869 for(j=0;j<player[0].num_weapons;j++){
3870 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3873 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3874 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3875 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3876 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3877 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3878 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3879 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3880 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3881 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3882 fwrite( &player[0].power, 1, sizeof(int), tfile );
3883 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3885 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3886 if(player[0].numclothes)
3887 for(k=0;k<player[0].numclothes;k++){
3889 templength=strlen(player[0].clothes[k]);
3890 fwrite( &templength,1,sizeof(int),tfile);
3891 for(l=0;l<templength;l++)
3892 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3893 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3894 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3895 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3898 fwrite( &environment, 1, sizeof(int), tfile );
3900 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3902 for(k=0;k<objects.numobjects;k++){
3903 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3904 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3905 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3906 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3907 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3908 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3909 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3912 fwrite( &numplayers, 1, sizeof(int), tfile );
3913 if(numplayers>1&&numplayers<maxplayers)
3914 for(j=1;j<numplayers;j++){
3915 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3916 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3917 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3918 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3919 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3920 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3921 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3922 for(k=0;k<player[j].num_weapons;k++){
3923 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3925 if(player[j].numwaypoints<30){
3926 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3927 for(k=0;k<player[j].numwaypoints;k++){
3928 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3929 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3930 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3932 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3933 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3936 player[j].numwaypoints=0;
3937 player[j].waypoint=0;
3938 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3939 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3940 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3942 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3943 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3944 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3945 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3946 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3947 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3948 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3949 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3950 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3951 fwrite( &player[j].power, 1, sizeof(int), tfile );
3952 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3954 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3955 if(player[j].numclothes)
3956 for(k=0;k<player[j].numclothes;k++){
3958 templength=strlen(player[j].clothes[k]);
3959 fwrite( &templength,1,sizeof(int),tfile);
3960 for(l=0;l<templength;l++)
3961 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3962 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3963 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3964 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3967 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3969 for(j=0;j<numpathpoints;j++){
3970 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3971 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3972 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3973 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3974 for(k=0;k<numpathpointconnect[j];k++){
3975 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3979 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3980 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3981 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3983 fwrite( &mapradius, 1, sizeof(float), tfile );
3989 if(Compare(consoletext[0],"save ",0,4)){
4001 for(j=5;j<consolechars[0];j++){
4002 mapname[j-5+11]=consoletext[0][j];
4004 mapname[consolechars[0]-5+11]='\0';
4006 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
4007 FSOUND_SetVolume(channels[consolesuccesssound], 256);
4008 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
4011 tfile=fopen( mapname, "wb" );
4012 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4013 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4014 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4015 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4016 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4017 for(j=0;j<player[0].num_weapons;j++){
4018 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4020 fwrite( &environment, 1, sizeof(int), tfile );
4022 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4023 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4024 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4025 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4026 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4028 fwrite( &numplayers, 1, sizeof(int), tfile );
4029 if(numplayers>1&&numplayers<maxplayers)
4030 for(j=1;j<numplayers;j++){
4031 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4032 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4033 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4034 for(k=0;k<player[j].num_weapons;k++){
4035 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4037 if(player[j].numwaypoints<30){
4038 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4039 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4040 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4041 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4044 player[j].numwaypoints=0;
4045 player[j].waypoint=0;
4046 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4047 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4048 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4051 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4053 for(j=0;j<numpathpoints;j++){
4054 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4055 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4056 for(k=0;k<numpathpointconnect[j];k++){
4057 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4063 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4064 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4067 /*if(Compare(consoletext[0],"Pants ",0,5)){
4068 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4069 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4073 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4074 for(j=6;j<consolechars[0];j++){
4075 mapname[j-6]=consoletext[0][j];
4078 tintr=atof(mapname);
4083 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4084 for(j=6;j<consolechars[0];j++){
4085 mapname[j-6]=consoletext[0][j];
4088 player[0].speedmult=atof(mapname);
4093 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4094 for(j=9;j<consolechars[0];j++){
4095 mapname[j-9]=consoletext[0][j];
4098 player[0].power=atof(mapname);
4103 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4104 for(j=13;j<consolechars[0];j++){
4105 mapname[j-13]=consoletext[0][j];
4108 viewdistance=atof(mapname)*100;
4113 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4114 for(j=10;j<consolechars[0];j++){
4115 mapname[j-10]=consoletext[0][j];
4118 fadestart=atof(mapname);
4123 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4124 for(j=6;j<consolechars[0];j++){
4125 mapname[j-6]=consoletext[0][j];
4128 player[0].power=atof(mapname);
4133 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4134 for(j=6;j<consolechars[0];j++){
4135 mapname[j-6]=consoletext[0][j];
4138 slomospeed=atof(mapname);
4145 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4146 for(j=8;j<consolechars[0];j++){
4147 mapname[j-8]=consoletext[0][j];
4150 slomofreq=atoi(mapname);
4155 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4156 for(j=5;j<consolechars[0];j++){
4157 mapname[j-5]=consoletext[0][j];
4160 player[0].scale=atof(mapname)*.2;
4165 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4167 float closestdist=-1;
4170 for(i=1;i<numplayers;i++){
4171 distance=findDistancefast(&player[i].coords,&player[0].coords);
4172 if(closestdist==-1||distance<closestdist){
4173 closestdist=distance;
4178 for(j=9;j<consolechars[0];j++){
4179 mapname[j-9]=consoletext[0][j];
4182 player[closest].scale=atof(mapname)*.2;
4187 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4192 float closestdist=-1;
4195 for(i=1;i<numplayers;i++){
4196 distance=findDistancefast(&player[i].coords,&player[0].coords);
4197 if(closestdist==-1||distance<closestdist){
4198 closestdist=distance;
4206 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4207 mapname[j-startpoint]=consoletext[0][j];
4209 if(consoletext[0][j]=='\0')alldone=1;
4211 mapname[j-startpoint]='\0';
4213 headprop=atof(mapname);
4217 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4218 mapname[j-startpoint]=consoletext[0][j];
4220 if(consoletext[0][j]=='\0')alldone=1;
4222 mapname[j-startpoint]='\0';
4224 bodyprop=atof(mapname);
4228 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4229 mapname[j-startpoint]=consoletext[0][j];
4231 if(consoletext[0][j]=='\0')alldone=1;
4233 mapname[j-startpoint]='\0';
4235 armprop=atof(mapname);
4239 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4240 mapname[j-startpoint]=consoletext[0][j];
4242 if(consoletext[0][j]=='\0')alldone=1;
4244 mapname[j-startpoint]='\0';
4246 legprop=atof(mapname);
4248 if(player[closest].creature==wolftype){
4249 player[closest].proportionhead=1.1*headprop;
4250 player[closest].proportionbody=1.1*bodyprop;
4251 player[closest].proportionarms=1.1*armprop;
4252 player[closest].proportionlegs=1.1*legprop;
4255 if(player[closest].creature==rabbittype){
4256 player[closest].proportionhead=1.2*headprop;
4257 player[closest].proportionbody=1.05*bodyprop;
4258 player[closest].proportionarms=1.00*armprop;
4259 player[closest].proportionlegs=1.1*legprop;
4260 player[closest].proportionlegs.y=1.05*legprop;
4267 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4268 for(i=1;i<numplayers;i++){
4269 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4275 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4276 for(j=9;j<consolechars[0];j++){
4277 mapname[j-9]=consoletext[0][j];
4280 tutoriallevel=atoi(mapname);
4286 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4287 for(j=6;j<consolechars[0];j++){
4288 mapname[j-6]=consoletext[0][j];
4291 tintg=atof(mapname);
4296 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4297 for(j=6;j<consolechars[0];j++){
4298 mapname[j-6]=consoletext[0][j];
4301 tintb=atof(mapname);
4306 if(Compare(consoletext[0],"hostile ",0,7)){
4307 for(j=8;j<consolechars[0];j++){
4308 mapname[j-8]=consoletext[0][j];
4311 hostile=atoi(mapname);
4317 if(Compare(consoletext[0],"type active ",0,11)){
4318 editoractive=typeactive;
4323 if(Compare(consoletext[0],"indemo ",0,6)){
4325 hotspot[numhotspots]=player[0].coords;
4326 hotspotsize[numhotspots]=0;
4327 hotspottype[numhotspots]=-111;
4329 strcpy(hotspottext[numhotspots],"mapname");
4335 if(Compare(consoletext[0],"notindemo ",0,9)){
4342 if(Compare(consoletext[0],"type sitting ",0,12)){
4343 editoractive=typesitting;
4348 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4349 editoractive=typesittingwall;
4354 if(Compare(consoletext[0],"type sleeping ",0,13)){
4355 editoractive=typesleeping;
4359 if(Compare(consoletext[0],"type dead1 ",0,10)){
4360 editoractive=typedead1;
4364 if(Compare(consoletext[0],"type dead2 ",0,10)){
4365 editoractive=typedead2;
4369 if(Compare(consoletext[0],"type dead3 ",0,10)){
4370 editoractive=typedead3;
4373 if(Compare(consoletext[0],"type dead4 ",0,10)){
4374 editoractive=typedead4;
4379 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4380 editorpathtype=wpkeepwalking;
4385 if(Compare(consoletext[0],"path pause ",0,10)){
4386 editorpathtype=wppause;
4391 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4392 maptype=mapkilleveryone;
4397 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4398 maptype=mapgosomewhere;
4403 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4404 maptype=mapkillsomeone;
4410 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4411 maptype=mapkillmost;
4417 if(Compare(consoletext[0],"hs ",0,2)){
4421 hotspot[numhotspots]=player[0].coords;
4426 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4427 mapname[j-startpoint]=consoletext[0][j];
4429 if(consoletext[0][j]=='\0')alldone=1;
4431 mapname[j-startpoint]='\0';
4433 hotspotsize[numhotspots]=atof(mapname);
4437 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4438 mapname[j-startpoint]=consoletext[0][j];
4440 if(consoletext[0][j]=='\0')alldone=1;
4442 mapname[j-startpoint]='\0';
4444 hotspottype[numhotspots]=atoi(mapname);
4448 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4449 mapname[j-startpoint]=consoletext[0][j];
4451 if(consoletext[0][j]=='\0')alldone=1;
4453 mapname[j-startpoint]='\n';
4454 mapname[j-startpoint+1]='\0';
4456 strcpy(hotspottext[numhotspots],mapname);
4463 if(Compare(consoletext[0],"dialogue ",0,8)){
4470 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4471 mapname[j-startpoint]=consoletext[0][j];
4473 if(consoletext[0][j]=='\0')alldone=1;
4475 mapname[j-startpoint]='\0';
4478 dialoguetype[numdialogues]=atoi(mapname);
4496 for(j=startpoint;j<consolechars[0];j++){
4497 mapname[j-startpoint+16]=consoletext[0][j];
4499 mapname[consolechars[0]-startpoint+16]='.';
4500 mapname[consolechars[0]-startpoint+17]='t';
4501 mapname[consolechars[0]-startpoint+18]='x';
4502 mapname[consolechars[0]-startpoint+19]='t';
4503 mapname[consolechars[0]-startpoint+20]='\0';
4505 for(j=0;j<max_dialoguelength;j++){
4507 dialoguetext[numdialogues][j][k]='\0';
4510 dialoguename[numdialogues][j][k]='\0';
4514 ifstream ipstream(mapname);
4515 ipstream.ignore(256,':');
4516 ipstream >> numdialogueboxes[numdialogues];
4517 for(i=0;i<numdialogueboxes[numdialogues];i++){
4518 ipstream.ignore(256,':');
4519 ipstream.ignore(256,':');
4520 ipstream.ignore(256,' ');
4521 ipstream >> dialogueboxlocation[numdialogues][i];
4522 ipstream.ignore(256,':');
4523 ipstream >> dialogueboxcolor[numdialogues][i][0];
4524 ipstream >> dialogueboxcolor[numdialogues][i][1];
4525 ipstream >> dialogueboxcolor[numdialogues][i][2];
4526 ipstream.ignore(256,':');
4527 ipstream.getline(dialoguename[numdialogues][i],64);
4528 ipstream.ignore(256,':');
4529 ipstream.ignore(256,' ');
4530 ipstream.getline(dialoguetext[numdialogues][i],128);
4532 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4534 ipstream.ignore(256,':');
4535 ipstream >> dialogueboxsound[numdialogues][i];
4538 for(i=0;i<numdialogueboxes[numdialogues];i++){
4539 for(j=0;j<numplayers;j++){
4540 participantfacing[numdialogues][i][j]=player[j].facing;
4547 whichdialogue=numdialogues;
4555 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4563 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4564 mapname[j-startpoint]=consoletext[0][j];
4566 if(consoletext[0][j]=='\0')alldone=1;
4568 mapname[j-startpoint]='\0';
4571 whichdi=atoi(mapname);
4589 for(j=startpoint;j<consolechars[0];j++){
4590 mapname[j-startpoint+16]=consoletext[0][j];
4592 mapname[consolechars[0]-startpoint+16]='.';
4593 mapname[consolechars[0]-startpoint+17]='t';
4594 mapname[consolechars[0]-startpoint+18]='x';
4595 mapname[consolechars[0]-startpoint+19]='t';
4596 mapname[consolechars[0]-startpoint+20]='\0';
4598 for(j=0;j<max_dialoguelength;j++){
4600 dialoguetext[whichdi][j][k]='\0';
4603 dialoguename[whichdi][j][k]='\0';
4607 ifstream ipstream(mapname);
4608 ipstream.ignore(256,':');
4609 ipstream >> numdialogueboxes[whichdi];
4610 for(i=0;i<numdialogueboxes[whichdi];i++){
4611 ipstream.ignore(256,':');
4612 ipstream.ignore(256,':');
4613 ipstream.ignore(256,' ');
4614 ipstream >> dialogueboxlocation[whichdi][i];
4615 ipstream.ignore(256,':');
4616 ipstream >> dialogueboxcolor[whichdi][i][0];
4617 ipstream >> dialogueboxcolor[whichdi][i][1];
4618 ipstream >> dialogueboxcolor[whichdi][i][2];
4619 ipstream.ignore(256,':');
4620 ipstream.getline(dialoguename[whichdi][i],64);
4621 ipstream.ignore(256,':');
4622 ipstream.ignore(256,' ');
4623 ipstream.getline(dialoguetext[whichdi][i],128);
4625 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4627 ipstream.ignore(256,':');
4628 ipstream >> dialogueboxsound[whichdi][i];
4636 if(Compare(consoletext[0],"fixtype ",0,7)){
4644 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4645 mapname[j-startpoint]=consoletext[0][j];
4647 if(consoletext[0][j]=='\0')alldone=1;
4649 mapname[j-startpoint]='\0';
4650 dialoguetype[0]=atoi(mapname);
4658 if(Compare(consoletext[0],"fixrotation ",0,11)){
4659 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4664 if(Compare(consoletext[0],"ddialogue ",0,9)){
4666 if(numdialogues<0)numdialogues=0;
4671 if(Compare(consoletext[0],"immobile ",0,8)){
4672 player[0].immobile=1;
4676 if(Compare(consoletext[0],"mobile ",0,6)){
4677 player[0].immobile=0;
4681 if(Compare(consoletext[0],"play ",0,4)){
4688 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4689 mapname[j-startpoint]=consoletext[0][j];
4691 if(consoletext[0][j]=='\0')alldone=1;
4693 mapname[j-startpoint]='\0';
4696 whichdialogue=atoi(mapname);
4698 if(numdialogues>whichdialogue){
4699 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4700 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4701 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4702 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4703 player[participantfocus[whichdialogue][i]].velocity=0;
4704 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4705 player[participantfocus[whichdialogue][i]].targetframe=0;
4713 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4717 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4718 temppos=temppos-viewer;
4719 Normalise(&temppos);
4729 whichsoundplay=rabbitchitter;
4730 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4731 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4732 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4733 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4734 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4735 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4736 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4737 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4738 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4739 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4740 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4741 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4742 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4743 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4744 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4745 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4746 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4747 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4748 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4749 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
4750 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4751 FSOUND_SetVolume(channels[whichsoundplay], 256);
4752 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
4760 if(Compare(consoletext[0],"dhs ",0,3)){
4762 if(numhotspots<0)numhotspots=0;
4767 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4774 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4775 mapname[j-startpoint]=consoletext[0][j];
4777 if(consoletext[0][j]=='\0')alldone=1;
4779 mapname[j-startpoint]='\0';
4781 headprop=atof(mapname);
4785 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4786 mapname[j-startpoint]=consoletext[0][j];
4788 if(consoletext[0][j]=='\0')alldone=1;
4790 mapname[j-startpoint]='\0';
4792 bodyprop=atof(mapname);
4796 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4797 mapname[j-startpoint]=consoletext[0][j];
4799 if(consoletext[0][j]=='\0')alldone=1;
4801 mapname[j-startpoint]='\0';
4803 armprop=atof(mapname);
4807 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4808 mapname[j-startpoint]=consoletext[0][j];
4810 if(consoletext[0][j]=='\0')alldone=1;
4812 mapname[j-startpoint]='\0';
4814 legprop=atof(mapname);
4816 if(player[0].creature==wolftype){
4817 player[0].proportionhead=1.1*headprop;
4818 player[0].proportionbody=1.1*bodyprop;
4819 player[0].proportionarms=1.1*armprop;
4820 player[0].proportionlegs=1.1*legprop;
4823 if(player[0].creature==rabbittype){
4824 player[0].proportionhead=1.2*headprop;
4825 player[0].proportionbody=1.05*bodyprop;
4826 player[0].proportionarms=1.00*armprop;
4827 player[0].proportionlegs=1.1*legprop;
4828 player[0].proportionlegs.y=1.05*legprop;
4834 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4835 for(i=0;i<numplayers;i++){
4836 if(i>0)player[i].immobile=1;
4842 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4843 player[0].armorhead=1;
4844 player[0].armorhigh=1;
4845 player[0].armorlow=1;
4846 player[0].protectionhead=1;
4847 player[0].protectionhigh=1;
4848 player[0].protectionlow=1;
4849 player[0].metalhead=1;
4850 player[0].metalhigh=1;
4851 player[0].metallow=1;
4853 player[0].speedmult=1;
4856 if(player[0].creature==wolftype){
4857 player[0].proportionhead=1.1;
4858 player[0].proportionbody=1.1;
4859 player[0].proportionarms=1.1;
4860 player[0].proportionlegs=1.1;
4863 if(player[0].creature==rabbittype){
4864 player[0].proportionhead=1.2;
4865 player[0].proportionbody=1.05;
4866 player[0].proportionarms=1.00;
4867 player[0].proportionlegs=1.1;
4868 player[0].proportionlegs.y=1.05;
4871 player[0].numclothes=0;
4872 if(player[0].whichskin==0){
4873 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4875 else if(player[0].whichskin==1){
4876 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4878 else if(player[0].whichskin==2){
4879 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4881 else if(player[0].whichskin==3){
4882 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4884 else if(player[0].whichskin==4){
4885 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4887 else if(player[0].whichskin==5){
4888 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4890 else if(player[0].whichskin==6){
4891 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4893 else if(player[0].whichskin==7){
4894 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4896 else if(player[0].whichskin==8){
4897 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4899 else if(player[0].whichskin==9){
4900 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4903 editoractive=typeactive;
4904 player[0].immobile=0;
4911 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4917 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4918 mapname[j-startpoint]=consoletext[0][j];
4920 if(consoletext[0][j]=='\0')alldone=1;
4922 mapname[j-startpoint]='\0';
4924 tintr=atof(mapname);
4928 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4929 mapname[j-startpoint]=consoletext[0][j];
4931 if(consoletext[0][j]=='\0')alldone=1;
4933 mapname[j-startpoint]='\0';
4935 tintg=atof(mapname);
4939 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4940 mapname[j-startpoint]=consoletext[0][j];
4942 if(consoletext[0][j]=='\0')alldone=1;
4944 mapname[j-startpoint]='\0';
4946 tintb=atof(mapname);
4951 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4957 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4958 mapname[j-startpoint]=consoletext[0][j];
4960 if(consoletext[0][j]=='\0')alldone=1;
4962 mapname[j-startpoint]='\0';
4964 skyboxr=atof(mapname);
4968 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4969 mapname[j-startpoint]=consoletext[0][j];
4971 if(consoletext[0][j]=='\0')alldone=1;
4973 mapname[j-startpoint]='\0';
4975 skyboxg=atof(mapname);
4979 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4980 mapname[j-startpoint]=consoletext[0][j];
4982 if(consoletext[0][j]=='\0')alldone=1;
4984 mapname[j-startpoint]='\0';
4986 skyboxb=atof(mapname);
4988 skyboxlightr=skyboxr;
4989 skyboxlightg=skyboxg;
4990 skyboxlightb=skyboxb;
4994 //if(skyboxtexture){
4995 terrain.DoShadows();
4996 objects.DoShadows();
4998 else terrain.DoLighting();
5003 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5009 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5010 mapname[j-startpoint]=consoletext[0][j];
5012 if(consoletext[0][j]=='\0')alldone=1;
5014 mapname[j-startpoint]='\0';
5016 skyboxlightr=atof(mapname);
5020 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5021 mapname[j-startpoint]=consoletext[0][j];
5023 if(consoletext[0][j]=='\0')alldone=1;
5025 mapname[j-startpoint]='\0';
5027 skyboxlightg=atof(mapname);
5031 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5032 mapname[j-startpoint]=consoletext[0][j];
5034 if(consoletext[0][j]=='\0')alldone=1;
5036 mapname[j-startpoint]='\0';
5038 skyboxlightb=atof(mapname);
5042 //if(skyboxtexture){
5043 terrain.DoShadows();
5044 objects.DoShadows();
5046 else terrain.DoLighting();
5051 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5052 skyboxtexture=1-skyboxtexture;
5055 //if(skyboxtexture){
5056 terrain.DoShadows();
5057 objects.DoShadows();
5059 else terrain.DoLighting();
5064 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
5070 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5071 mapname[j-startpoint]=consoletext[0][j];
5073 if(consoletext[0][j]=='\0')alldone=1;
5075 mapname[j-startpoint]='\0';
5077 player[0].protectionhead=atof(mapname);
5081 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5082 mapname[j-startpoint]=consoletext[0][j];
5084 if(consoletext[0][j]=='\0')alldone=1;
5086 mapname[j-startpoint]='\0';
5088 player[0].protectionhigh=atof(mapname);
5092 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5093 mapname[j-startpoint]=consoletext[0][j];
5095 if(consoletext[0][j]=='\0')alldone=1;
5097 mapname[j-startpoint]='\0';
5099 player[0].protectionlow=atof(mapname);
5104 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5110 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5111 mapname[j-startpoint]=consoletext[0][j];
5113 if(consoletext[0][j]=='\0')alldone=1;
5115 mapname[j-startpoint]='\0';
5117 player[0].armorhead=atof(mapname);
5121 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5122 mapname[j-startpoint]=consoletext[0][j];
5124 if(consoletext[0][j]=='\0')alldone=1;
5126 mapname[j-startpoint]='\0';
5128 player[0].armorhigh=atof(mapname);
5132 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5133 mapname[j-startpoint]=consoletext[0][j];
5135 if(consoletext[0][j]=='\0')alldone=1;
5137 mapname[j-startpoint]='\0';
5139 player[0].armorlow=atof(mapname);
5144 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5145 for(i=0;i<numplayers;i++){
5146 player[i].protectionhead=1.0;
5147 player[i].protectionhigh=1.0;
5148 player[i].protectionlow=1.0;
5149 player[i].armorhead=1.0;
5150 player[i].armorhigh=1.0;
5151 player[i].armorlow=1.0;
5157 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5159 float closestdist=-1;
5162 for(i=1;i<numplayers;i++){
5163 distance=findDistancefast(&player[i].coords,&player[0].coords);
5164 if(closestdist==-1||distance<closestdist){
5165 closestdist=distance;
5175 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5176 mapname[j-startpoint]=consoletext[0][j];
5178 if(consoletext[0][j]=='\0')alldone=1;
5180 mapname[j-startpoint]='\0';
5182 player[closest].protectionhead=atof(mapname);
5186 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5187 mapname[j-startpoint]=consoletext[0][j];
5189 if(consoletext[0][j]=='\0')alldone=1;
5191 mapname[j-startpoint]='\0';
5193 player[closest].protectionhigh=atof(mapname);
5197 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5198 mapname[j-startpoint]=consoletext[0][j];
5200 if(consoletext[0][j]=='\0')alldone=1;
5202 mapname[j-startpoint]='\0';
5204 player[closest].protectionlow=atof(mapname);
5209 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5211 float closestdist=-1;
5214 for(i=1;i<numplayers;i++){
5215 distance=findDistancefast(&player[i].coords,&player[0].coords);
5216 if(closestdist==-1||distance<closestdist){
5217 closestdist=distance;
5226 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5227 mapname[j-startpoint]=consoletext[0][j];
5229 if(consoletext[0][j]=='\0')alldone=1;
5231 mapname[j-startpoint]='\0';
5233 player[closest].armorhead=atof(mapname);
5237 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5238 mapname[j-startpoint]=consoletext[0][j];
5240 if(consoletext[0][j]=='\0')alldone=1;
5242 mapname[j-startpoint]='\0';
5244 player[closest].armorhigh=atof(mapname);
5248 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5249 mapname[j-startpoint]=consoletext[0][j];
5251 if(consoletext[0][j]=='\0')alldone=1;
5253 mapname[j-startpoint]='\0';
5255 player[closest].armorlow=atof(mapname);
5261 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5267 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5268 mapname[j-startpoint]=consoletext[0][j];
5270 if(consoletext[0][j]=='\0')alldone=1;
5272 mapname[j-startpoint]='\0';
5274 player[0].metalhead=atof(mapname);
5278 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5279 mapname[j-startpoint]=consoletext[0][j];
5281 if(consoletext[0][j]=='\0')alldone=1;
5283 mapname[j-startpoint]='\0';
5285 player[0].metalhigh=atof(mapname);
5289 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5290 mapname[j-startpoint]=consoletext[0][j];
5292 if(consoletext[0][j]=='\0')alldone=1;
5295 mapname[j-startpoint]='\0';
5297 player[0].metallow=atof(mapname);
5302 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5304 float closestdist=-1;
5307 for(i=1;i<numplayers;i++){
5308 distance=findDistancefast(&player[i].coords,&player[0].coords);
5309 if(closestdist==-1||distance<closestdist){
5310 closestdist=distance;
5314 player[closest].numclothes=0;
5315 if(player[closest].whichskin==0){
5316 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5318 else if(player[closest].whichskin==1){
5319 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5321 else if(player[closest].whichskin==2){
5322 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5324 else if(player[closest].whichskin==3){
5325 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5327 else if(player[closest].whichskin==4){
5328 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5330 else if(player[closest].whichskin==5){
5331 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5333 else if(player[closest].whichskin==6){
5334 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5336 else if(player[closest].whichskin==7){
5337 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5339 else if(player[closest].whichskin==8){
5340 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5342 else if(player[closest].whichskin==9){
5343 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5349 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5352 player[closest].numclothes=0;
5353 if(player[closest].whichskin==0){
5354 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5356 else if(player[closest].whichskin==1){
5357 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5359 else if(player[closest].whichskin==2){
5360 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5362 else if(player[closest].whichskin==3){
5363 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5365 else if(player[closest].whichskin==4){
5366 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5368 else if(player[closest].whichskin==5){
5369 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5371 else if(player[closest].whichskin==6){
5372 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5374 else if(player[closest].whichskin==7){
5375 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5377 else if(player[closest].whichskin==8){
5378 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5380 else if(player[closest].whichskin==9){
5381 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5387 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5403 for(j=8;j<consolechars[0];j++){
5404 mapname[j-8+15]=consoletext[0][j];
5406 mapname[consolechars[0]-8+15]='.';
5407 mapname[consolechars[0]-8+16]='p';
5408 mapname[consolechars[0]-8+17]='n';
5409 mapname[consolechars[0]-8+18]='g';
5410 mapname[consolechars[0]-8+19]='\0';
5412 //:Data:Textures:Pants.png
5414 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5415 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5416 strcpy(player[0].clothes[player[0].numclothes],mapname);
5417 player[0].clothestintr[player[0].numclothes]=tintr;
5418 player[0].clothestintg[player[0].numclothes]=tintg;
5419 player[0].clothestintb[player[0].numclothes]=tintb;
5420 player[0].numclothes++;
5426 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5427 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5432 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5433 cellophane=1-cellophane;
5436 for(i=0;i<numplayers;i++){
5437 player[i].proportionhead.z=0;
5438 player[i].proportionbody.z=0;
5439 player[i].proportionarms.z=0;
5440 player[i].proportionlegs.z=0;
5445 for(i=0;i<numplayers;i++){
5446 player[i].proportionhead.z=player[i].proportionhead.x;
5447 player[i].proportionbody.z=player[i].proportionbody.x;
5448 player[i].proportionarms.z=player[i].proportionarms.x;
5449 player[i].proportionlegs.z=player[i].proportionlegs.x;
5456 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5472 for(j=12;j<consolechars[0];j++){
5473 mapname[j-12+15]=consoletext[0][j];
5475 mapname[consolechars[0]-12+15]='.';
5476 mapname[consolechars[0]-12+16]='p';
5477 mapname[consolechars[0]-12+17]='n';
5478 mapname[consolechars[0]-12+18]='g';
5479 mapname[consolechars[0]-12+19]='\0';
5481 //:Data:Textures:Pants.png
5483 float closestdist=-1;
5486 for(i=1;i<numplayers;i++){
5487 distance=findDistancefast(&player[i].coords,&player[0].coords);
5488 if(closestdist==-1||distance<closestdist){
5489 closestdist=distance;
5494 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5495 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5496 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5497 player[closest].clothestintr[player[closest].numclothes]=tintr;
5498 player[closest].clothestintg[player[closest].numclothes]=tintg;
5499 player[closest].clothestintb[player[closest].numclothes]=tintb;
5500 player[closest].numclothes++;
5506 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5507 player[0].skeleton.id=0;
5508 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);
5509 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5510 player[0].creature=rabbittype;
5513 player[0].proportionhead=1.2;
5514 player[0].proportionbody=1.05;
5515 player[0].proportionarms=1.00;
5516 player[0].proportionlegs=1.1;
5517 player[0].proportionlegs.y=1.05;
5518 player[0].headless=0;
5520 player[0].damagetolerance=200;
5524 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5525 player[0].skeleton.id=0;
5526 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);
5527 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5528 player[0].creature=wolftype;
5530 player[0].proportionhead=1.1;
5531 player[0].proportionbody=1.1;
5532 player[0].proportionarms=1.1;
5533 player[0].proportionlegs=1.1;
5534 player[0].proportionlegs.y=1.1;
5535 player[0].scale=.23;
5537 player[0].damagetolerance=300;
5541 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5542 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5545 if(Compare(consoletext[0],"rambo ",0,5)){
5546 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5549 if(Compare(consoletext[0],"david ",0,5)){
5550 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5553 if(Compare(consoletext[0],"wolf ",0,4)){
5554 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5557 if(Compare(consoletext[0],"darkwolf ",0,8)){
5558 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5561 if(Compare(consoletext[0],"snowwolf ",0,8)){
5562 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5565 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5566 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5569 if(Compare(consoletext[0],"white ",0,5)){
5570 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5573 if(Compare(consoletext[0],"brown ",0,5)){
5574 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5577 if(Compare(consoletext[0],"black ",0,5)){
5578 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5581 if(consolechars[0]>0){
5584 consoletext[k][j]=consoletext[k-1][j];
5586 consolechars[k]=consolechars[k-1];
5589 consoletext[0][j]=' ';
5595 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, TRUE);
5596 FSOUND_SetVolume(channels[consolefailsound], 256);
5597 FSOUND_SetPaused(channels[consolefailsound], FALSE);
5606 togglekeydelay[i]=0;
5610 consoleblinkdelay-=multiplier;
5611 if(consoleblinkdelay<=0){
5612 consoleblinkdelay=.3;
5613 consoleblink=1-consoleblink;
5617 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5620 if(newdetail>2)newdetail=detail;
5621 if(newdetail<0)newdetail=detail;
5622 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5623 if(newscreenwidth<0)newscreenwidth=screenwidth;
5624 if(newscreenheight>3000)newscreenheight=screenheight;
5625 if(newscreenheight<0)newscreenheight=screenheight;
5627 //ofstream opstream(":Data:config.txt");
5628 ofstream opstream("./Data/config.txt");
5629 opstream << "Screenwidth:\n";
5630 opstream << newscreenwidth;
5631 opstream << "\nScreenheight:\n";
5632 opstream << newscreenheight;
5633 opstream << "\nMouse sensitivity:\n";
5634 opstream << usermousesensitivity;
5635 opstream << "\nBlur(0,1):\n";
5636 opstream << ismotionblur;
5637 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5638 opstream << newdetail;
5639 opstream << "\nFloating jump:\n";
5640 opstream << floatjump;
5641 opstream << "\nMouse jump:\n";
5642 opstream << mousejump;
5643 opstream << "\nAmbient sound:\n";
5644 opstream << ambientsound;
5645 opstream << "\nBlood (0,1,2):\n";
5646 opstream << bloodtoggle;
5647 opstream << "\nAuto slomo:\n";
5648 opstream << autoslomo;
5649 opstream << "\nFoliage:\n";
5650 opstream << foliage;
5651 opstream << "\nMusic:\n";
5652 opstream << musictoggle;
5653 opstream << "\nTrilinear:\n";
5654 opstream << trilinear;
5655 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5657 opstream << "\nInvert mouse:\n";
5658 opstream << invertmouse;
5659 opstream << "\nGamespeed:\n";
5660 if(oldgamespeed==0)oldgamespeed=1;
5661 opstream << oldgamespeed;
5662 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5663 opstream << difficulty;
5664 opstream << "\nDamage effects(blackout, doublevision):\n";
5665 opstream << damageeffects;
5666 opstream << "\nText:\n";
5667 opstream << texttoggle;
5668 opstream << "\nDebug:\n";
5669 opstream << debugmode;
5670 opstream << "\nVBL Sync:\n";
5671 opstream << vblsync;
5672 opstream << "\nShow Points:\n";
5673 opstream << showpoints;
5674 opstream << "\nAlways Blur:\n";
5675 opstream << alwaysblur;
5676 opstream << "\nImmediate mode (turn on on G5):\n";
5677 opstream << immediate;
5678 opstream << "\nVelocity blur:\n";
5679 opstream << velocityblur;
5680 opstream << "\nVolume:\n";
5682 opstream << "\nForward key:\n";
5683 opstream << KeyToChar(forwardkey);
5684 opstream << "\nBack key:\n";
5685 opstream << KeyToChar(backkey);
5686 opstream << "\nLeft key:\n";
5687 opstream << KeyToChar(leftkey);
5688 opstream << "\nRight key:\n";
5689 opstream << KeyToChar(rightkey);
5690 opstream << "\nJump key:\n";
5691 opstream << KeyToChar(jumpkey);
5692 opstream << "\nCrouch key:\n";
5693 opstream << KeyToChar(crouchkey);
5694 opstream << "\nDraw key:\n";
5695 opstream << KeyToChar(drawkey);
5696 opstream << "\nThrow key:\n";
5697 opstream << KeyToChar(throwkey);
5698 opstream << "\nAttack key:\n";
5699 opstream << KeyToChar(attackkey);
5700 opstream << "\nChat key:\n";
5701 opstream << KeyToChar(chatkey);
5706 static int oldwinfreeze;
5707 if(winfreeze&&!oldwinfreeze){
5708 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
5709 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
5710 FSOUND_SetVolume(channels[consolesuccesssound], 256);
5711 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
5713 if(winfreeze==0)oldwinfreeze=winfreeze;
5714 else oldwinfreeze++;
5716 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5717 if(winfreeze)winfreeze=0;
5720 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5726 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5729 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5731 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5733 static bool oldbuttondialogue;
5735 if(indialogue!=-1)talkdelay=1;
5736 talkdelay-=multiplier;
5739 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5740 for(i=0;i<numdialogues;i++){
5741 int realdialoguetype;
5743 if(dialoguetype[i]>49){
5744 realdialoguetype=dialoguetype[i]-50;
5747 else if(dialoguetype[i]>39){
5748 realdialoguetype=dialoguetype[i]-40;
5751 else if(dialoguetype[i]>29){
5752 realdialoguetype=dialoguetype[i]-30;
5755 else if(dialoguetype[i]>19){
5756 realdialoguetype=dialoguetype[i]-20;
5759 else if(dialoguetype[i]>9){
5760 realdialoguetype=dialoguetype[i]-10;
5764 realdialoguetype=dialoguetype[i];
5767 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5768 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5770 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5771 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5772 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5773 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5774 player[participantfocus[whichdialogue][j]].velocity=0;
5775 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5776 player[participantfocus[whichdialogue][j]].targetframe=0;
5781 dialoguegonethrough[i]++;
5782 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5783 static float gLoc[3];
5784 static float vel[3];
5786 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5787 temppos=temppos-viewer;
5788 Normalise(&temppos);
5793 gLoc[2]=temppos.z;vel[0]=0;
5797 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5798 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5799 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5800 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5801 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5802 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5803 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5804 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5805 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5806 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5807 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5808 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5809 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5810 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5811 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5812 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5813 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5814 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5815 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5816 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5817 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
5818 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5819 FSOUND_SetVolume(channels[whichsoundplay], 256);
5820 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
5822 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5827 windvar+=multiplier;
5828 smoketex+=multiplier;
5829 tutorialstagetime+=multiplier;
5831 static float hotspotvisual[40];
5835 for(i=0;i<numhotspots;i++)
5836 hotspotvisual[i]-=multiplier/320;
5838 for(i=0;i<numhotspots;i++){
5839 //if(hotspottype[i]<=10)
5840 while(hotspotvisual[i]<0){
5842 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5843 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5844 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5845 hotspotsprite+=hotspot[i];
5846 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5847 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5851 for(i=0;i<numhotspots;i++){
5852 if(hotspottype[i]<=10&&hotspottype[i]>0){
5853 hotspot[i]=player[hotspottype[i]].coords;
5859 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5862 if(tutorialstage<=1){
5867 if(tutorialstage==1){
5870 if(tutorialstage==2){
5873 if(tutorialstage==3){
5874 tutorialmaxtime=600;
5876 if(tutorialstage==4){
5877 tutorialmaxtime=1000;
5879 if(tutorialstage==5){
5880 tutorialmaxtime=600;
5882 if(tutorialstage==6){
5883 tutorialmaxtime=600;
5885 if(tutorialstage==7){
5886 tutorialmaxtime=600;
5888 if(tutorialstage==8){
5889 tutorialmaxtime=600;
5891 if(tutorialstage==9){
5892 tutorialmaxtime=600;
5894 if(tutorialstage==10){
5897 if(tutorialstage==11){
5898 tutorialmaxtime=1000;
5900 if(tutorialstage==12){
5901 tutorialmaxtime=1000;
5903 if(tutorialstage==13){
5906 if(tutorialstage==14){
5918 player[1].coords=(temp+temp2)/2;
5922 gLoc[0]=player[1].coords.x;
5923 gLoc[1]=player[1].coords.y;
5924 gLoc[2]=player[1].coords.z;
5928 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
5929 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5930 FSOUND_SetVolume(channels[fireendsound], 256);
5931 FSOUND_SetPaused(channels[fireendsound], FALSE);
5933 for(i=0;i<player[1].skeleton.num_joints;i++){
5935 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5936 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5937 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;
5938 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5939 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5944 if(tutorialstage==15){
5945 tutorialmaxtime=500;
5947 if(tutorialstage==16){
5948 tutorialmaxtime=500;
5950 if(tutorialstage==17){
5951 tutorialmaxtime=500;
5953 if(tutorialstage==18){
5954 tutorialmaxtime=500;
5956 if(tutorialstage==19){
5958 //tutorialmaxtime=500;
5960 if(tutorialstage==20){
5961 tutorialmaxtime=500;
5963 if(tutorialstage==21){
5964 tutorialmaxtime=500;
5971 if(tutorialstage==22){
5972 tutorialmaxtime=500;
5974 if(tutorialstage==23){
5975 tutorialmaxtime=500;
5977 if(tutorialstage==24){
5978 tutorialmaxtime=500;
5980 if(tutorialstage==25){
5981 tutorialmaxtime=500;
5983 if(tutorialstage==26){
5986 if(tutorialstage==27){
5990 player[1].aitype=attacktypecutoff;
5992 if(tutorialstage==28){
5993 tutorialmaxtime=400;
5995 if(tutorialstage==29){
5996 tutorialmaxtime=400;
5997 player[0].escapednum=0;
5999 if(tutorialstage==30){
6003 player[1].aitype=passivetype;
6005 if(tutorialstage==31){
6008 if(tutorialstage==32){
6011 if(tutorialstage==33){
6012 tutorialmaxtime=400;
6015 player[1].aitype=attacktypecutoff;
6017 if(tutorialstage==34){
6018 tutorialmaxtime=400;
6020 if(tutorialstage==35){
6021 tutorialmaxtime=400;
6023 if(tutorialstage==36){
6027 player[1].aitype=passivetype;
6029 if(tutorialstage==37){
6035 player[1].aitype=attacktypecutoff;
6037 if(tutorialstage==38){
6041 player[1].aitype=passivetype;
6043 if(tutorialstage==39){
6054 weapons.owner[weapons.numweapons]=-1;
6055 weapons.type[weapons.numweapons]=knife;
6056 weapons.damage[weapons.numweapons]=0;
6057 weapons.mass[weapons.numweapons]=1;
6058 weapons.tipmass[weapons.numweapons]=1.2;
6059 weapons.length[weapons.numweapons]=.25;
6060 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6061 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6063 weapons.velocity[weapons.numweapons]=0.1;
6064 weapons.tipvelocity[weapons.numweapons]=0.1;
6065 weapons.missed[weapons.numweapons]=1;
6066 weapons.hitsomething[weapons.numweapons]=0;
6067 weapons.freetime[weapons.numweapons]=0;
6068 weapons.firstfree[weapons.numweapons]=1;
6069 weapons.physics[weapons.numweapons]=1;
6071 weapons.numweapons++;
6073 if(tutorialstage==40){
6074 tutorialmaxtime=300;
6076 if(tutorialstage==41){
6077 tutorialmaxtime=300;
6079 if(tutorialstage==42){
6082 if(tutorialstage==43){
6083 tutorialmaxtime=300;
6085 if(tutorialstage==44){
6087 player[0].weaponactive=-1;
6088 player[0].num_weapons=0;
6089 player[1].weaponactive=0;
6090 player[1].num_weapons=1;
6091 player[1].weaponids[0]=0;
6095 player[1].aitype=attacktypecutoff;
6097 tutorialmaxtime=300;
6099 if(tutorialstage==45){
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;
6107 tutorialmaxtime=300;
6109 if(tutorialstage==46){
6111 player[0].weaponactive=-1;
6112 player[0].num_weapons=0;
6113 player[1].weaponactive=0;
6114 player[1].num_weapons=1;
6115 player[1].weaponids[0]=0;
6117 weapons.type[0]=sword;
6119 tutorialmaxtime=300;
6122 if(tutorialstage==47){
6134 weapons.owner[weapons.numweapons]=-1;
6135 weapons.type[weapons.numweapons]=sword;
6136 weapons.damage[weapons.numweapons]=0;
6137 weapons.mass[weapons.numweapons]=1;
6138 weapons.tipmass[weapons.numweapons]=1.2;
6139 weapons.length[weapons.numweapons]=.25;
6140 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6141 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6143 weapons.velocity[weapons.numweapons]=0.1;
6144 weapons.tipvelocity[weapons.numweapons]=0.1;
6145 weapons.missed[weapons.numweapons]=1;
6146 weapons.hitsomething[weapons.numweapons]=0;
6147 weapons.freetime[weapons.numweapons]=0;
6148 weapons.firstfree[weapons.numweapons]=1;
6149 weapons.physics[weapons.numweapons]=1;
6153 player[0].weaponactive=0;
6154 player[0].num_weapons=1;
6155 player[0].weaponids[0]=1;
6156 player[1].weaponactive=0;
6157 player[1].num_weapons=1;
6158 player[1].weaponids[0]=0;
6160 weapons.numweapons++;
6162 if(tutorialstage==48){
6165 player[1].aitype=passivetype;
6171 player[0].weaponactive=0;
6172 player[0].num_weapons=1;
6173 player[0].weaponids[0]=1;
6174 player[1].weaponactive=0;
6175 player[1].num_weapons=1;
6176 player[1].weaponids[0]=0;
6178 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6179 else weapons.type[0]=staff;
6181 weapons.numweapons++;
6183 if(tutorialstage==49){
6186 player[1].aitype=passivetype;
6188 tutorialmaxtime=200;
6190 weapons.position[1]=1000;
6191 weapons.tippoint[1]=1000;
6193 weapons.numweapons=1;
6195 player[1].weaponactive=-1;
6196 player[1].num_weapons=0;
6197 player[0].weaponactive=0;
6198 player[0].num_weapons=1;
6199 player[0].weaponids[0]=0;
6201 weapons.type[0]=knife;
6203 weapons.numweapons++;
6205 if(tutorialstage==50){
6211 gLoc[0]=player[1].coords.x;
6212 gLoc[1]=player[1].coords.y;
6213 gLoc[2]=player[1].coords.z;
6217 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6218 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6219 FSOUND_SetVolume(channels[fireendsound], 256);
6220 FSOUND_SetPaused(channels[fireendsound], FALSE);
6222 for(i=0;i<player[1].skeleton.num_joints;i++){
6224 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6225 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6226 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;
6227 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6228 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6232 player[1].num_weapons=0;
6233 player[1].weaponstuck=-1;
6234 player[1].weaponactive=-1;
6236 weapons.numweapons=0;
6238 weapons.owner[0]=-1;
6239 weapons.velocity[0]=0.1;
6240 weapons.tipvelocity[0]=-0.1;
6241 weapons.missed[0]=1;
6242 weapons.hitsomething[0]=0;
6243 weapons.freetime[0]=0;
6244 weapons.firstfree[0]=1;
6245 weapons.physics[0]=1;
6247 if(tutorialstage==51){
6248 tutorialmaxtime=80000;
6250 if(tutorialstage<=51)tutorialstagetime=0;
6254 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6255 if(tutorialstage==3){
6256 if(deltah||deltav)tutorialsuccess+=multiplier;
6258 if(tutorialstage==4){
6259 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6261 if(tutorialstage==5){
6262 if(player[0].jumpkeydown)tutorialsuccess=1;
6264 if(tutorialstage==6){
6265 if(player[0].isCrouch())tutorialsuccess=1;
6267 if(tutorialstage==7){
6268 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6270 if(tutorialstage==8){
6271 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6273 if(tutorialstage==9){
6274 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6276 if(tutorialstage==11){
6277 if(player[0].isWallJump())tutorialsuccess=1;
6279 if(tutorialstage==12){
6280 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6282 if(tutorialstage==15){
6283 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6285 if(tutorialstage==16){
6286 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6288 if(tutorialstage==17){
6289 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6291 if(tutorialstage==18){
6292 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6294 if(tutorialstage==19){
6295 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6297 if(tutorialstage==20){
6298 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6300 if(tutorialstage==21){
6301 if(bonus==cannon)tutorialsuccess=1;
6303 if(tutorialstage==22){
6304 if(bonus==spinecrusher)tutorialsuccess=1;
6306 if(tutorialstage==23){
6307 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6309 if(tutorialstage==24){
6310 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6312 if(tutorialstage==25){
6313 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6315 if(tutorialstage==28){
6316 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6318 if(tutorialstage==29){
6319 if(player[0].escapednum==2){
6323 player[1].aitype=passivetype;
6326 if(tutorialstage==33){
6327 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6329 if(tutorialstage==34){
6330 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6332 if(tutorialstage==35){
6333 if(animation[player[0].targetanimation].attack==reversal){
6337 player[1].aitype=passivetype;
6340 if(tutorialstage==40){
6341 if(player[0].num_weapons>0)tutorialsuccess=1;
6343 if(tutorialstage==41){
6344 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6346 if(tutorialstage==43){
6347 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6349 if(tutorialstage==44){
6350 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6352 if(tutorialstage==45){
6353 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6355 if(tutorialstage==46){
6356 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6358 if(tutorialstage==49){
6359 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6361 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6364 if(tutorialstagetime==tutorialmaxtime-3){
6365 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6366 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6367 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6370 if(tutorialsuccess>=1){
6371 if(tutorialstage==34||tutorialstage==35)
6372 tutorialstagetime=tutorialmaxtime-1;
6377 if(tutorialstage<14||tutorialstage>=50){
6378 player[1].coords.y=300;
6379 player[1].velocity=0;
6383 if(tutoriallevel!=1){
6384 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6385 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, TRUE);
6386 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6387 FSOUND_SetPaused(channels[consolesuccesssound], FALSE);
6392 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
6393 FSOUND_SetVolume(channels[fireendsound], 256);
6394 FSOUND_SetPaused(channels[fireendsound], FALSE);
6397 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6398 else bonusnum[bonus]+=0.15;
6399 if(tutoriallevel)bonusvalue=0;
6400 bonusvalue/=bonusnum[bonus];
6401 bonustotal+=bonusvalue;
6403 bonustime+=multiplier;
6405 if(environment==snowyenvironment){
6406 precipdelay-=multiplier;
6407 while(precipdelay<0){
6409 if(!detail)precipdelay+=.04;
6410 XYZ footvel,footpoint;
6413 footpoint=viewer+viewerfacing*6;
6414 footpoint.y+=((float)abs(Random()%1200))/100-6;
6415 footpoint.x+=((float)abs(Random()%1200))/100-6;
6416 footpoint.z+=((float)abs(Random()%1200))/100-6;
6417 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6420 for(k=0;k<numplayers;k++){
6421 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6422 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6424 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){
6425 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6426 else if(player[k].rotation>player[k].targetrotation){
6427 player[k].rotation-=multiplier*player[k].turnspeed;
6429 else if(player[k].rotation<player[k].targetrotation){
6430 player[k].rotation+=multiplier*player[k].turnspeed;
6435 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))){
6436 player[k].turnspeed*=2;
6437 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6438 else if(player[k].rotation>player[k].targetrotation){
6439 player[k].rotation-=multiplier*player[k].turnspeed;
6441 else if(player[k].rotation<player[k].targetrotation){
6442 player[k].rotation+=multiplier*player[k].turnspeed;
6444 player[k].turnspeed/=2;
6447 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6448 player[k].turnspeed*=4;
6449 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6450 else if(player[k].rotation>player[k].targetrotation){
6451 player[k].rotation-=multiplier*player[k].turnspeed;
6453 else if(player[k].rotation<player[k].targetrotation){
6454 player[k].rotation+=multiplier*player[k].turnspeed;
6456 player[k].turnspeed/=4;
6459 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6460 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6462 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6463 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6466 if(player[k].collide<-.3)player[k].collide=-.3;
6467 if(player[k].collide>1)player[k].collide=1;
6468 player[k].collide-=multiplier*30;
6470 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6471 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6473 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6474 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6475 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6476 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6477 lowpoint=player[k].coords;
6478 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6479 else lowpoint.y+=1.3;
6480 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){
6481 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6483 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6484 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6486 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6487 flatfacing=lowpoint-player[k].coords;
6488 player[k].coords=lowpoint;
6489 player[k].coords.y-=1.3;
6490 player[k].collide=1;
6492 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6493 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6494 tempcoords1=lowpoint;
6495 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6496 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6498 player[k].targetanimation=walljumpleftanim;
6499 player[k].targetframe=0;
6502 gLoc[0]=player[k].coords.x;
6503 gLoc[1]=player[k].coords.y;
6504 gLoc[2]=player[k].coords.z;
6508 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6509 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6510 FSOUND_SetVolume(channels[movewhooshsound], 256);
6511 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6512 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6514 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6515 player[k].rotation=-asin(0-lowpointtarget.x);
6516 player[k].rotation*=360/6.28;
6517 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6518 player[k].targetrotation=player[k].rotation;
6519 player[k].lowrotation=player[k].rotation;
6520 if(k==0)numwallflipped++;
6524 lowpoint=tempcoords1;
6525 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6526 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6527 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6529 player[k].targetanimation=walljumprightanim;
6530 player[k].targetframe=0;
6533 gLoc[0]=player[k].coords.x;
6534 gLoc[1]=player[k].coords.y;
6535 gLoc[2]=player[k].coords.z;
6539 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6540 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6541 FSOUND_SetVolume(channels[movewhooshsound], 256);
6542 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6543 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6545 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6546 player[k].rotation=-asin(0-lowpointtarget.x);
6547 player[k].rotation*=360/6.28;
6548 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6549 player[k].targetrotation=player[k].rotation;
6550 player[k].lowrotation=player[k].rotation;
6551 if(k==0)numwallflipped++;
6555 lowpoint=tempcoords1;
6556 lowpointtarget=lowpoint+player[k].facing*2;
6557 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6558 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6560 player[k].targetanimation=walljumpbackanim;
6561 player[k].targetframe=0;
6564 gLoc[0]=player[k].coords.x;
6565 gLoc[1]=player[k].coords.y;
6566 gLoc[2]=player[k].coords.z;
6570 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6571 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6572 FSOUND_SetVolume(channels[movewhooshsound], 256);
6573 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6574 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6576 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6577 player[k].rotation=-asin(0-lowpointtarget.x);
6578 player[k].rotation*=360/6.28;
6579 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6580 player[k].targetrotation=player[k].rotation;
6581 player[k].lowrotation=player[k].rotation;
6582 if(k==0)numwallflipped++;
6586 lowpoint=tempcoords1;
6587 lowpointtarget=lowpoint-player[k].facing*2;
6588 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6589 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6591 player[k].targetanimation=walljumpfrontanim;
6592 player[k].targetframe=0;
6595 gLoc[0]=player[k].coords.x;
6596 gLoc[1]=player[k].coords.y;
6597 gLoc[2]=player[k].coords.z;
6601 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
6602 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6603 FSOUND_SetVolume(channels[movewhooshsound], 256);
6604 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6605 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6607 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6608 player[k].rotation=-asin(0-lowpointtarget.x);
6609 player[k].rotation*=360/6.28;
6610 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6611 player[k].rotation+=180;
6612 player[k].targetrotation=player[k].rotation;
6613 player[k].lowrotation=player[k].rotation;
6614 if(k==0)numwallflipped++;
6622 else if(objects.type[i]==rocktype){
6623 lowpoint2=player[k].coords;
6624 lowpoint=player[k].coords;
6626 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6627 player[k].coords=colpoint;
6628 player[k].collide=1;
6631 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6632 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6634 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6636 player[k].targetframe=0;
6637 player[k].onterrain=1;
6639 if(player[k].id==0){
6640 FSOUND_SetPaused(channels[whooshsound], TRUE);
6641 FSOUND_SetVolume(channels[whooshsound], 0);
6644 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6645 if(player[k].isFlip())player[k].jumppower=-4;
6646 player[k].targetanimation=player[k].getLanding();
6649 gLoc[0]=player[k].coords.x;
6650 gLoc[1]=player[k].coords.y;
6651 gLoc[2]=player[k].coords.z;
6652 vel[0]=player[k].velocity.x;
6653 vel[1]=player[k].velocity.y;
6654 vel[2]=player[k].velocity.z;
6655 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
6656 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6657 FSOUND_SetVolume(channels[landsound], 128);
6658 FSOUND_SetPaused(channels[landsound], FALSE);
6660 envsound[numenvsounds]=player[k].coords;
6661 envsoundvol[numenvsounds]=16;
6662 envsoundlife[numenvsounds]=.4;
6671 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6672 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6673 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6674 lowpoint=player[k].coords;
6676 if(objects.type[i]!=rocktype)
6677 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6678 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6679 player[k].coords=lowpoint;
6680 player[k].coords.y-=1.35;
6681 player[k].collide=1;
6683 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)){
6684 lowpoint=player[k].coords;
6685 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6686 lowpoint=player[k].coords;
6690 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6691 lowpointtarget=lowpoint+facing*1.4;
6692 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6694 lowpoint=player[k].coords;
6696 lowpointtarget=lowpoint+facing*1.4;
6698 lowpointtarget2=lowpointtarget;
6700 lowpointtarget3=lowpointtarget;
6702 lowpointtarget4=lowpointtarget;
6704 lowpointtarget5=lowpointtarget;
6706 lowpointtarget6=lowpointtarget;
6708 lowpointtarget7=lowpoint;
6710 lowpointtarget2.x+=.1;
6712 lowpointtarget3.z+=.1;
6714 lowpointtarget4.x-=.1;
6716 lowpointtarget5.z-=.1;
6718 lowpointtarget6.y+=45/13;
6719 lowpointtarget6+=facing*.6;
6720 lowpointtarget7.y+=90/13;
6721 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6722 if(objects.friction[i]>.5)
6725 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6726 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6727 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6728 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)
6730 lowpoint=player[k].coords;
6731 lowpoint.y+=(float)j/13;
6732 lowpointtarget=lowpoint+facing*1.4;
6733 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6737 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6740 if(j<=25&&player[k].targetanimation==jumpdownanim){
6743 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6744 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6745 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)*/){
6746 lowpoint=player[k].coords;
6747 lowpoint.y+=(float)j/13;
6748 lowpointtarget=lowpoint+facing*1.3;
6749 flatfacing=player[k].coords;
6750 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6751 player[k].coords.y=lowpointtarget.y-.07;
6752 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6754 if(j>10||!player[k].isRun()){
6755 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6756 if(k==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
6760 gLoc[0]=player[k].coords.x;
6761 gLoc[1]=player[k].coords.y;
6762 gLoc[2]=player[k].coords.z;
6763 vel[0]=player[k].velocity.x;
6764 vel[1]=player[k].velocity.y;
6765 vel[2]=player[k].velocity.z;
6766 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
6767 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6768 FSOUND_SetVolume(channels[jumpsound], 128);
6769 FSOUND_SetPaused(channels[jumpsound], FALSE);
6771 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6772 player[k].rotation=-asin(0-lowpointtarget.x);
6773 player[k].rotation*=360/6.28;
6774 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6775 player[k].targetrotation=player[k].rotation;
6776 player[k].lowrotation=player[k].rotation;
6778 //player[k].velocity=lowpointtarget*.03;
6779 player[k].velocity=0;
6781 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6782 //player[k].currentanimation=climbanim;
6783 player[k].targetanimation=climbanim;
6784 player[k].jumppower=0;
6785 player[k].jumpclimb=1;
6787 player[k].transspeed=6;
6790 //player[k].currentframe=1;
6791 player[k].targetframe=1;
6793 //player[k].currentframe=0;
6794 player[k].targetframe=0;
6795 //player[k].currentanimation=hanganim;
6796 player[k].targetanimation=hanganim;
6797 player[k].jumppower=0;
6811 if(player[k].collide<=0){
6812 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()){
6813 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)){
6814 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6815 player[k].targetanimation=jumpdownanim;
6816 player[k].targetframe=0;
6821 gLoc[0]=player[k].coords.x;
6822 gLoc[1]=player[k].coords.y;
6823 gLoc[2]=player[k].coords.z;
6824 vel[0]=player[k].velocity.x;
6825 vel[1]=player[k].velocity.y;
6826 vel[2]=player[k].velocity.z;
6828 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
6829 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6830 FSOUND_SetVolume(channels[whooshsound], 128);
6831 FSOUND_SetPaused(channels[whooshsound], FALSE);
6834 player[k].velocity.y+=gravity;
6839 player[k].realoldcoords=player[k].coords;
6842 static XYZ oldviewer;
6845 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6846 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6847 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6848 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6849 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6850 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6851 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6852 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6856 player[0].forwardkeydown=0;
6857 player[0].leftkeydown=0;
6858 player[0].backkeydown=0;
6859 player[0].rightkeydown=0;
6860 player[0].jumpkeydown=0;
6861 player[0].crouchkeydown=0;
6862 player[0].drawkeydown=0;
6863 player[0].throwkeydown=0;
6866 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6869 static bool endkeydown;
6876 facing=DoRotation(facing,-rotation2,0,0);
6877 facing=DoRotation(facing,0,0-rotation,0);
6882 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6884 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6885 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6886 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6887 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6888 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6889 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6890 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)
6891 ||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)
6892 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6894 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6895 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6896 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6897 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6898 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6899 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6900 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6901 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6902 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6903 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6904 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6906 participantfocus[whichdialogue][indialogue]=whichend;
6907 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6908 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6911 participantfocus[whichdialogue][indialogue]=-1;
6913 if(player[participantfocus[whichdialogue][indialogue]].dead){
6918 dialoguecamera[whichdialogue][indialogue]=viewer;
6919 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6920 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6922 if(indialogue<numdialogueboxes[whichdialogue]){
6923 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6924 static float gLoc[3];
6925 static float vel[3];
6927 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6928 temppos=temppos-viewer;
6929 Normalise(&temppos);
6934 gLoc[2]=temppos.z;vel[0]=0;
6938 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6939 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6940 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6941 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6942 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6943 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6944 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6945 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6946 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6947 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6948 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6949 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6950 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6951 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6952 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6953 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6954 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6955 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6956 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6957 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6958 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
6959 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6960 FSOUND_SetVolume(channels[whichsoundplay], 256);
6961 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
6965 for(j=0;j<numplayers;j++){
6966 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6971 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)
6972 ||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)
6975 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6976 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6977 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6978 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6979 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6980 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6981 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6982 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6983 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6984 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6985 participantfacing[whichdialogue][indialogue][whichend]=facing;
6987 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)
6988 &&!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)
6989 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6992 if(indialogue>=numdialogueboxes[whichdialogue]){
6999 FSOUND_SetPaused(channels[whooshsound], TRUE);
7000 viewer=dialoguecamera[whichdialogue][indialogue];
7001 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7002 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7004 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7005 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7006 if(dialoguetime>0.5)
7007 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)
7008 ||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)
7009 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7012 if(indialogue<numdialogueboxes[whichdialogue]){
7013 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7014 static float gLoc[3];
7015 static float vel[3];
7017 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7018 temppos=temppos-viewer;
7019 Normalise(&temppos);
7024 gLoc[2]=temppos.z;vel[0]=0;
7028 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7029 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7030 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7031 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7032 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7033 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7034 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7035 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7036 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7037 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7038 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7039 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7040 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7041 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7042 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7043 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7044 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7045 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7046 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7047 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7048 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7049 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7050 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, TRUE);
7051 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7052 FSOUND_SetVolume(channels[whichsoundplay], 256);
7053 FSOUND_SetPaused(channels[whichsoundplay], FALSE);
7055 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7056 hotspot[numhotspots]=player[0].coords;
7057 hotspotsize[numhotspots]=10;
7058 hotspottype[numhotspots]=-1;
7062 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7066 if(player[participantfocus[whichdialogue][indialogue]].dead){
7074 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)
7075 &&!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)
7076 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7079 if(indialogue>=numdialogueboxes[whichdialogue]){
7083 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7086 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7089 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7091 for(i=1;i<numplayers;i++){
7092 player[i].aitype = attacktypecutoff;
7099 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7100 else oldbuttondialogue=1;
7102 static float keyrefreshdelay=0,bigrefreshdelay=0;
7106 /*keyrefreshdelay-=multiplier;
7107 bigrefreshdelay-=multiplier;
7109 if(keyrefreshdelay<=0){
7110 static int concat[4];
7112 concat[0]=player[0].forwardkeydown;
7113 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7114 concat[0]=concat[0]*2+player[0].rightkeydown;
7115 concat[0]=concat[0]*2+player[0].leftkeydown;
7116 concat[0]=concat[0]*2+player[0].backkeydown;
7117 concat[0]=concat[0]*2+player[0].jumpkeydown;
7118 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7119 concat[0]=concat[0]*2+player[0].crouchkeydown;
7121 concat[1]=player[0].crouchtogglekeydown;
7122 concat[1]=concat[1]*2+player[0].drawkeydown;
7123 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7124 concat[1]=concat[1]*2+player[0].throwkeydown;
7125 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7126 concat[1]=concat[1]*2+player[0].attackkeydown;
7128 //concat[2]=(char)((int)(rotation/2)%180);
7130 //concat[3]=(char)((int)(rotation2/2)%180);
7132 chatname[0]=concat[0]-128;
7133 chatname[1]=concat[1]-128;
7134 //chatname[2]=concat[2]-128;
7135 //chatname[3]=concat[3]-128;
7137 memcpy(chatname+temppoint,&rotation,sizeof(float));
7138 temppoint+=sizeof(float);
7139 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7140 temppoint+=sizeof(float);
7142 chatname[temppoint]='\0';
7144 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7145 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7146 //keyrefreshdelay=.01;
7147 keyrefreshdelay=.03;
7150 if(bigrefreshdelay<=0){
7153 memcpy(chatname+temppoint,&i,sizeof(int));
7154 temppoint+=sizeof(int);
7155 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7156 temppoint+=sizeof(float);
7157 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7158 temppoint+=sizeof(float);
7159 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7160 temppoint+=sizeof(float);
7161 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7162 temppoint+=sizeof(float);
7163 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7164 temppoint+=sizeof(float);
7165 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7166 temppoint+=sizeof(int);
7167 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7168 temppoint+=sizeof(int);
7169 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7170 temppoint+=sizeof(float);
7171 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7172 temppoint+=sizeof(float);
7173 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7174 temppoint+=sizeof(float);
7175 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7176 temppoint+=sizeof(int);
7177 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7178 temppoint+=sizeof(int);
7179 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7180 temppoint+=sizeof(float);
7181 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7182 temppoint+=sizeof(float);
7183 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7184 temppoint+=sizeof(float);
7185 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7186 temppoint+=sizeof(int);
7187 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7188 temppoint+=sizeof(int);
7189 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7190 temppoint+=sizeof(int);
7191 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7192 temppoint+=sizeof(int);
7193 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7194 temppoint+=sizeof(int);
7195 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7196 temppoint+=sizeof(int);
7197 chatname[temppoint]='\0';
7199 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);
7200 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7201 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7203 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);
7205 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7206 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7208 //bigrefreshdelay=.02;
7213 if(!player[0].jumpkeydown){
7214 player[0].jumptogglekeydown=0;
7216 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7219 dialoguetime+=multiplier;
7220 skybox.cloudmove+=multiplier;
7221 hawkrotation+=multiplier*25;
7223 realhawkcoords.x=25;
7224 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7225 hawkcalldelay-=multiplier/2;
7227 if(hawkcalldelay<=0)
7229 static float gLoc[3];
7230 static float vel[3];
7231 gLoc[0]=realhawkcoords.x;
7232 gLoc[1]=realhawkcoords.y;
7233 gLoc[2]=realhawkcoords.z;
7237 PlaySoundEx( hawksound, samp[hawksound], NULL, TRUE);
7238 FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
7239 FSOUND_SetVolume(channels[hawksound], 128);
7240 FSOUND_SetPaused(channels[hawksound], FALSE);
7242 hawkcalldelay=16+abs(Random()%8);
7244 static float temptexdetail;
7247 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7248 player[0].damagetolerance=200000;
7251 player[0].permanentdamage=0;
7252 player[0].superpermanentdamage=0;
7255 whichchar = abs(Random()%7);
7256 registrationname[whichchar]+=1;
7260 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7262 if(environment>2)environment=0;
7263 Setenvironment(environment);
7269 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7273 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7274 cameramode=1-cameramode;
7275 cameratogglekeydown=1;
7278 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7279 cameratogglekeydown=0;
7282 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7283 if(player[0].num_weapons>0){
7284 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7285 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7286 else weapons.type[player[0].weaponids[0]]=sword;
7287 if(weapons.type[player[0].weaponids[0]]==sword){
7288 weapons.mass[player[0].weaponids[0]]=1.5;
7289 weapons.tipmass[player[0].weaponids[0]]=1;
7290 weapons.length[player[0].weaponids[0]]=.8;
7292 if(weapons.type[player[0].weaponids[0]]==staff){
7293 weapons.mass[player[0].weaponids[0]]=2;
7294 weapons.tipmass[player[0].weaponids[0]]=1;
7295 weapons.length[player[0].weaponids[0]]=1.5;
7298 if(weapons.type[player[0].weaponids[0]]==knife){
7299 weapons.mass[player[0].weaponids[0]]=1;
7300 weapons.tipmass[player[0].weaponids[0]]=1.2;
7301 weapons.length[player[0].weaponids[0]]=.25;
7305 /*for(i=0;i<objects.numobjects;i++){
7306 if(objects.type[i]==treeleavestype){
7307 for(j=0;j<objects.numobjects;j++){
7308 if(objects.type[j]==treetrunktype)
7309 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7310 objects.scale[i]=objects.scale[j];
7314 detailtogglekeydown=1;
7317 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7319 float closestdist=-1;
7322 for(i=1;i<numplayers;i++){
7323 distance=findDistancefast(&player[i].coords,&player[0].coords);
7324 if(closestdist==-1||distance<closestdist){
7325 closestdist=distance;
7330 if(player[closest].num_weapons)
7332 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7333 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7334 else weapons.type[player[closest].weaponids[0]]=sword;
7335 if(weapons.type[player[closest].weaponids[0]]==sword){
7336 weapons.mass[player[closest].weaponids[0]]=1.5;
7337 weapons.tipmass[player[closest].weaponids[0]]=1;
7338 weapons.length[player[closest].weaponids[0]]=.8;
7340 if(weapons.type[player[0].weaponids[0]]==staff){
7341 weapons.mass[player[0].weaponids[0]]=2;
7342 weapons.tipmass[player[0].weaponids[0]]=1;
7343 weapons.length[player[0].weaponids[0]]=1.5;
7345 if(weapons.type[player[closest].weaponids[0]]==knife){
7346 weapons.mass[player[closest].weaponids[0]]=1;
7347 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7348 weapons.length[player[closest].weaponids[0]]=.25;
7351 if(!player[closest].num_weapons)
7353 player[closest].weaponids[0]=weapons.numweapons;
7354 weapons.owner[weapons.numweapons]=closest;
7355 weapons.type[weapons.numweapons]=knife;
7356 weapons.damage[weapons.numweapons]=0;
7357 weapons.numweapons++;
7358 player[closest].num_weapons=1;
7359 if(weapons.type[player[closest].weaponids[0]]==sword){
7360 weapons.mass[player[closest].weaponids[0]]=1.5;
7361 weapons.tipmass[player[closest].weaponids[0]]=1;
7362 weapons.length[player[closest].weaponids[0]]=.8;
7364 if(weapons.type[player[closest].weaponids[0]]==knife){
7365 weapons.mass[player[closest].weaponids[0]]=1;
7366 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7367 weapons.length[player[closest].weaponids[0]]=.25;
7371 detailtogglekeydown=1;
7374 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7376 float closestdist=-1;
7379 for(i=1;i<numplayers;i++){
7380 distance=findDistancefast(&player[i].coords,&player[0].coords);
7381 if(closestdist==-1||distance<closestdist){
7382 closestdist=distance;
7387 player[closest].rotation+=multiplier*50;
7388 player[closest].targetrotation=player[closest].rotation;
7392 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7394 float closestdist=-1;
7397 for(i=1;i<numplayers;i++){
7398 distance=findDistancefast(&player[i].coords,&player[0].coords);
7399 if(closestdist==-1||distance<closestdist){
7400 closestdist=distance;
7404 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7407 player[closest].whichskin++;
7408 if(player[closest].whichskin>9)player[closest].whichskin=0;
7409 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7411 if(player[closest].creature==rabbittype){
7412 if(player[closest].whichskin==0){
7413 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7415 else if(player[closest].whichskin==1){
7416 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7418 else if(player[closest].whichskin==2){
7419 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7421 else if(player[closest].whichskin==3){
7422 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7424 else if(player[closest].whichskin==4){
7425 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7427 else if(player[closest].whichskin==5){
7428 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7430 else if(player[closest].whichskin==6){
7431 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7433 else if(player[closest].whichskin==7){
7434 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7436 else if(player[closest].whichskin==8){
7437 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7439 else if(player[closest].whichskin==9){
7440 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7443 if(player[closest].creature==wolftype){
7445 if(player[closest].whichskin==0){
7446 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7448 else if(player[closest].whichskin==1){
7449 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7451 else if(player[closest].whichskin==2){
7452 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7457 if(player[closest].numclothes){
7458 for(i=0;i<player[closest].numclothes;i++){
7459 tintr=player[closest].clothestintr[i];
7460 tintg=player[closest].clothestintg[i];
7461 tintb=player[closest].clothestintb[i];
7462 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7464 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7467 detailtogglekeydown=1;
7470 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7472 float closestdist=-1;
7475 for(i=1;i<numplayers;i++){
7476 distance=findDistancefast(&player[i].coords,&player[0].coords);
7477 if(closestdist==-1||distance<closestdist){
7478 closestdist=distance;
7483 if(player[closest].creature==wolftype){
7484 headprop=player[closest].proportionhead.x/1.1;
7485 bodyprop=player[closest].proportionbody.x/1.1;
7486 armprop=player[closest].proportionarms.x/1.1;
7487 legprop=player[closest].proportionlegs.x/1.1;
7490 if(player[closest].creature==rabbittype){
7491 headprop=player[closest].proportionhead.x/1.2;
7492 bodyprop=player[closest].proportionbody.x/1.05;
7493 armprop=player[closest].proportionarms.x/1.00;
7494 legprop=player[closest].proportionlegs.x/1.1;
7498 if(player[closest].creature==rabbittype){
7499 player[closest].skeleton.id=closest;
7500 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);
7501 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7502 player[closest].whichskin=0;
7503 player[closest].creature=wolftype;
7505 player[closest].proportionhead=1.1;
7506 player[closest].proportionbody=1.1;
7507 player[closest].proportionarms=1.1;
7508 player[closest].proportionlegs=1.1;
7509 player[closest].proportionlegs.y=1.1;
7510 player[closest].scale=.23*5*player[0].scale;
7512 player[closest].damagetolerance=300;
7516 player[closest].skeleton.id=closest;
7517 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);
7518 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7519 player[closest].whichskin=0;
7520 player[closest].creature=rabbittype;
7522 player[closest].proportionhead=1.2;
7523 player[closest].proportionbody=1.05;
7524 player[closest].proportionarms=1.00;
7525 player[closest].proportionlegs=1.1;
7526 player[closest].proportionlegs.y=1.05;
7527 player[closest].scale=.2*5*player[0].scale;
7529 player[closest].damagetolerance=200;
7532 if(player[closest].creature==wolftype){
7533 player[closest].proportionhead=1.1*headprop;
7534 player[closest].proportionbody=1.1*bodyprop;
7535 player[closest].proportionarms=1.1*armprop;
7536 player[closest].proportionlegs=1.1*legprop;
7539 if(player[closest].creature==rabbittype){
7540 player[closest].proportionhead=1.2*headprop;
7541 player[closest].proportionbody=1.05*bodyprop;
7542 player[closest].proportionarms=1.00*armprop;
7543 player[closest].proportionlegs=1.1*legprop;
7544 player[closest].proportionlegs.y=1.05*legprop;
7548 detailtogglekeydown=1;
7551 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7552 detailtogglekeydown=0;
7555 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7558 slomotogglekeydown=1;
7562 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7564 float closestdist=-1;
7566 XYZ flatfacing2,flatvelocity2;
7569 for(i=1;i<numplayers;i++){
7570 distance=findDistancefast(&player[i].coords,&player[0].coords);
7571 if(distance<144&&!player[i].headless)
7572 if(closestdist==-1||distance<closestdist){
7573 closestdist=distance;
7575 blah = player[i].coords;
7580 XYZ headspurtdirection;
7581 int i = player[closest].skeleton.jointlabels[head];
7582 for(k=0;k<player[closest].skeleton.num_joints; k++){
7583 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7584 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7585 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;
7586 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7587 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7588 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7589 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7590 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7591 Normalise(&headspurtdirection);
7592 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7593 flatvelocity2+=headspurtdirection*8;
7594 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7596 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7606 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7607 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7608 FSOUND_SetVolume(channels[splattersound], 256);
7609 FSOUND_SetPaused(channels[splattersound], FALSE);
7611 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7612 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7613 FSOUND_SetVolume(channels[breaksound2], 100);
7614 FSOUND_SetPaused(channels[breaksound2], FALSE);
7616 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7617 player[closest].RagDoll(0);
7618 player[closest].dead=2;
7619 player[closest].headless=1;
7620 player[closest].DoBloodBig(3,165);
7625 explodetogglekeydown=1;
7628 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7630 float closestdist=-1;
7632 XYZ flatfacing2,flatvelocity2;
7635 for(i=1;i<numplayers;i++){
7636 distance=findDistancefast(&player[i].coords,&player[0].coords);
7638 if(closestdist==-1||distance<closestdist){
7639 closestdist=distance;
7641 blah=player[i].coords;
7655 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
7656 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7657 FSOUND_SetVolume(channels[splattersound], 256);
7658 FSOUND_SetPaused(channels[splattersound], FALSE);
7660 PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
7661 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7662 FSOUND_SetVolume(channels[breaksound2], 600);
7663 FSOUND_SetPaused(channels[breaksound2], FALSE);
7665 for(i=0;i<player[closest].skeleton.num_joints; i++){
7666 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7667 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7668 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;
7669 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7670 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7671 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7672 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7673 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7674 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7675 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7678 for(i=0;i<player[closest].skeleton.num_joints; i++){
7679 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7680 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7681 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;
7682 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7683 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7684 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7685 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7686 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7687 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7690 for(i=0;i<player[closest].skeleton.num_joints; i++){
7691 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7692 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7693 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;
7694 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7695 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7696 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7697 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7698 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7699 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7702 for(i=0;i<player[closest].skeleton.num_joints; i++){
7703 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7704 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7705 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;
7706 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7707 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7708 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7709 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7710 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7711 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7715 for(j=0;j<numplayers; j++){
7717 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7718 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7719 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7720 player[j].skeleton.longdead=0;
7721 player[j].RagDoll(0);
7722 for(i=0;i<player[j].skeleton.num_joints; i++){
7723 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7724 if(findDistancefast(&temppos,&player[closest].coords)<25){
7725 flatvelocity2=temppos-player[closest].coords;
7726 Normalise(&flatvelocity2);
7727 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7734 player[closest].DoDamage(10000);
7735 player[closest].RagDoll(0);
7736 player[closest].dead=2;
7737 player[closest].coords=20;
7738 player[closest].skeleton.free=2;
7744 explodetogglekeydown=1;
7747 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7748 explodetogglekeydown=0;
7752 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7754 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7755 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7756 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7757 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7758 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7759 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7760 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7762 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7763 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7764 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7765 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7766 for(j=0;j<player[0].num_weapons;j++){
7767 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7769 fwrite( &environment, 1, sizeof(int), tfile );
7771 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7772 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7773 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7774 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7775 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7777 fwrite( &numplayers, 1, sizeof(int), tfile );
7778 if(numplayers>1&&numplayers<maxplayers)
7779 for(i=1;i<numplayers;i++){
7780 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7781 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7782 for(j=0;j<player[i].num_weapons;j++){
7783 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7785 if(player[i].numwaypoints<30){
7786 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7787 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7788 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7789 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7792 player[i].numwaypoints=0;
7793 player[i].waypoint=0;
7794 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7795 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7796 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7802 slomotogglekeydown=1;
7805 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7806 slomotogglekeydown=0;
7810 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7811 player[0].onfire=1-player[0].onfire;
7812 if(player[0].onfire){
7813 player[0].CatchFire();
7815 if(!player[0].onfire){
7818 gLoc[0]=player[0].coords.x;
7819 gLoc[1]=player[0].coords.y;
7820 gLoc[2]=player[0].coords.z;
7824 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
7825 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7826 FSOUND_SetVolume(channels[fireendsound], 256);
7827 FSOUND_SetPaused(channels[fireendsound], FALSE);
7828 FSOUND_SetPaused(channels[stream_firesound], TRUE);
7830 slomotogglekeydown=1;
7833 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7834 if(player[0].bleeding<=0)
7835 player[0].DoBlood(1,255);
7839 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7841 float closestdist=-1;
7844 for(i=1;i<numplayers;i++){
7845 distance=findDistancefast(&player[i].coords,&player[0].coords);
7846 if(closestdist==-1||distance<closestdist){
7847 closestdist=distance;
7851 if(closestdist>0&&closest>=0){
7852 //player[closest]=player[numplayers-1];
7853 //player[closest].skeleton=player[numplayers-1].skeleton;
7856 drawmodetogglekeydown=1;
7859 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7861 float closestdist=-1;
7864 for(i=1;i<max_objects;i++){
7865 distance=findDistancefast(&objects.position[i],&player[0].coords);
7866 if(closestdist==-1||distance<closestdist){
7867 closestdist=distance;
7871 if(closestdist>0&&closest>=0){
7872 objects.position[closest].y-=500;
7874 drawmodetogglekeydown=1;
7877 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7879 //if(drawmode>2)drawmode=0;
7880 if(objects.numobjects<max_objects-1){
7882 boxcoords.x=player[0].coords.x;
7883 boxcoords.z=player[0].coords.z;
7884 boxcoords.y=player[0].coords.y-3;
7885 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7886 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7887 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7888 float temprotat,temprotat2;
7889 temprotat=editorrotation;
7890 temprotat2=editorrotation2;
7891 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7892 if(temprotat2<0)temprotat2=Random()%360;
7894 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7895 if(editortype==treetrunktype)
7896 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7899 drawmodetogglekeydown=1;
7902 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7903 if(numplayers<maxplayers-1){
7904 player[numplayers].scale=.2*5*player[0].scale;
7905 player[numplayers].creature=rabbittype;
7906 player[numplayers].howactive=editoractive;
7907 player[numplayers].skeleton.id=numplayers;
7908 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);
7910 //texsize=512*512*3/texdetail/texdetail;
7911 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7912 //player[numplayers].skeleton.skinText.resize(texsize);
7914 k=abs(Random()%2)+1;
7916 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7917 player[numplayers].whichskin=0;
7920 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7921 player[numplayers].whichskin=1;
7924 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7925 player[numplayers].whichskin=2;
7928 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7929 player[numplayers].power=1;
7930 player[numplayers].speedmult=1;
7931 player[numplayers].currentanimation=bounceidleanim;
7932 player[numplayers].targetanimation=bounceidleanim;
7933 player[numplayers].currentframe=0;
7934 player[numplayers].targetframe=1;
7935 player[numplayers].target=0;
7936 player[numplayers].bled=0;
7937 player[numplayers].speed=1+(float)(Random()%100)/1000;
7939 player[numplayers].targetrotation=player[0].targetrotation;
7940 player[numplayers].rotation=player[0].rotation;
7942 player[numplayers].velocity=0;
7943 player[numplayers].coords=player[0].coords;
7944 player[numplayers].oldcoords=player[numplayers].coords;
7945 player[numplayers].realoldcoords=player[numplayers].coords;
7947 player[numplayers].id=numplayers;
7948 player[numplayers].skeleton.id=numplayers;
7949 player[numplayers].updatedelay=0;
7950 player[numplayers].normalsupdatedelay=0;
7952 player[numplayers].aitype=passivetype;
7953 player[numplayers].aitarget=0;
7955 if(player[0].creature==wolftype){
7956 headprop=player[0].proportionhead.x/1.1;
7957 bodyprop=player[0].proportionbody.x/1.1;
7958 armprop=player[0].proportionarms.x/1.1;
7959 legprop=player[0].proportionlegs.x/1.1;
7962 if(player[0].creature==rabbittype){
7963 headprop=player[0].proportionhead.x/1.2;
7964 bodyprop=player[0].proportionbody.x/1.05;
7965 armprop=player[0].proportionarms.x/1.00;
7966 legprop=player[0].proportionlegs.x/1.1;
7969 if(player[numplayers].creature==wolftype){
7970 player[numplayers].proportionhead=1.1*headprop;
7971 player[numplayers].proportionbody=1.1*bodyprop;
7972 player[numplayers].proportionarms=1.1*armprop;
7973 player[numplayers].proportionlegs=1.1*legprop;
7976 if(player[numplayers].creature==rabbittype){
7977 player[numplayers].proportionhead=1.2*headprop;
7978 player[numplayers].proportionbody=1.05*bodyprop;
7979 player[numplayers].proportionarms=1.00*armprop;
7980 player[numplayers].proportionlegs=1.1*legprop;
7981 player[numplayers].proportionlegs.y=1.05*legprop;
7984 player[numplayers].headless=0;
7985 player[numplayers].onfire=0;
7988 player[numplayers].proportionhead.z=0;
7989 player[numplayers].proportionbody.z=0;
7990 player[numplayers].proportionarms.z=0;
7991 player[numplayers].proportionlegs.z=0;
7994 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7996 player[numplayers].damagetolerance=200;
7998 player[numplayers].protectionhead=player[0].protectionhead;
7999 player[numplayers].protectionhigh=player[0].protectionhigh;
8000 player[numplayers].protectionlow=player[0].protectionlow;
8001 player[numplayers].armorhead=player[0].armorhead;
8002 player[numplayers].armorhigh=player[0].armorhigh;
8003 player[numplayers].armorlow=player[0].armorlow;
8004 player[numplayers].metalhead=player[0].metalhead;
8005 player[numplayers].metalhigh=player[0].metalhigh;
8006 player[numplayers].metallow=player[0].metallow;
8008 player[numplayers].immobile=player[0].immobile;
8010 player[numplayers].numclothes=player[0].numclothes;
8011 if(player[numplayers].numclothes)
8012 for(i=0;i<player[numplayers].numclothes;i++){
8013 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8014 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8015 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8016 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8017 tintr=player[numplayers].clothestintr[i];
8018 tintg=player[numplayers].clothestintg[i];
8019 tintb=player[numplayers].clothestintb[i];
8020 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8022 if(player[numplayers].numclothes){
8023 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8026 player[numplayers].power=player[0].power;
8027 player[numplayers].speedmult=player[0].speedmult;
8029 player[numplayers].damage=0;
8030 player[numplayers].permanentdamage=0;
8031 player[numplayers].superpermanentdamage=0;
8032 player[numplayers].deathbleeding=0;
8033 player[numplayers].bleeding=0;
8034 player[numplayers].numwaypoints=0;
8035 player[numplayers].waypoint=0;
8036 player[numplayers].jumppath=0;
8037 player[numplayers].weaponstuck=-1;
8038 player[numplayers].weaponactive=-1;
8039 player[numplayers].num_weapons=0;
8040 player[numplayers].bloodloss=0;
8041 player[numplayers].dead=0;
8043 player[numplayers].loaded=1;
8047 drawmodetogglekeydown=1;
8050 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8051 if(player[numplayers-1].numwaypoints<90){
8052 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8053 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8054 player[numplayers-1].numwaypoints++;
8056 drawmodetogglekeydown=1;
8059 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8060 if(numpathpoints<30){
8061 bool connected,alreadyconnected;
8064 for(i=0;i<numpathpoints;i++){
8065 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8067 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8068 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8070 if(!alreadyconnected){
8071 numpathpointconnect[pathpointselected]++;
8073 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8079 pathpoint[numpathpoints-1]=player[0].coords;
8080 numpathpointconnect[numpathpoints-1]=0;
8081 if(numpathpoints>1&&pathpointselected!=-1){
8082 numpathpointconnect[pathpointselected]++;
8083 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8085 pathpointselected=numpathpoints-1;
8088 drawmodetogglekeydown=1;
8091 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8092 pathpointselected++;
8093 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8094 drawmodetogglekeydown=1;
8096 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8097 pathpointselected--;
8098 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8099 drawmodetogglekeydown=1;
8101 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8102 if(pathpointselected!=-1){
8104 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8105 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8106 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8107 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8109 for(i=0;i<numpathpoints;i++){
8110 for(j=0;j<numpathpointconnect[i];j++){
8111 if(pathpointconnect[i][j]==pathpointselected){
8112 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8113 numpathpointconnect[i]--;
8115 if(pathpointconnect[i][j]==numpathpoints){
8116 pathpointconnect[i][j]=pathpointselected;
8120 pathpointselected=numpathpoints-1;
8122 drawmodetogglekeydown=1;
8125 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8126 editorenabled=1-editorenabled;
8128 player[0].damagetolerance=100000;
8130 player[0].superpermanentdamage=0;
8131 player[0].bloodloss=0;
8132 player[0].deathbleeding=0;
8135 player[0].damagetolerance=200;
8137 player[0].permanentdamage=0;
8138 player[0].superpermanentdamage=0;
8139 player[0].bloodloss=0;
8140 player[0].deathbleeding=0;
8142 drawmodetogglekeydown=1;
8145 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8147 if(editortype==treeleavestype||editortype==10)editortype--;
8148 if(editortype<0)editortype=firetype;
8149 drawmodetogglekeydown=1;
8152 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8154 if(editortype==treeleavestype||editortype==10)editortype++;
8155 if(editortype>firetype)editortype=0;
8156 drawmodetogglekeydown=1;
8159 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8160 editorrotation-=multiplier*100;
8161 if(editorrotation<-.01)editorrotation=-.01;
8162 drawmodetogglekeydown=1;
8165 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8166 editorrotation+=multiplier*100;
8167 drawmodetogglekeydown=1;
8170 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8171 editorsize+=multiplier;
8172 drawmodetogglekeydown=1;
8175 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8176 editorsize-=multiplier;
8177 if(editorsize<.1)editorsize=.1;
8178 drawmodetogglekeydown=1;
8182 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8183 mapradius-=multiplier*10;
8186 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8187 mapradius+=multiplier*10;
8190 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8191 mapcenter.x+=multiplier*20;
8194 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8195 mapcenter.x-=multiplier*20;
8198 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8199 mapcenter.z+=multiplier*20;
8202 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8203 mapcenter.z-=multiplier*20;
8206 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8207 editorrotation2+=multiplier*100;
8210 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8211 editorrotation2-=multiplier*100;
8212 if(editorrotation2<-.01)editorrotation2=-.01;
8214 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8216 float closestdist=-1;
8218 for(i=0;i<objects.numobjects;i++){
8219 distance=findDistancefast(&objects.position[i],&player[0].coords);
8220 if(closestdist==-1||distance<closestdist){
8221 closestdist=distance;
8225 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8226 drawmodetogglekeydown=1;
8230 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)){
8231 drawmodetogglekeydown=0;
8234 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8235 //if(!player[0].skeleton.free)player[0].damage+=500;
8236 player[0].RagDoll(0);
8237 //player[0].spurt=1;
8238 //player[0].DoDamage(1000);
8242 gLoc[0]=player[0].coords.x;
8243 gLoc[1]=player[0].coords.y;
8244 gLoc[2]=player[0].coords.z;
8245 vel[0]=player[0].velocity.x;
8246 vel[1]=player[0].velocity.y;
8247 vel[2]=player[0].velocity.z;
8248 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
8249 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8250 FSOUND_SetVolume(channels[whooshsound], 128);
8251 FSOUND_SetPaused(channels[whooshsound], FALSE);
8252 //FSOUND_SetPaused(channels[whooshsound], TRUE);
8254 texturesizetogglekeydown=1;
8257 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8260 float closestdist=-1;
8262 for(i=0;i<objects.numobjects;i++){
8263 if(objects.type[i]==treeleavestype){
8264 objects.scale[i]*=.9;
8267 texturesizetogglekeydown=1;
8270 static XYZ relative;
8271 static int randattack;
8273 static bool playerrealattackkeydown=0;
8275 if(!buttons[0])oldbutton=0;
8276 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8277 if(oldattackkey)player[0].attackkeydown=0;
8278 if(oldattackkey)playerrealattackkeydown=0;
8279 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8280 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);
8281 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8282 for(k=0;k<numplayers;k++){
8283 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8284 player[k].Reverse();
8288 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8290 for(k=0;k<numplayers;k++){
8291 if(indialogue!=-1)player[k].attackkeydown=0;
8292 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8293 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8294 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)){
8295 player[k].jumppower-=2;
8297 if(player[k].attackkeydown&&player[k].jumppower>1&&player[k].backkeydown&&player[k].targetanimation!=backhandspringanim&&(player[k].isIdle()||player[k].isStop()||player[k].isRun()||player[k].targetanimation==walkanim)){
8298 for(i=0;i<numplayers;i++){
8300 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8301 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8302 player[k].targetanimation=dodgebackanim;
8304 player[k].targetframe=0;
8305 rotatetarget=player[i].coords-player[k].coords;
8306 Normalise(&rotatetarget);
8307 player[k].targetrotation=-asin(0-rotatetarget.x);
8308 player[k].targetrotation*=360/6.28;
8309 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8311 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8314 if(player[k].targetanimation!=dodgebackanim){
8315 if(k==0)numflipped++;
8316 player[k].targetanimation=backhandspringanim;
8318 player[k].targetframe=0;
8319 player[k].targetrotation=-rotation+180;
8320 if(player[k].leftkeydown)player[k].targetrotation-=45;
8321 if(player[k].rightkeydown)player[k].targetrotation+=45;
8322 player[k].rotation=player[k].targetrotation;
8323 player[k].jumppower-=2;
8326 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())){
8327 player[k].hasvictim=0;
8329 for(i=0;i<numplayers;i++){
8331 if(!player[k].hasvictim)
8332 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8333 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){
8334 player[k].victim=&player[i];
8335 player[k].hasvictim=1;
8336 if(player[k].aitype==playercontrolled){
8337 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;
8338 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;
8339 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;
8340 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;
8341 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;
8342 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;
8343 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;
8344 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;
8345 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;
8346 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height==lowheight&&animation[player[k].targetanimation].attack!=normalattack)player[k].targetanimation=lowkickanim;
8349 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8350 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8351 else randattack=abs(Random()%5);
8352 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8353 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8354 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8355 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8356 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8358 if(player[k].weaponactive!=-1){
8359 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;
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*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[k].weaponmissdelay<=0)player[k].targetanimation=knifeslashstartanim;
8361 //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;
8362 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;
8363 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;
8364 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;
8365 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;
8366 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;
8370 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8372 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)){
8373 if(player[k].weaponactive==-1){
8374 player[i].targetanimation=sneakattackedanim;
8375 player[i].currentanimation=sneakattackedanim;
8376 player[k].currentanimation=sneakattackanim;
8377 player[k].targetanimation=sneakattackanim;
8378 player[k].oldcoords=player[k].coords;
8379 player[k].coords=player[i].coords;
8381 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8382 player[i].targetanimation=knifesneakattackedanim;
8383 player[i].currentanimation=knifesneakattackedanim;
8384 player[k].currentanimation=knifesneakattackanim;
8385 player[k].targetanimation=knifesneakattackanim;
8386 player[i].oldcoords=player[i].coords;
8387 player[i].coords=player[k].coords;
8389 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8390 player[i].targetanimation=swordsneakattackedanim;
8391 player[i].currentanimation=swordsneakattackedanim;
8392 player[k].currentanimation=swordsneakattackanim;
8393 player[k].targetanimation=swordsneakattackanim;
8394 player[i].oldcoords=player[i].coords;
8395 player[i].coords=player[k].coords;
8397 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8398 player[k].victim=&player[i];
8399 player[k].hasvictim=1;
8400 player[i].targettilt2=0;
8401 player[i].targetframe=1;
8402 player[i].currentframe=0;
8404 player[i].velocity=0;
8405 player[k].targettilt2=player[i].targettilt2;
8406 player[k].currentframe=player[i].currentframe;
8407 player[k].targetframe=player[i].targetframe;
8408 player[k].target=player[i].target;
8409 player[k].velocity=0;
8410 player[k].targetrotation=player[i].rotation;
8411 player[k].rotation=player[i].rotation;
8412 player[i].targetrotation=player[i].rotation;
8415 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8417 player[k].targetframe=0;
8419 //player[k].velocity=0;
8421 rotatetarget=player[i].coords-player[k].coords;
8422 Normalise(&rotatetarget);
8423 player[k].targetrotation=-asin(0-rotatetarget.x);
8424 player[k].targetrotation*=360/6.28;
8425 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8427 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8429 player[k].lastattack3=player[k].lastattack2;
8430 player[k].lastattack2=player[k].lastattack;
8431 player[k].lastattack=player[k].targetanimation;
8432 //player[k].targettilt2=0;
8436 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8437 rotatetarget=player[i].coords-player[k].coords;
8438 Normalise(&rotatetarget);
8439 player[k].targetrotation=-asin(0-rotatetarget.x);
8440 player[k].targetrotation*=360/6.28;
8441 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8442 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8444 player[k].victim=&player[i];
8445 player[k].hasvictim=1;
8446 player[i].targetanimation=knifefollowedanim;
8447 player[i].currentanimation=knifefollowedanim;
8448 player[i].targettilt2=0;
8449 player[i].targettilt2=player[k].targettilt2;
8450 player[i].targetframe=1;
8451 player[i].currentframe=0;
8453 player[i].velocity=0;
8454 player[k].currentanimation=knifefollowanim;
8455 player[k].targetanimation=knifefollowanim;
8456 player[k].targettilt2=player[i].targettilt2;
8457 player[k].currentframe=player[i].currentframe;
8458 player[k].targetframe=player[i].targetframe;
8459 player[k].target=player[i].target;
8460 player[k].velocity=0;
8461 player[k].oldcoords=player[k].coords;
8462 player[i].coords=player[k].coords;
8463 player[i].targetrotation=player[k].targetrotation;
8464 player[i].rotation=player[k].targetrotation;
8465 player[k].rotation=player[k].targetrotation;
8466 player[i].rotation=player[k].targetrotation;
8471 if(player[k].weaponactive!=-1){
8472 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8475 for(i=0;i<numplayers;i++){
8477 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8478 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8479 if(player[i].skeleton.free)
8480 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)))){
8481 player[k].victim=&player[i];
8482 player[k].hasvictim=1;
8483 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8484 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;
8485 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;
8486 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;
8488 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){
8489 player[k].targetanimation=killanim;
8490 for(j=0;j<terrain.numdecals;j++){
8491 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8492 terrain.DeleteDecal(j);
8495 for(l=0;l<objects.numobjects;l++){
8496 if(objects.model[l].type==decalstype)
8497 for(j=0;j<objects.model[l].numdecals;j++){
8498 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8499 objects.model[l].DeleteDecal(j);
8504 if(!player[i].dead||musictype!=2)
8505 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)){
8506 player[k].targetanimation=dropkickanim;
8507 for(j=0;j<terrain.numdecals;j++){
8508 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8509 terrain.DeleteDecal(j);
8512 for(l=0;l<objects.numobjects;l++){
8513 if(objects.model[l].type==decalstype)
8514 for(j=0;j<objects.model[l].numdecals;j++){
8515 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8516 objects.model[l].DeleteDecal(j);
8522 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)){
8524 player[k].targetframe=0;
8526 //player[k].velocity=0;
8528 rotatetarget=player[i].coords-player[k].coords;
8529 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8530 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;
8532 Normalise(&rotatetarget);
8533 player[k].targetrotation=-asin(0-rotatetarget.x);
8534 player[k].targetrotation*=360/6.28;
8535 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8537 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8538 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8541 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8542 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8544 player[k].lastattack3=player[k].lastattack2;
8545 player[k].lastattack2=player[k].lastattack;
8546 player[k].lastattack=player[k].targetanimation;
8548 if(player[k].targetanimation==swordgroundstabanim){
8549 player[k].targetrotation+=30;
8551 //player[k].targettilt2=0;
8557 if(!player[k].hasvictim){
8558 for(i=0;i<numplayers;i++){
8559 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8560 player[k].victim=&player[i];
8561 player[k].hasvictim=1;
8563 if(player[k].hasvictim&&!player[i].skeleton.free)
8564 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8565 player[k].victim=&player[i];
8569 if(player[k].aitype==playercontrolled)
8570 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)){
8572 player[k].targetanimation=rabbitkickanim;
8573 player[k].targetframe=0;
8576 if(animation[player[k].targetanimation].attack&&k==0){
8579 if(player[k].weaponactive!=-1){
8580 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8583 if(player[k].weaponactive!=-1){
8584 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8587 if(player[k].weaponactive!=-1){
8588 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8590 if(armedstaff)numstaffattack++;
8591 else if(armedsword)numswordattack++;
8592 else if(armedknife)numknifeattack++;
8593 else numunarmedattack++;
8600 static float collisionradius;
8602 for(k=0;k<numplayers;k++){
8603 for(i=k;i<numplayers;i++){
8606 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))
8607 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))
8608 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8609 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8610 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)
8611 if(player[i].coords.y>player[k].coords.y-3)
8612 if(player[i].coords.y<player[k].coords.y+3)
8613 if(player[i].coords.x>player[k].coords.x-3)
8614 if(player[i].coords.x<player[k].coords.x+3)
8615 if(player[i].coords.z>player[k].coords.z-3)
8616 if(player[i].coords.z<player[k].coords.z+3){
8617 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)){
8618 if(player[i].onfire||player[k].onfire){
8619 if(!player[i].onfire)player[i].CatchFire();
8620 if(!player[k].onfire)player[k].CatchFire();
8624 tempcoords1=player[i].coords;
8625 tempcoords2=player[k].coords;
8626 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8627 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8628 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8629 if(player[0].hasvictim)
8630 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8631 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8633 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)){
8634 player[k].coords.y=player[i].coords.y;
8635 player[i].velocity=player[k].velocity;
8636 player[i].skeleton.free=0;
8637 player[i].rotation=0;
8638 player[i].RagDoll(0);
8639 player[i].DoDamage(20);
8640 if(k==0)camerashake+=.3;
8641 player[i].skeleton.longdead=0;
8642 player[k].lastcollide=1;
8645 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)){
8646 player[i].coords.y=player[k].coords.y;
8647 player[k].velocity=player[i].velocity;
8648 player[k].skeleton.free=0;
8649 player[k].rotation=0;
8650 player[k].RagDoll(0);
8651 player[k].DoDamage(20);
8652 if(i==0)camerashake+=.3;
8653 player[k].skeleton.longdead=0;
8654 player[i].lastcollide=1;
8657 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)){
8658 rotatetarget=player[k].velocity-player[i].velocity;
8659 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))
8660 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))){
8662 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)){
8663 static float gLoc[3];
8664 static float vel[3];
8665 gLoc[0]=player[i].coords.x;
8666 gLoc[1]=player[i].coords.y;
8667 gLoc[2]=player[i].coords.z;
8668 vel[0]=player[i].velocity.x;
8669 vel[1]=player[i].velocity.y;
8670 vel[2]=player[i].velocity.z;
8671 if(tutoriallevel!=1){
8672 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
8673 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8674 FSOUND_SetVolume(channels[heavyimpactsound], 256);
8675 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
8677 //player[i].velocity=player[k].velocity;
8678 //player[k].velocity=player[i].velocity;
8680 player[i].RagDoll(0);
8681 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8686 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8687 player[k].RagDoll(0);
8688 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8693 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8695 //if(player[i].skeleton.oldfree){
8696 for(j=0;j<player[i].skeleton.num_joints;j++){
8697 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8700 //if(player[k].skeleton.oldfree){
8701 for(j=0;j<player[k].skeleton.num_joints;j++){
8702 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8708 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)){
8710 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8711 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)){
8712 rotatetarget=player[k].coords-player[i].coords;
8713 Normalise(&rotatetarget);
8714 player[k].coords=(player[k].coords+player[i].coords)/2;
8715 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);
8716 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8717 if(player[k].howactive==typeactive||hostile)
8718 if(player[k].isIdle()){
8719 if(player[k].howactive<typesleeping){
8720 player[k].targetanimation=player[k].getStop();
8721 player[k].targetframe=0;
8724 else if(player[k].howactive==typesleeping)
8726 player[k].targetanimation=getupfromfrontanim;
8727 player[k].targetframe=0;
8730 if(!editorenabled)player[k].howactive=typeactive;
8732 if(player[i].howactive==typeactive||hostile)
8733 if(player[i].isIdle()){
8734 if(player[i].howactive<typesleeping){
8735 player[i].targetanimation=player[i].getStop();
8736 player[i].targetframe=0;
8741 player[i].targetanimation=getupfromfrontanim;
8742 player[i].targetframe=0;
8745 if(!editorenabled)player[i].howactive=typeactive;
8749 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){
8750 player[i].velocity=player[k].velocity;
8751 player[k].velocity=player[k].velocity*-.5;
8752 //player[i].velocity.y-=10;
8753 player[k].velocity.y=player[i].velocity.y;
8754 player[i].DoDamage(20);
8755 player[i].RagDoll(0);
8756 player[k].lastcollide=1;
8763 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){
8764 player[k].velocity=player[i].velocity;
8765 player[i].velocity=player[i].velocity*-.3;
8766 //player[k].velocity.y-=10;
8767 player[i].velocity.y=player[k].velocity.y;
8768 player[k].DoDamage(20);
8769 player[k].RagDoll(0);
8770 player[i].lastcollide=1;
8781 player[i].CheckKick();
8782 player[k].CheckKick();
8788 for(k=0;k<numplayers;k++){
8789 for(i=k;i<numplayers;i++){
8791 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))){
8792 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)){
8793 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)){
8794 player[i].victim=&player[k];
8795 player[i].targetanimation=jumpreversedanim;
8796 player[i].currentanimation=jumpreversedanim;
8797 player[k].currentanimation=jumpreversalanim;
8798 player[k].targetanimation=jumpreversalanim;
8799 player[i].targettilt2=0;
8800 player[i].currentframe=0;
8801 player[i].targetframe=1;
8802 player[k].currentframe=0;
8803 player[k].targetframe=1;
8804 if(player[i].coords.y<player[k].coords.y+1){
8805 player[i].targetanimation=rabbitkickreversedanim;
8806 player[i].currentanimation=rabbitkickreversedanim;
8807 player[k].currentanimation=rabbitkickreversalanim;
8808 player[k].targetanimation=rabbitkickreversalanim;
8809 player[k].currentframe=1;
8810 player[k].targetframe=2;
8811 player[i].currentframe=1;
8812 player[i].targetframe=2;
8814 player[k].targettilt2=0;
8816 player[i].velocity=0;
8817 player[k].velocity=0;
8818 player[k].oldcoords=player[k].coords;
8819 player[i].coords=player[k].coords;
8820 player[k].targetrotation=player[i].targetrotation;
8821 player[k].rotation=player[i].targetrotation;
8822 player[k].victim=&player[i];
8823 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8825 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)){
8826 player[k].victim=&player[i];
8827 player[k].targetanimation=jumpreversedanim;
8828 player[k].currentanimation=jumpreversedanim;
8829 player[i].currentanimation=jumpreversalanim;
8830 player[i].targetanimation=jumpreversalanim;
8831 player[k].targettilt2=0;
8832 player[i].targettilt2=0;
8833 player[k].currentframe=0;
8834 player[k].targetframe=1;
8835 player[i].currentframe=0;
8836 player[i].targetframe=1;
8837 if(player[k].coords.y<player[i].coords.y+1){
8838 player[k].targetanimation=rabbitkickreversedanim;
8839 player[k].currentanimation=rabbitkickreversedanim;
8840 player[i].currentanimation=rabbitkickreversalanim;
8841 player[i].targetanimation=rabbitkickreversalanim;
8842 player[k].currentframe=1;
8843 player[k].targetframe=2;
8844 player[i].currentframe=1;
8845 player[i].targetframe=2;
8848 player[k].velocity=0;
8849 player[i].velocity=0;
8850 player[i].oldcoords=player[i].coords;
8851 player[k].coords=player[i].coords;
8852 player[i].targetrotation=player[k].targetrotation;
8853 player[i].rotation=player[k].targetrotation;
8854 player[i].victim=&player[k];
8855 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8862 for(k=0;k<numplayers;k++)
8863 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8872 static float checkdelay;
8873 checkdelay-=multiplier;
8875 static bool checkedcoll[maxplayers][maxplayers];
8876 static bool above[maxplayers];
8878 for(i=0;i<maxplayers;i++){
8879 for(j=0;j<maxplayers;j++){
8880 checkedcoll[i][j]=0;
8884 if(numplayers>1&&checkdelay<=0){
8886 for(k=0;k<numplayers;k++){
8887 if(player[k].skeleton.free!=2)above[k]=-1;
8889 for(i=k;i<numplayers;i++){
8892 if(!checkedcoll[i][k]){
8893 checkedcoll[i][k]=1;
8894 checkedcoll[k][i]=1;
8895 if(player[i].skeleton.free&&player[k].skeleton.free)
8896 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8897 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8898 if(player[i].coords.y>player[k].coords.y-3)
8899 if(player[i].coords.y<player[k].coords.y+3)
8900 if(player[i].coords.x>player[k].coords.x-3)
8901 if(player[i].coords.x<player[k].coords.x+3)
8902 if(player[i].coords.z>player[k].coords.z-3)
8903 if(player[i].coords.z<player[k].coords.z+3)
8904 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)){
8906 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8918 above[moving]=stuck;
8919 for(l=0;l<player[moving].skeleton.num_joints;l++){
8920 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8921 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8923 player[moving].skeleton.joints[l].position.y+=.003;
8924 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8938 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8939 texturesizetogglekeydown=0;
8942 for(k=0;k<numplayers;k++){
8943 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8944 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8945 player[k].DoDamage(1000);
8950 static bool respawnkeydown;
8951 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8952 targetlevel=whichlevel;
8956 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8957 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8962 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8964 if(targetlevel>numchallengelevels-1)targetlevel=0;
8967 slomotogglekeydown=1;
8971 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8973 FSOUND_SetPaused(channels[whooshsound], TRUE);
8975 for(k=0;k<numplayers;k++){
8978 player[k].permanentdamage=0;
8979 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8980 player[k].aitype=passivetype;
8982 player[0].aitype=playercontrolled;
8986 static bool movekey;
8987 static bool connected;
8988 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8989 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8990 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8991 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8992 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8993 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8995 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
8997 for(int i=0;i<numplayers;i++){
8998 if(!player[i].skeleton.free){
8999 oldtargetrotation=player[i].targetrotation;
9000 if(i==0&&indialogue==-1){
9001 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){
9002 if(!cameramode)player[0].targetrotation=-rotation+180;
9003 if(cameramode)player[0].targetrotation=0;
9009 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9010 if(cameramode){facing=flatfacing;}
9012 facing=DoRotation(facing,-rotation2,0,0);
9013 facing=DoRotation(facing,0,0-rotation,0);
9016 player[0].lookrotation=-rotation;
9018 player[i].targetheadrotation=rotation;
9019 player[i].targetheadrotation2=rotation2;
9021 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9022 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){
9023 player[i].targetrotation=-player[i].lookrotation+180;
9029 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9031 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9032 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9034 player[i].targetheadrotation=player[i].lookrotation;
9035 player[i].targetheadrotation2=player[i].lookrotation2;
9038 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9039 Normalise(&rotatetarget);
9040 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9041 player[i].targetheadrotation*=360/6.28;
9042 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9044 player[i].targetheadrotation*=-1;
9045 player[i].targetheadrotation+=180;
9046 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9054 player[i].avoidsomething=0;
9056 for(j=0;j<objects.numobjects;j++){
9057 if(objects.onfire[j]){
9058 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9060 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9061 player[i].collided=0;
9062 player[i].avoidcollided=1;
9063 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9064 player[i].avoidwhere=objects.position[j];
9070 //Add avoidwhere to players
9072 for(j=0;j<numplayers;j++){
9073 if(player[j].onfire){
9074 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9076 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9077 player[i].collided=0;
9078 player[i].avoidcollided=1;
9079 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9080 player[i].avoidwhere=objects.position[j];
9086 if(player[i].collided>.8)player[i].avoidcollided=0;
9087 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9088 player[i].jumpclimb=0;
9090 if(editorenabled)player[i].stunned=1;
9093 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9094 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;
9096 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9097 player[i].forwardkeydown=0;
9098 player[i].leftkeydown=0;
9099 player[i].backkeydown=0;
9100 player[i].rightkeydown=0;
9101 player[i].crouchkeydown=0;
9102 player[i].attackkeydown=0;
9103 player[i].jumpkeydown=0;
9104 player[i].throwkeydown=0;
9107 if(player[i].aitype==pathfindtype){
9108 if(player[i].finalpathfindpoint==-1){
9109 float closestdistance;
9115 for(j=0;j<numpathpoints;j++){
9116 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9117 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9119 player[i].finaltarget=pathpoint[j];
9122 player[i].finalpathfindpoint=closest;
9123 for(j=0;j<numpathpoints;j++){
9124 if(numpathpointconnect[j])
9125 for(k=0;k<numpathpointconnect[j];k++){
9126 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9127 if(tempdist*tempdist<closestdistance){
9128 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9129 closestdistance=tempdist*tempdist;
9131 player[i].finaltarget=colpoint;
9136 player[i].finalpathfindpoint=closest;
9139 if(player[i].targetpathfindpoint==-1){
9140 float closestdistance;
9146 if(player[i].lastpathfindpoint==-1){
9147 for(j=0;j<numpathpoints;j++){
9148 if(j!=player[i].lastpathfindpoint)
9149 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9150 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9154 player[i].targetpathfindpoint=closest;
9155 for(j=0;j<numpathpoints;j++){
9156 if(j!=player[i].lastpathfindpoint)
9157 if(numpathpointconnect[j])
9158 for(k=0;k<numpathpointconnect[j];k++){
9159 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9160 if(tempdist*tempdist<closestdistance){
9161 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9162 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9163 closestdistance=tempdist*tempdist;
9170 player[i].targetpathfindpoint=closest;
9174 for(j=0;j<numpathpoints;j++){
9175 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9178 if(numpathpointconnect[j])
9179 for(k=0;k<numpathpointconnect[j];k++){
9180 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9183 if(numpathpointconnect[player[i].lastpathfindpoint])
9184 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9185 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9188 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9189 if(closest==-1||tempdist<closestdistance){
9190 closestdistance=tempdist;
9196 player[i].targetpathfindpoint=closest;
9199 player[i].losupdatedelay-=multiplier;
9201 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9202 Normalise(&rotatetarget);
9203 player[i].targetrotation=-asin(0-rotatetarget.x);
9204 player[i].targetrotation*=360/6.28;
9205 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9206 player[i].lookrotation=player[i].targetrotation;
9207 //player[i].aiupdatedelay=.05;
9209 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9210 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9211 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9212 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9213 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9214 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9215 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9216 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9217 player[i].targetpathfindpoint=-1;
9219 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){
9220 player[i].aitype=passivetype;
9223 player[i].forwardkeydown=1;
9224 player[i].leftkeydown=0;
9225 player[i].backkeydown=0;
9226 player[i].rightkeydown=0;
9227 player[i].crouchkeydown=0;
9228 player[i].attackkeydown=0;
9229 player[i].throwkeydown=0;
9231 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9233 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9234 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9236 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9237 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))
9238 player[i].aitype=attacktypecutoff;
9239 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9240 player[i].aitype=attacktypecutoff;
9242 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9243 player[i].losupdatedelay=.2;
9244 for(j=0;j<numplayers;j++){
9245 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9246 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9247 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9248 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9249 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9250 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)){
9251 player[i].aitype=searchtype;
9252 player[i].lastchecktime=12;
9253 player[i].lastseen=player[j].coords;
9254 player[i].lastseentime=12;
9260 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9261 if(player[i].creature!=wolftype){
9262 player[i].stunned=.6;
9263 player[i].surprised=.6;
9268 if(player[i].aitype!=passivetype&&leveltime>.5){
9269 player[i].howactive=typeactive;
9272 if(player[i].aitype==passivetype){
9273 player[i].aiupdatedelay-=multiplier;
9274 player[i].losupdatedelay-=multiplier;
9275 player[i].lastseentime+=multiplier;
9276 player[i].pausetime-=multiplier;
9277 if(player[i].lastseentime>1)player[i].lastseentime=1;
9279 if(player[i].aiupdatedelay<0){
9280 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9281 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9282 Normalise(&rotatetarget);
9283 player[i].targetrotation=-asin(0-rotatetarget.x);
9284 player[i].targetrotation*=360/6.28;
9285 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9286 player[i].lookrotation=player[i].targetrotation;
9287 player[i].aiupdatedelay=.05;
9289 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9290 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9291 player[i].waypoint++;
9292 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9297 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9298 else player[i].forwardkeydown=0;
9299 player[i].leftkeydown=0;
9300 player[i].backkeydown=0;
9301 player[i].rightkeydown=0;
9302 player[i].crouchkeydown=0;
9303 player[i].attackkeydown=0;
9304 player[i].throwkeydown=0;
9306 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9307 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9309 XYZ leftpos,rightpos;
9310 float leftdist,rightdist;
9311 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9312 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9313 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9314 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9315 if(leftdist<rightdist)player[i].targetrotation+=90;
9316 else player[i].targetrotation-=90;
9320 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9321 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9325 if(player[i].howactive<typesleeping)
9326 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9327 for(j=0;j<numenvsounds;j++){
9328 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9329 player[i].aitype=attacktypecutoff;
9333 if(player[i].howactive==typesleeping)
9334 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9335 for(j=0;j<numenvsounds;j++){
9336 if(envsoundvol[j]>14)
9337 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9338 player[i].aitype=attacktypecutoff;
9342 if(player[i].aitype!=passivetype){
9343 if(player[i].howactive==typesleeping){
9344 player[i].targetanimation=getupfromfrontanim;
9345 player[i].targetframe=0;
9349 player[i].howactive=typeactive;
9353 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9354 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9355 player[i].aitype=attacktypecutoff;
9356 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9357 player[i].aitype=attacktypecutoff;
9359 if(player[i].creature==wolftype){
9361 float smelldistance;
9363 for(j=0;j<numplayers;j++){
9364 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9365 if(j==0&&player[j].num_weapons>0){
9366 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9367 if(player[j].num_weapons==2)
9368 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9373 windsmell=windvector;
9374 Normalise(&windsmell);
9375 windsmell=windsmell*2+player[j].coords;
9376 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9377 player[i].aitype=attacktypecutoff;
9382 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9383 player[i].losupdatedelay=.2;
9384 for(j=0;j<numplayers;j++){
9385 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9386 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9387 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9388 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9389 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)){
9390 player[i].lastseentime-=.2;
9391 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9392 else player[i].lastseentime-=.6;
9394 if(player[i].lastseentime<=0){
9395 player[i].aitype=searchtype;
9396 player[i].lastchecktime=12;
9397 player[i].lastseen=player[j].coords;
9398 player[i].lastseentime=12;
9404 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9405 if(player[i].creature!=wolftype){
9406 player[i].stunned=.6;
9407 player[i].surprised=.6;
9409 if(player[i].creature==wolftype){
9410 player[i].stunned=.47;
9411 player[i].surprised=.47;
9417 if(player[i].aitype==searchtype){
9418 player[i].aiupdatedelay-=multiplier;
9419 player[i].losupdatedelay-=multiplier;
9420 if(!player[i].pause)player[i].lastseentime-=multiplier;
9421 player[i].lastchecktime-=multiplier;
9423 if(player[i].isRun()&&!player[i].onground){
9424 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9425 test2=player[i].coords+player[i].facing;
9427 test=player[i].coords+player[i].facing;
9429 j=checkcollide(test2,test,player[i].laststanding);
9430 if(j==-1)j=checkcollide(test2,test);
9432 player[i].velocity=0;
9433 player[i].targetanimation=player[i].getStop();
9434 player[i].targetframe=0;
9436 player[i].targetrotation+=180;
9437 player[i].stunned=.5;
9438 //player[i].aitype=passivetype;
9439 player[i].aitype=pathfindtype;
9440 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9441 player[i].finalpathfindpoint=-1;
9442 player[i].targetpathfindpoint=-1;
9443 player[i].lastpathfindpoint=-1;
9444 player[i].lastpathfindpoint2=-1;
9445 player[i].lastpathfindpoint3=-1;
9446 player[i].lastpathfindpoint4=-1;
9448 else player[i].laststanding=j;
9451 if(player[i].aiupdatedelay<0){
9452 rotatetarget=player[i].lastseen-player[i].coords;
9453 Normalise(&rotatetarget);
9454 player[i].targetrotation=-asin(0-rotatetarget.x);
9455 player[i].targetrotation*=360/6.28;
9456 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9457 player[i].lookrotation=player[i].targetrotation;
9458 player[i].aiupdatedelay=.05;
9459 player[i].forwardkeydown=1;
9461 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9462 player[i].forwardkeydown=0;
9463 player[i].aiupdatedelay=1;
9464 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9465 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9466 player[i].lastchecktime=3;
9469 player[i].leftkeydown=0;
9470 player[i].backkeydown=0;
9471 player[i].rightkeydown=0;
9472 player[i].crouchkeydown=0;
9473 player[i].attackkeydown=0;
9474 player[i].throwkeydown=0;
9476 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9477 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9479 XYZ leftpos,rightpos;
9480 float leftdist,rightdist;
9481 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9482 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9483 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9484 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9485 if(leftdist<rightdist)player[i].targetrotation+=90;
9486 else player[i].targetrotation-=90;
9490 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9491 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9493 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9494 for(j=0;j<numenvsounds;j++){
9495 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9496 player[i].aitype=attacktypecutoff;
9500 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9501 player[i].losupdatedelay=.2;
9502 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9503 {player[i].aitype=attacktypecutoff;
9504 player[i].lastseentime=1;}
9505 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9506 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9507 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9508 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)){
9509 player[i].aitype=attacktypecutoff;
9510 player[i].lastseentime=1;
9513 if(player[i].lastseentime<0){
9514 //player[i].aitype=passivetype;
9516 player[i].aitype=pathfindtype;
9517 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9518 player[i].finalpathfindpoint=-1;
9519 player[i].targetpathfindpoint=-1;
9520 player[i].lastpathfindpoint=-1;
9521 player[i].lastpathfindpoint2=-1;
9522 player[i].lastpathfindpoint3=-1;
9523 player[i].lastpathfindpoint4=-1;
9527 if(player[i].aitype!=gethelptype){
9528 player[i].runninghowlong=0;
9531 if(player[i].aitype==gethelptype){
9532 player[i].runninghowlong+=multiplier;
9533 player[i].aiupdatedelay-=multiplier;
9535 if(player[i].aiupdatedelay<0||player[i].ally==0){
9536 player[i].aiupdatedelay=.2;
9544 if(!player[i].ally){
9545 for(j=0;j<numplayers;j++){
9546 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9547 distance=findDistancefast(&player[i].coords,&player[j].coords);
9548 if(closestdist==-1||distance<closestdist){
9549 closestdist=distance;
9555 if(closest!=-1)player[i].ally=closest;
9556 else player[i].ally=0;
9557 player[i].lastseen=player[0].coords;
9558 player[i].lastseentime=12;
9562 player[i].lastchecktime=12;
9563 //player[i].lastseentime-=.5;
9565 facing=player[i].coords;
9566 flatfacing=player[player[i].ally].coords;
9567 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9568 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9569 if(-1!=checkcollide(facing,flatfacing))
9570 player[i].lastseentime-=.1;
9572 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9573 player[i].aitype=searchtype;
9574 player[i].lastseentime=12;
9577 if(player[i].ally>0){
9578 rotatetarget=player[player[i].ally].coords-player[i].coords;
9579 Normalise(&rotatetarget);
9580 player[i].targetrotation=-asin(0-rotatetarget.x);
9581 player[i].targetrotation*=360/6.28;
9582 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9583 player[i].lookrotation=player[i].targetrotation;
9584 player[i].aiupdatedelay=.05;
9585 player[i].forwardkeydown=1;
9587 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9588 player[i].aitype=searchtype;
9589 player[i].lastseentime=12;
9590 player[player[i].ally].aitype=searchtype;
9591 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9592 player[player[i].ally].lastseen=player[i].lastseen;
9593 player[player[i].ally].lastseentime=player[i].lastseentime;
9594 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9598 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9599 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9601 XYZ leftpos,rightpos;
9602 float leftdist,rightdist;
9603 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9604 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9605 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9606 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9607 if(leftdist<rightdist)player[i].targetrotation+=90;
9608 else player[i].targetrotation-=90;
9613 player[i].leftkeydown=0;
9614 player[i].backkeydown=0;
9615 player[i].rightkeydown=0;
9616 player[i].crouchkeydown=0;
9617 player[i].attackkeydown=0;
9619 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9620 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9623 if(player[i].aitype==getweapontype){
9624 player[i].aiupdatedelay-=multiplier;
9625 player[i].lastchecktime-=multiplier;
9627 if(player[i].aiupdatedelay<0){
9628 player[i].aiupdatedelay=.2;
9636 if(player[i].ally<0){
9637 for(j=0;j<weapons.numweapons;j++){
9638 if(weapons.owner[j]==-1){
9639 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9640 if(closestdist==-1||distance<closestdist){
9641 closestdist=distance;
9647 if(closest!=-1)player[i].ally=closest;
9648 else player[i].ally=-1;
9651 player[i].lastseentime=12;
9653 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9654 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9655 player[i].aitype=attacktypecutoff;
9656 player[i].lastseentime=1;
9659 if(player[i].ally>=0){
9660 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9661 player[i].aitype=attacktypecutoff;
9662 player[i].lastseentime=1;
9664 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9665 Normalise(&rotatetarget);
9666 player[i].targetrotation=-asin(0-rotatetarget.x);
9667 player[i].targetrotation*=360/6.28;
9668 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9669 player[i].lookrotation=player[i].targetrotation;
9670 player[i].aiupdatedelay=.05;
9671 player[i].forwardkeydown=1;
9674 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9675 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9677 XYZ leftpos,rightpos;
9678 float leftdist,rightdist;
9679 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9680 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9681 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9682 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9683 if(leftdist<rightdist)player[i].targetrotation+=90;
9684 else player[i].targetrotation-=90;
9687 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9688 if(abs(Random()%6)){
9689 player[i].crouchkeydown=1;
9690 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9691 if(player[i].isRun()){
9692 player[i].targetframe=0;
9694 player[i].targetanimation=sneakanim;
9697 else player[i].forwardkeydown=0;
9699 else player[i].crouchkeydown=0;
9701 else player[i].crouchkeydown=0;*/
9704 player[i].leftkeydown=0;
9705 player[i].backkeydown=0;
9706 player[i].rightkeydown=0;
9707 player[i].attackkeydown=0;
9708 player[i].throwkeydown=1;
9709 player[i].crouchkeydown=0;
9710 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9711 player[i].drawkeydown=0;
9713 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9714 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9717 if(player[i].aitype==attacktypecutoff){
9718 player[i].aiupdatedelay-=multiplier;
9719 if(player[i].damage<player[i].damagetolerance*2/3)
9720 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)){
9721 player[i].attackkeydown=0;
9722 if(player[i].isIdle())player[i].crouchkeydown=1;
9723 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9724 if(weapons.type[player[0].weaponids[0]]==knife){
9725 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9726 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9727 else player[i].targetanimation=rollanim;
9729 player[i].targetframe=0;
9730 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9731 player[i].wentforweapon=0;
9733 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9734 player[i].targetanimation=flipanim;
9736 player[i].targetframe=0;
9740 player[i].forwardkeydown=0;
9741 player[i].aiupdatedelay=.02;
9743 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9744 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9745 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9747 if(player[i].wentforweapon<3)
9748 for(j=0;j<weapons.numweapons;j++){
9749 if(player[i].creature!=wolftype)
9750 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){
9751 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9752 player[i].wentforweapon++;
9753 player[i].lastchecktime=6;
9754 player[i].aitype=getweapontype;
9759 if(player[i].damage<player[i].damagetolerance/2)
9760 if(animation[player[i].targetanimation].height!=highheight)
9761 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)))){
9762 player[i].crouchkeydown=1;
9764 if(player[i].isRun()&&!player[i].onground){
9765 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9766 test2=player[i].coords+player[i].facing;
9768 test=player[i].coords+player[i].facing;
9770 j=checkcollide(test2,test,player[i].laststanding);
9771 if(j==-1)j=checkcollide(test2,test);
9773 player[i].velocity=0;
9774 player[i].targetanimation=player[i].getStop();
9775 player[i].targetframe=0;
9777 player[i].targetrotation+=180;
9778 player[i].stunned=.5;
9779 //player[i].aitype=passivetype;
9780 player[i].aitype=pathfindtype;
9781 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9782 player[i].finalpathfindpoint=-1;
9783 player[i].targetpathfindpoint=-1;
9784 player[i].lastpathfindpoint=-1;
9785 player[i].lastpathfindpoint2=-1;
9786 player[i].lastpathfindpoint3=-1;
9787 player[i].lastpathfindpoint4=-1;
9789 else player[i].laststanding=j;
9792 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9793 player[i].aitype=pathfindtype;
9794 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9795 player[i].finalpathfindpoint=-1;
9796 player[i].targetpathfindpoint=-1;
9797 player[i].lastpathfindpoint=-1;
9798 player[i].lastpathfindpoint2=-1;
9799 player[i].lastpathfindpoint3=-1;
9800 player[i].lastpathfindpoint4=-1;
9802 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){
9803 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9804 else player[i].drawkeydown=0;
9805 player[i].rabbitkickenabled=Random()%2;
9806 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9807 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9808 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;
9809 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9810 Normalise(&rotatetarget);
9811 player[i].targetrotation=-asin(0-rotatetarget.x);
9812 player[i].targetrotation*=360/6.28;
9813 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9814 player[i].lookrotation=player[i].targetrotation;
9815 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9817 oldkey=player[i].forwardkeydown;
9818 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9819 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;
9820 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9821 else player[i].forwardkeydown=0;
9823 player[i].forwardkeydown=0;
9824 if(Random()%10==0)player[i].forwardkeydown=1;
9825 if(Random()%100==0){
9826 player[i].aitype=pathfindtype;
9827 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9828 player[i].finalpathfindpoint=-1;
9829 player[i].targetpathfindpoint=-1;
9830 player[i].lastpathfindpoint=-1;
9831 player[i].lastpathfindpoint2=-1;
9832 player[i].lastpathfindpoint3=-1;
9833 player[i].lastpathfindpoint4=-1;
9836 player[i].leftkeydown=0;
9837 player[i].backkeydown=0;
9838 player[i].rightkeydown=0;
9839 player[i].crouchkeydown=0;
9840 player[i].throwkeydown=0;
9842 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9843 /*for(j=0;j<numplayers;j++){
9844 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9845 player[i].crouchkeydown=1;
9848 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9849 else player[i].attackkeydown=0;
9850 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9851 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9852 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9853 player[i].attackkeydown=0;
9854 if(player[i].isIdle())player[i].crouchkeydown=1;
9855 player[i].forwardkeydown=0;
9856 player[i].aiupdatedelay=.02;
9859 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9861 for(j=0;j<numplayers;j++){
9862 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)){
9863 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))))){
9864 if(target>=0)target=-1;
9869 if(target>=0)player[target].Reverse();
9872 if(player[i].collided<1)player[i].jumpkeydown=0;
9873 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;
9874 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9875 player[0].jumpkeydown=0;
9876 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9877 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9878 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9880 if(tutoriallevel==1){
9881 if(!canattack)player[i].attackkeydown=0;
9885 facing=player[i].coords;
9886 flatfacing=player[0].coords;
9887 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9888 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9889 if(player[i].occluded>=2)
9890 if(-1!=checkcollide(facing,flatfacing)){
9891 if(!player[i].pause)player[i].lastseentime-=.2;
9892 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9893 player[i].aitype=searchtype;
9894 player[i].lastchecktime=12;
9895 player[i].lastseen=player[0].coords;
9896 player[i].lastseentime=12;
9899 else player[i].lastseentime=1;
9902 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9903 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9904 test=player[0].coords;
9906 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9909 // NOTE: Ask about logic of this call : NOTE
9910 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9911 player[i].stunned>0 ||
9912 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9914 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9915 player[i].targetrotation=player[i].rotation;
9916 player[i].forwardkeydown=0;
9917 player[i].leftkeydown=0;
9918 player[i].backkeydown=0;
9919 player[i].rightkeydown=0;
9920 player[i].jumpkeydown=0;
9921 player[i].attackkeydown=0;
9922 player[i].crouchkeydown=0;
9923 player[i].throwkeydown=0;
9930 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9933 if(player[i].aitype==attacktypecutoff){
9934 rotatetarget=player[0].coords-player[i].coords;
9935 Normalise(&rotatetarget);
9936 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9937 player[i].targetheadrotation*=360/6.28;
9938 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9940 player[i].targetheadrotation*=-1;
9941 player[i].targetheadrotation+=180;
9942 //player[i].targetheadrotation2=0;
9943 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9945 else if(player[i].howactive>=typesleeping){
9946 player[i].targetheadrotation=player[i].targetrotation;
9947 player[i].targetheadrotation2=0;
9950 if(player[i].interestdelay<=0){
9951 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9952 player[i].headtarget=player[i].coords;
9953 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9954 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9955 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9956 player[i].headtarget+=player[i].facing*1.5;
9958 rotatetarget=player[i].headtarget-player[i].coords;
9959 Normalise(&rotatetarget);
9960 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9961 player[i].targetheadrotation*=360/6.28;
9962 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9964 player[i].targetheadrotation*=-1;
9965 player[i].targetheadrotation+=180;
9966 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9968 //if(whichlevel==2)player[i].jumpkeydown=0;
9970 if(animation[player[i].targetanimation].attack==reversed){
9971 //player[i].targetrotation=player[i].rotation;
9972 player[i].forwardkeydown=0;
9973 player[i].leftkeydown=0;
9974 player[i].backkeydown=0;
9975 player[i].rightkeydown=0;
9976 player[i].jumpkeydown=0;
9977 player[i].attackkeydown=0;
9978 //player[i].crouchkeydown=0;
9979 player[i].throwkeydown=0;
9983 player[i].forwardkeydown=0;
9984 player[i].leftkeydown=0;
9985 player[i].backkeydown=0;
9986 player[i].rightkeydown=0;
9987 player[i].jumpkeydown=0;
9988 player[i].crouchkeydown=0;
9989 player[i].drawkeydown=0;
9990 player[i].throwkeydown=0;
9993 if(player[i].collided<-.3)player[i].collided=-.3;
9994 if(player[i].collided>1)player[i].collided=1;
9995 player[i].collided-=multiplier*4;
9996 player[i].whichdirectiondelay-=multiplier;
9997 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
9998 player[i].avoidcollided=-.3;
9999 player[i].whichdirection=abs(Random()%2);
10000 player[i].whichdirectiondelay=.4;
10002 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10003 player[i].avoidcollided-=multiplier/4;
10004 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10005 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10006 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;
10008 if(!player[i].throwkeydown){
10009 player[i].throwtogglekeydown=0;
10011 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10012 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)){
10013 for(j=0;j<weapons.numweapons;j++){
10014 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)
10015 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10016 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10017 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10018 player[i].throwtogglekeydown=1;
10019 player[i].targetanimation=crouchremoveknifeanim;
10020 player[i].target=0;
10021 player[i].targetframe=0;
10022 rotatetarget=weapons.position[j]-player[i].coords;
10023 Normalise(&rotatetarget);
10024 player[i].targetrotation=-asin(0-rotatetarget.x);
10025 player[i].targetrotation*=360/6.28;
10026 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10027 player[i].hasvictim=0;
10029 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10030 player[i].throwtogglekeydown=1;
10031 player[i].hasvictim=0;
10033 //for(i=0;i<weapons.numweapons;i++){
10034 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))
10035 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10036 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10039 gLoc[0]=player[i].coords.x;
10040 gLoc[1]=player[i].coords.y;
10041 gLoc[2]=player[i].coords.z;
10042 vel[0]=player[i].velocity.x;
10043 vel[1]=player[i].velocity.y;
10044 vel[2]=player[i].velocity.z;
10045 if(weapons.type[j]!=staff){
10046 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10047 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10048 FSOUND_SetVolume(channels[knifedrawsound], 128);
10049 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10052 player[i].weaponactive=0;
10053 weapons.owner[j]=player[i].id;
10054 if(player[i].num_weapons>0){
10055 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10057 player[i].num_weapons++;
10058 player[i].weaponids[0]=j;
10064 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){
10065 if(!player[i].isFlip()){
10066 player[i].throwtogglekeydown=1;
10067 player[i].targetanimation=removeknifeanim;
10068 player[i].target=0;
10069 player[i].targetframe=0;
10070 rotatetarget=weapons.position[j]-player[i].coords;
10071 Normalise(&rotatetarget);
10072 player[i].targetrotation=-asin(0-rotatetarget.x);
10073 player[i].targetrotation*=360/6.28;
10074 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10076 if(player[i].isFlip()){
10077 player[i].throwtogglekeydown=1;
10078 player[i].hasvictim=0;
10080 for(k=0;k<weapons.numweapons;k++){
10081 if(player[i].weaponactive==-1)
10082 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))
10083 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10086 gLoc[0]=player[i].coords.x;
10087 gLoc[1]=player[i].coords.y;
10088 gLoc[2]=player[i].coords.z;
10089 vel[0]=player[i].velocity.x;
10090 vel[1]=player[i].velocity.y;
10091 vel[2]=player[i].velocity.z;
10092 if(weapons.type[k]!=staff){
10093 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10094 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10095 FSOUND_SetVolume(channels[knifedrawsound], 128);
10096 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10099 player[i].weaponactive=0;
10100 weapons.owner[k]=player[i].id;
10101 if(player[i].num_weapons>0){
10102 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10104 player[i].num_weapons++;
10105 player[i].weaponids[0]=k;
10112 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10114 for(j=0;j<numplayers;j++){
10115 if(player[i].weaponactive==-1)
10117 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)){
10118 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10119 player[i].throwtogglekeydown=1;
10120 player[i].victim=&player[j];
10121 player[i].hasvictim=1;
10122 player[i].targetanimation=crouchremoveknifeanim;
10123 player[i].target=0;
10124 player[i].targetframe=0;
10125 rotatetarget=player[j].coords-player[i].coords;
10126 Normalise(&rotatetarget);
10127 player[i].targetrotation=-asin(0-rotatetarget.x);
10128 player[i].targetrotation*=360/6.28;
10129 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10131 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10132 player[i].throwtogglekeydown=1;
10133 player[i].victim=&player[j];
10134 player[i].hasvictim=1;
10135 int k = player[j].weaponids[0];
10136 if(player[i].hasvictim){
10139 gLoc[0]=player[i].coords.x;
10140 gLoc[1]=player[i].coords.y;
10141 gLoc[2]=player[i].coords.z;
10142 vel[0]=player[i].velocity.x;
10143 vel[1]=player[i].velocity.y;
10144 vel[2]=player[i].velocity.z;
10147 if(player[i].victim->weaponstuck!=-1){
10148 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10153 if(weapons.type[k]!=staff){
10154 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
10155 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10156 FSOUND_SetVolume(channels[knifedrawsound], 128);
10157 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
10161 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
10162 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10163 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
10164 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
10167 player[i].weaponactive=0;
10168 if(weapons.owner[k]!=-1){
10169 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10170 else player[i].victim->num_weapons=1;
10172 player[i].victim->skeleton.longdead=0;
10173 player[i].victim->skeleton.free=1;
10174 player[i].victim->skeleton.broken=0;
10176 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10177 player[i].victim->skeleton.joints[l].velchange=0;
10178 player[i].victim->skeleton.joints[l].locked=0;
10184 Normalise(&relative);
10185 XYZ footvel,footpoint;
10187 footpoint=weapons.position[k];
10188 if(player[i].victim->weaponstuck!=-1){
10189 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10190 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10191 weapons.bloody[k]=2;
10192 weapons.blooddrip[k]=5;
10193 player[i].victim->weaponstuck=-1;
10194 player[i].victim->bloodloss+=2000;
10195 player[i].victim->DoDamage(2000);
10198 if(player[i].victim->num_weapons>0){
10199 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10200 if(player[i].victim->weaponids[0]==k)
10201 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10204 player[i].victim->weaponactive=-1;
10206 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10207 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10208 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10209 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10211 weapons.owner[k]=i;
10212 if(player[i].num_weapons>0){
10213 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10215 player[i].num_weapons++;
10216 player[i].weaponids[0]=k;
10223 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10224 if(weapons.type[player[i].weaponids[0]]==knife){
10225 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10227 for(j=0;j<numplayers;j++){
10229 if(tutoriallevel!=1||tutorialstage==49)
10231 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)){
10232 if(!player[i].isFlip()){
10233 player[i].throwtogglekeydown=1;
10234 player[i].victim=&player[j];
10235 player[i].targetanimation=knifethrowanim;
10236 player[i].target=0;
10237 player[i].targetframe=0;
10238 rotatetarget=player[j].coords-player[i].coords;
10239 Normalise(&rotatetarget);
10240 player[i].targetrotation=-asin(0-rotatetarget.x);
10241 player[i].targetrotation*=360/6.28;
10242 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10244 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10246 if(player[i].isFlip()){
10247 if(player[i].weaponactive!=-1){
10248 player[i].throwtogglekeydown=1;
10249 player[i].victim=&player[j];
10251 weapons.owner[player[i].weaponids[0]]=-1;
10252 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);
10255 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10257 weapons.velocity[player[i].weaponids[0]]=aim*50;
10258 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10259 weapons.missed[player[i].weaponids[0]]=0;
10260 weapons.freetime[player[i].weaponids[0]]=0;
10261 weapons.firstfree[player[i].weaponids[0]]=1;
10262 weapons.physics[player[i].weaponids[0]]=0;
10263 player[i].num_weapons--;
10264 if(player[i].num_weapons){
10265 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10267 player[i].weaponactive=-1;
10274 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10275 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10277 player[i].throwtogglekeydown=1;
10278 weapons.owner[player[i].weaponids[0]]=-1;
10279 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10280 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10281 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10282 weapons.missed[player[i].weaponids[0]]=1;
10283 weapons.freetime[player[i].weaponids[0]]=0;
10284 weapons.firstfree[player[i].weaponids[0]]=1;
10285 weapons.physics[player[i].weaponids[0]]=1;
10286 player[i].num_weapons--;
10287 if(player[i].num_weapons){
10288 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10289 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10292 player[i].weaponactive=-1;
10293 for(j=0;j<numplayers;j++){
10294 player[j].wentforweapon=0;
10301 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10302 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)){
10303 //Setenvironment(1-environment);
10306 if(player[i].weaponactive!=-1){
10307 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10309 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10310 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10311 player[i].targetanimation=drawrightanim;
10312 player[i].targetframe=0;
10313 player[i].target=0;
10314 player[i].drawtogglekeydown=1;
10316 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){
10317 player[i].targetanimation=drawleftanim;
10318 player[i].targetframe=0;
10319 player[i].target=0;
10320 player[i].drawtogglekeydown=1;
10322 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10323 player[i].targetanimation=crouchdrawrightanim;
10324 player[i].targetframe=0;
10325 player[i].target=0;
10326 player[i].drawtogglekeydown=1;
10330 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){
10331 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10332 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10333 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10334 player[i].targetframe=0;
10335 player[i].target=0;
10336 player[i].hasvictim=0;
10337 //player[i].attacktogglekeydown=1;
10341 if(!player[i].drawkeydown){
10342 player[i].drawtogglekeydown=0;
10347 absflatfacing.z=-1;
10349 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10351 else absflatfacing=flatfacing;
10353 if(indialogue!=-1){
10354 player[i].forwardkeydown=0;
10355 player[i].leftkeydown=0;
10356 player[i].backkeydown=0;
10357 player[i].rightkeydown=0;
10358 player[i].jumpkeydown=0;
10359 player[i].crouchkeydown=0;
10360 player[i].drawkeydown=0;
10361 player[i].throwkeydown=0;
10365 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10366 if(!player[i].forwardkeydown){
10367 player[i].forwardstogglekeydown=0;
10369 if(player[i].crouchkeydown){
10373 player[i].superruntoggle=1;
10375 for(j=0;j<numplayers;j++){
10376 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10377 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10378 player[i].superruntoggle=0;
10385 for(j=0;j<numplayers;j++){
10386 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10387 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))){
10388 if(target>=0)target=-1;
10393 if(target>=0)player[target].Reverse();
10394 player[i].lowreversaldelay=.5;
10396 if(player[i].isIdle()){
10397 player[i].targetanimation=player[i].getCrouch();
10398 player[i].target=0;
10399 player[i].targetframe=0;
10400 player[i].transspeed=10;
10402 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10403 player[i].targetanimation=rollanim;
10404 player[i].target=0;
10405 player[i].targetframe=0;
10406 player[i].transspeed=20;
10409 if(!player[i].crouchkeydown){
10411 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10413 if(player[i].isCrouch()){
10415 for(j=0;j<numplayers;j++){
10416 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10417 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10418 if(target>=0)target=-1;
10423 if(target>=0)player[target].Reverse();
10424 player[i].highreversaldelay=.5;
10426 if(player[i].isCrouch()){
10427 if(!player[i].wasCrouch()){
10428 player[i].currentanimation=player[i].getCrouch();
10429 player[i].currentframe=0;
10431 player[i].target=0;
10432 player[i].targetanimation=player[i].getIdle();
10433 player[i].targetframe=0;
10434 player[i].transspeed=10;
10437 if(player[i].targetanimation==sneakanim){
10438 player[i].targetanimation=player[i].getIdle();
10439 player[i].target=0;
10440 player[i].targetframe=0;
10441 player[i].transspeed=10;
10444 if(player[i].forwardkeydown){
10445 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)){
10446 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10447 else player[i].targetanimation=player[i].getRun();
10448 player[i].target=0;
10449 player[i].targetframe=0;
10451 if(player[i].isCrouch()){
10452 player[i].targetanimation=sneakanim;
10453 if(player[i].wasCrouch())player[i].target=0;
10454 player[i].targetframe=0;
10456 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10457 player[i].targetanimation=climbanim;
10458 player[i].target=0;
10459 player[i].targetframe=1;
10460 player[i].jumpclimb=1;
10462 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10463 player[i].velocity+=absflatfacing*5*multiplier;
10465 player[i].forwardstogglekeydown=1;
10468 if (player[i].rightkeydown){
10469 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)){
10470 player[i].targetanimation=player[i].getRun();
10471 player[i].target=0;
10472 player[i].targetframe=0;
10474 if(player[i].isCrouch()){
10475 player[i].targetanimation=sneakanim;
10476 if(player[i].wasCrouch()) player[i].target=0;
10477 player[i].targetframe=0;
10479 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10480 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10482 player[i].targetrotation-=90;
10483 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10484 if(player[i].backkeydown)player[i].targetrotation-=45;
10487 if ( player[i].leftkeydown){
10488 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)){
10489 player[i].targetanimation=player[i].getRun();
10490 player[i].target=0;
10491 player[i].targetframe=0;
10493 if(player[i].isCrouch()){
10494 player[i].targetanimation=sneakanim;
10495 if(player[i].wasCrouch())player[i].target=0;
10496 player[i].targetframe=0;
10498 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10499 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10501 player[i].targetrotation+=90;
10502 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10503 if(player[i].backkeydown)player[i].targetrotation+=45;
10506 if(player[i].backkeydown){
10507 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)){
10508 player[i].targetanimation=player[i].getRun();
10509 player[i].target=0;
10510 player[i].targetframe=0;
10512 if(player[i].isCrouch()){
10513 player[i].targetanimation=sneakanim;
10514 if(player[i].wasCrouch())player[i].target=0;
10515 player[i].targetframe=0;
10517 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10518 player[i].velocity-=absflatfacing*5*multiplier;
10520 if(player[i].targetanimation==hanganim){
10521 player[i].currentanimation=jumpdownanim;
10522 player[i].targetanimation=jumpdownanim;
10523 player[i].target=0;
10524 player[i].currentframe=0;
10525 player[i].targetframe=1;
10526 player[i].velocity=0;
10527 player[i].velocity.y+=gravity;
10528 player[i].coords.y-=1.4;
10529 player[i].grabdelay=1;
10531 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10532 player[i].targetrotation+=180;
10535 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10536 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)){
10537 player[i].jumpstart=0;
10538 player[i].targetanimation=jumpupanim;
10539 player[i].target=0;
10540 player[i].targetframe=0;
10541 player[i].rotation=player[i].targetrotation;
10542 player[i].transspeed=20;
10543 player[i].FootLand(0,1);
10544 player[i].FootLand(1,1);
10548 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10550 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10551 if(!movekey)player[i].velocity=0;
10556 for(j=0;j<numplayers;j++){
10557 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10558 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10559 if(target>=0)target=-1;
10564 if(target>=0)player[i].velocity.y=1;
10565 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10566 player[i].velocity.y=7;
10567 player[i].crouchtogglekeydown=1;
10569 else player[i].velocity.y=5;
10571 if(mousejump&&i==0&&debugmode){
10572 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10573 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10576 player[i].coords.y+=.2;
10577 player[i].jumppower-=1;
10579 static float gLoc[3];
10580 static float vel[3];
10581 gLoc[0]=player[i].coords.x;
10582 gLoc[1]=player[i].coords.y;
10583 gLoc[2]=player[i].coords.z;
10584 vel[0]=player[i].velocity.x;
10585 vel[1]=player[i].velocity.y;
10586 vel[2]=player[i].velocity.z;
10589 PlaySoundEx( whooshsound, samp[whooshsound], NULL, TRUE);
10590 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10591 FSOUND_SetVolume(channels[whooshsound], 128);
10592 FSOUND_SetPaused(channels[whooshsound], FALSE);
10595 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
10596 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10597 FSOUND_SetVolume(channels[jumpsound], 128);
10598 FSOUND_SetPaused(channels[jumpsound], FALSE);
10600 if((player[i].isIdle())&&player[i].jumppower>1){
10601 player[i].targetanimation=player[i].getLanding();
10602 player[i].landhard=0;
10603 player[i].target=0;
10604 player[i].targetframe=2;
10605 player[i].jumpstart=1;
10606 player[i].tempdeltav=deltav;
10608 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10609 if(player[i].jumppower>multiplier*6){
10610 player[i].velocity.y+=multiplier*6;
10611 player[i].jumppower-=multiplier*6;
10613 if(player[i].jumppower<=multiplier*6){
10614 player[i].velocity.y+=player[i].jumppower;
10615 player[i].jumppower=0;
10618 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10622 if(player[i].isRun()||player[i].targetanimation==walkanim){
10623 player[i].targetanimation=player[i].getStop();
10624 player[i].target=0;
10625 player[i].targetframe=0;
10627 if(player[i].targetanimation==sneakanim){
10628 player[i].targetanimation=player[i].getCrouch();
10629 if(player[i].currentanimation==sneakanim)player[i].target=0;
10630 player[i].targetframe=0;
10633 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10634 player[i].targetanimation=player[i].getStop();
10635 player[i].target=0;
10636 player[i].targetframe=0;
10638 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10639 player[i].targetanimation=player[i].getStop();
10640 player[i].target=0;
10641 player[i].targetframe=0;
10645 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10649 for(k=0;k<numplayers;k++){
10650 if(abs(player[k].rotation-player[k].targetrotation)>180){
10651 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10652 else player[k].rotation+=360;
10655 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10656 player[k].targetanimation=player[k].getStop();
10657 player[k].targetframe=0;
10658 player[k].target=0;
10661 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10662 player[k].targettilt=0;
10664 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10665 player[k].targettilt=0;
10666 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10667 player[k].jumppower+=multiplier*7;
10668 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10669 //*(1-(player[k].damage/player[k].damagetolerance))
10670 if(player[k].jumppower>5)player[k].jumppower=5;
10673 if(player[k].isRun()){
10674 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10677 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10678 else if(player[k].tilt>player[k].targettilt){
10679 player[k].tilt-=multiplier*150;
10681 else if(player[k].tilt<player[k].targettilt){
10682 player[k].tilt+=multiplier*150;
10685 player[k].grabdelay-=multiplier;
10688 for(k=0;k<numplayers;k++){
10689 player[k].DoAnimations();
10690 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10691 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10696 player[0].righthandmorphstart=0;
10697 player[0].righthandmorphend=1;
10698 player[0].lefthandmorphstart=0;
10699 player[0].lefthandmorphend=1;
10700 player[0].headmorphstart=0;
10701 player[0].headmorphend=2;*/
10704 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10705 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10706 player[0].righthandmorphend=1;
10707 player[0].targetrighthandmorphness=1;
10709 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10710 player[0].lefthandmorphend=0;
10711 player[0].targetlefthandmorphness=1;
10713 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10714 player[0].headmorphend=2;
10715 player[0].targetheadmorphness=1;
10717 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10718 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10719 player[0].righthandmorphend=0;
10720 player[0].targetrighthandmorphness=1;
10722 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10723 player[0].lefthandmorphend=1;
10724 player[0].targetlefthandmorphness=1;
10726 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10727 player[0].headmorphend=0;
10728 player[0].targetheadmorphness=1;
10731 if(numenvsounds!=0)
10732 for(j=numenvsounds-1;j>=0;j--){
10733 envsoundlife[j]-=multiplier;
10734 if(envsoundlife[j]<0){
10736 envsoundlife[j]=envsoundlife[numenvsounds];
10737 envsound[j]=envsound[numenvsounds];
10740 if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
10741 if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
10743 if(tutoriallevel==1){
10760 if(tutorialstage>=51)
10761 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10762 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10764 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10765 FSOUND_SetPaused(channels[stream_music3], FALSE);
10766 FSOUND_SetVolume(channels[stream_music3], 256);
10771 float gLoc[3]={0,0,0};
10772 float vel[3]={0,0,0};
10773 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10774 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10775 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10776 FSOUND_SetVolume(channels[fireendsound], 256);
10777 FSOUND_SetPaused(channels[fireendsound], FALSE);
10778 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10786 if(tutorialstage<51)
10787 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10790 gLoc[0]=player[0].coords.x;
10791 gLoc[1]=player[0].coords.y;
10792 gLoc[2]=player[0].coords.z;
10796 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10797 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10798 FSOUND_SetVolume(channels[fireendsound], 256);
10799 FSOUND_SetPaused(channels[fireendsound], FALSE);
10801 player[0].coords=(oldtemp+oldtemp2)/2;
10809 if(tutorialstage>=14&&tutorialstage<50)
10810 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10813 gLoc[0]=player[1].coords.x;
10814 gLoc[1]=player[1].coords.y;
10815 gLoc[2]=player[1].coords.z;
10819 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10820 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10821 FSOUND_SetVolume(channels[fireendsound], 256);
10822 FSOUND_SetPaused(channels[fireendsound], FALSE);
10824 for(int i=0;i<player[1].skeleton.num_joints;i++){
10826 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10827 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10828 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;
10829 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10830 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10834 player[1].coords=(oldtemp+oldtemp2)/2;
10835 for(int i=0;i<player[1].skeleton.num_joints;i++){
10836 player[1].skeleton.joints[i].velocity=0;
10838 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10839 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10840 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;
10841 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10842 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10850 static float gLoc[3];
10854 static float vel[3];
10855 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10856 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10857 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10859 //Set orientation with forward and up vectors
10860 static XYZ upvector;
10864 upvector=DoRotation(upvector,-rotation2+90,0,0);
10865 upvector=DoRotation(upvector,0,0-rotation,0);
10870 facing=DoRotation(facing,-rotation2,0,0);
10871 facing=DoRotation(facing,0,0-rotation,0);
10874 static float ori[6];
10875 ori[0] = -facing.x;
10877 ori[2] = -facing.z;
10878 ori[3] = -upvector.x;
10879 ori[4] = upvector.y;
10880 ori[5] = -upvector.z;
10882 FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10889 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10891 freezetogglekeydown=1;
10895 void Game::TickOnce(){
10898 if(directing||indialogue==-1){
10899 rotation+=deltah*.7;
10900 if(!invertmouse)rotation2+=deltav*.7;
10901 if(invertmouse)rotation2-=deltav*.7;
10902 if(rotation2>90)rotation2=90;
10903 if(rotation2<-70)rotation2=-70;
10905 if(mainmenu)rotation+=multiplier*5;
10906 if(!mainmenu&&!indemo&&!registered){
10907 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10908 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10909 FSOUND_SetPaused(channels[stream_music3], FALSE);
10910 FSOUND_SetVolume(channels[stream_music3], 256);
10915 float gLoc[3]={0,0,0};
10916 float vel[3]={0,0,0};
10917 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10918 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10919 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10920 FSOUND_SetVolume(channels[fireendsound], 256);
10921 FSOUND_SetPaused(channels[fireendsound], FALSE);
10922 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10931 if(tryquit==1&&!registered&&mainmenu!=12){
10932 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10933 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
10934 FSOUND_SetPaused(channels[stream_music3], FALSE);
10935 FSOUND_SetVolume(channels[stream_music3], 256);
10940 float gLoc[3]={0,0,0};
10941 float vel[3]={0,0,0};
10942 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10943 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
10944 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10945 FSOUND_SetVolume(channels[fireendsound], 256);
10946 FSOUND_SetPaused(channels[fireendsound], FALSE);
10947 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10958 void Game::TickOnceAfter(){
10959 static XYZ colviewer;
10960 static XYZ coltarget;
10963 static float brotate;
10966 static float changedelay;
10967 static bool alldead;
10968 static float unseendelay;
10969 static float cameraspeed;
10973 if(environment==snowyenvironment)music1=stream_music1snow;
10974 if(environment==grassyenvironment)music1=stream_music1grass;
10975 if(environment==desertenvironment)music1=stream_music1desert;
10980 for(i=0;i<numplayers;i++){
10981 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)){
10982 musictype=stream_music2;
10986 if(player[0].dead)musictype=stream_music3;
10989 if(musictype==stream_music2){
10993 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10994 unseendelay-=multiplier;
10996 musictype=stream_music2;
11002 musictype=stream_music3;
11003 musicvolume[2]=512;
11010 if(musictype!=oldmusictype&&musictype==stream_music2){
11011 static float gLoc[3];
11012 static float vel[3];
11013 gLoc[0]=cameraloc.x;
11014 gLoc[1]=cameraloc.y;
11015 gLoc[2]=cameraloc.z;
11019 PlaySoundEx( alarmsound, samp[alarmsound], NULL, TRUE);
11020 FSOUND_SetVolume(channels[alarmsound], 512);
11021 FSOUND_SetPaused(channels[alarmsound], FALSE);
11025 musicselected=musictype;
11027 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11028 else musicvolume[0]-=multiplier*450;
11029 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11030 else musicvolume[1]-=multiplier*450;
11031 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11032 else musicvolume[2]-=multiplier*450;
11034 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11035 else musicvolume[0]-=multiplier*450;
11036 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11037 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11038 else musicvolume[1]-=multiplier*100;
11039 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11040 else musicvolume[2]-=multiplier*450;*/
11043 if(musicvolume[i]<0)musicvolume[i]=0;
11044 if(musicvolume[i]>512)musicvolume[i]=512;
11047 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11050 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11051 PlayStreamEx( music1, strm[music1], NULL, TRUE);
11052 FSOUND_SetPaused(channels[music1], FALSE);
11054 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11055 PlayStreamEx( stream_music2, strm[stream_music2], NULL, TRUE);
11056 FSOUND_SetPaused(channels[stream_music2], FALSE);
11058 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11059 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11060 FSOUND_SetPaused(channels[stream_music3], FALSE);
11065 FSOUND_SetPaused(channels[music1], TRUE);
11066 FSOUND_SetPaused(channels[stream_music2], TRUE);
11067 FSOUND_SetPaused(channels[stream_music3], TRUE);
11070 oldmusicvolume[i]=0;
11076 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11077 FSOUND_SetPaused(channels[music1], TRUE);
11079 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11080 FSOUND_SetPaused(channels[stream_music2], TRUE);
11082 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11083 FSOUND_SetPaused(channels[stream_music3], TRUE);
11086 if(musicvolume[0]!=oldmusicvolume[0]){
11087 FSOUND_SetVolume(channels[music1], musicvolume[0]);
11089 if(musicvolume[1]!=oldmusicvolume[1]){
11090 FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
11092 if(musicvolume[2]!=oldmusicvolume[2]){
11093 FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
11097 oldmusicvolume[i]=musicvolume[i];
11103 for(i=0;i<numhotspots;i++){
11104 if(hotspottype[i]>10&&hotspottype[i]<20){
11105 if(player[hotspottype[i]-10].dead==0){
11108 else if(killhotspot==2)
11112 if(killhotspot==2)killhotspot=0;
11117 for(i=0;i<numhotspots;i++){
11118 if(hotspottype[i]==-1){
11119 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11126 for(i=1;i<numplayers;i++){
11127 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11129 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11131 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11132 if(player[0].dead&&changedelay<=0){
11134 targetlevel=whichlevel;
11138 for(i=1;i<numplayers;i++){
11139 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11143 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11145 targetlevel=whichlevel+1;
11146 if(targetlevel>numchallengelevels-1)targetlevel=0;
11148 if(winhotspot||windialogue){
11150 targetlevel=whichlevel+1;
11151 if(targetlevel>numchallengelevels-1)targetlevel=0;
11157 targetlevel=whichlevel+1;
11158 if(targetlevel>numchallengelevels-1)targetlevel=0;
11161 if(changedelay>0&&!player[0].dead&&!won){
11162 //high scores, awards, win
11165 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11166 accountcampaignchoicesmade[accountactive]++;
11167 accountcampaignscore[accountactive]+=bonustotal;
11169 accountcampaigntime[accountactive]+=leveltime;
11170 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11172 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11178 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11179 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11181 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11197 if(!editorenabled&&gameon&&!mainmenu){
11198 if(changedelay!=-999)changedelay-=multiplier/7;
11199 if(player[0].dead)targetlevel=whichlevel;
11200 if(loading==2&&!campaign){
11208 float gLoc[3]={0,0,0};
11209 float vel[3]={0,0,0};
11210 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11211 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11212 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11213 FSOUND_SetVolume(channels[firestartsound], 256);
11214 FSOUND_SetPaused(channels[firestartsound], FALSE);
11215 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11217 if(!player[0].dead&&targetlevel!=whichlevel){
11218 startbonustotal=bonustotal;
11220 if(!player[0].dead)Loadlevel(targetlevel);
11221 if(player[0].dead)Loadlevel(whichlevel);
11223 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11224 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11225 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11226 FSOUND_SetVolume(channels[fireendsound], 256);
11227 FSOUND_SetPaused(channels[fireendsound], FALSE);
11228 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11232 if(loading==2&&targetlevel==whichlevel){
11240 float gLoc[3]={0,0,0};
11241 float vel[3]={0,0,0};
11242 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11243 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11244 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11245 FSOUND_SetVolume(channels[firestartsound], 256);
11246 FSOUND_SetPaused(channels[firestartsound], FALSE);
11247 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11249 for(i=0;i<255;i++){
11263 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11264 Loadlevel(mapname);
11266 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11267 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11268 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11269 FSOUND_SetVolume(channels[fireendsound], 256);
11270 FSOUND_SetPaused(channels[fireendsound], FALSE);
11271 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11275 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11276 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11277 if(accountprogress[accountactive]>3&&!registered){
11278 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11279 PlayStreamEx( stream_music3, strm[stream_music3], NULL, TRUE);
11280 FSOUND_SetPaused(channels[stream_music3], FALSE);
11281 FSOUND_SetVolume(channels[stream_music3], 256);
11285 accountprogress[accountactive]=3;
11287 float gLoc[3]={0,0,0};
11288 float vel[3]={0,0,0};
11289 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11290 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
11291 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11292 FSOUND_SetVolume(channels[fireendsound], 256);
11293 FSOUND_SetPaused(channels[fireendsound], FALSE);
11294 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11303 if(whichlevel!=-2&&!loading&&!player[0].dead){
11307 if(player[0].dead)loading=1;
11313 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11314 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11318 else if(mainmenu==0&&winfreeze){
11319 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11321 else stealthloading=0;
11323 if(!stealthloading){
11324 float gLoc[3]={0,0,0};
11325 float vel[3]={0,0,0};
11326 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11327 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
11328 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11329 FSOUND_SetVolume(channels[firestartsound], 256);
11330 FSOUND_SetPaused(channels[firestartsound], FALSE);
11331 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11342 // ifstream ipstream(":Data:Campaigns:main.txt");
11343 ifstream ipstream("./Data/Campaigns/main.txt");
11344 //campaignnumlevels=0;
11345 //accountcampaignchoicesmade[accountactive]=0;
11346 ipstream.ignore(256,':');
11347 ipstream >> campaignnumlevels;
11348 for(i=0;i<campaignnumlevels;i++){
11349 ipstream.ignore(256,':');
11350 ipstream.ignore(256,':');
11351 ipstream.ignore(256,' ');
11352 ipstream >> campaignmapname[i];
11353 ipstream.ignore(256,':');
11354 ipstream >> campaigndescription[i];
11355 for(j=0;j<256;j++){
11356 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11358 ipstream.ignore(256,':');
11359 ipstream >> campaignchoosenext[i];
11360 ipstream.ignore(256,':');
11361 ipstream >> campaignnumnext[i];
11362 if(campaignnumnext[i])
11363 for(j=0;j<campaignnumnext[i];j++){
11364 ipstream.ignore(256,':');
11365 ipstream >> campaignnextlevel[i][j];
11366 campaignnextlevel[i][j]-=1;
11368 ipstream.ignore(256,':');
11369 ipstream >> campaignlocationx[i];
11370 ipstream.ignore(256,':');
11371 ipstream >> campaignlocationy[i];
11375 for(i=0;i<campaignnumlevels;i++){
11377 levelhighlight[i]=0;
11381 for(i=0;i<campaignnumlevels;i++){
11383 levelhighlight[i]=0;
11388 if(accountcampaignchoicesmade[accountactive])
11389 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11390 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11391 levelvisible[levelorder[i+1]]=1;
11393 int whichlevelstart;
11394 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11395 if(whichlevelstart<0){
11396 campaignchoicenum=1;
11397 campaignchoicewhich[0]=0;
11401 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11402 if(campaignchoicenum)
11403 for(i=0;i<campaignchoicenum;i++){
11404 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11405 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11406 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11413 //if(firstload)TickOnceAfter();
11414 if(!firstload)LoadStuff();
11416 for(i=0;i<255;i++){
11431 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11432 //accountcampaignchoicesmade[accountactive]++;
11435 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11439 Loadlevel(mapname);
11443 FSOUND_SetPaused(channels[stream_music3], TRUE);
11448 if(loading==3)loading=0;
11452 oldmusictype=musictype;
11458 facing=DoRotation(facing,-rotation2,0,0);
11459 facing=DoRotation(facing,0,0-rotation,0);
11460 viewerfacing=facing;
11464 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;
11465 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;
11467 if(player[0].skeleton.free){
11468 for(i=0;i<player[0].skeleton.num_joints;i++){
11469 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11470 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11474 if(player[0].skeleton.free!=2&&!autocam){
11476 if(findLengthfast(&player[0].velocity)>400){
11477 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11479 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11480 coltarget=target-cameraloc;
11481 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11483 Normalise(&coltarget);
11484 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11485 else cameraloc=cameraloc+coltarget*multiplier*8;
11487 if(editorenabled)cameraloc=target;
11488 cameradist+=multiplier*5;
11489 if(cameradist>2.3)cameradist=2.3;
11490 viewer=cameraloc-facing*cameradist;
11492 coltarget=cameraloc;
11493 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11494 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11495 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11496 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11498 coltarget=cameraloc;
11499 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11501 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11502 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11503 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11505 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11509 cameradist=findDistance(&viewer,&target);
11510 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11511 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11513 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11514 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11517 if(player[0].skeleton.free!=2&&autocam){
11519 if(findLengthfast(&player[0].velocity)>400){
11520 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11522 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11523 cameradist+=multiplier*5;
11524 if(cameradist>3.3)cameradist=3.3;
11525 coltarget=target-cameraloc;
11526 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11527 else if(findLengthfast(&coltarget)>1)
11529 Normalise(&coltarget);
11530 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11531 else cameraloc=cameraloc+coltarget*multiplier*8;
11533 if(editorenabled)cameraloc=target;
11536 coltarget=cameraloc;
11537 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11538 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11539 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11540 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11542 coltarget=cameraloc;
11543 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11545 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11546 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11547 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11549 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11553 cameradist=findDistance(&viewer,&target);
11554 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11555 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11557 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11558 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11561 if(camerashake>.8)camerashake=.8;
11562 //if(woozy>10)woozy=10;
11563 //woozy+=multiplier;
11565 if(player[0].dead)camerashake=0;
11566 if(player[0].dead)woozy=0;
11567 camerashake-=multiplier*2;
11568 blackout-=multiplier*2;
11569 //if(player[0].isCrouch())woozy-=multiplier*8;
11570 if(camerashake<0)camerashake=0;
11571 if(blackout<0)blackout=0;
11572 //if(woozy<0)woozy=0;
11574 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11575 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11576 viewer.z+=(float)(Random()%100)*.0005*camerashake;