2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <sys/types.h>
35 extern float multiplier;
37 extern int environment;
38 extern float texscale;
39 extern Terrain terrain;
40 extern FSOUND_SAMPLE *samp[100];
41 extern int channels[100];
42 extern Sprites sprites;
43 extern int kTextureSize;
44 extern float screenwidth,screenheight;
47 extern float texdetail;
48 extern Objects objects;
50 extern float slomodelay;
51 extern bool floatjump;
53 extern Animation animation[animation_count];
55 extern float texdetail;
56 extern GLubyte bloodText[512*512*3];
57 extern GLubyte wolfbloodText[512*512*3];
58 extern float terraindetail;
59 extern float camerashake;
61 extern float blackout;
62 extern bool cellophane;
63 extern bool musictoggle;
64 extern int difficulty;
65 extern Weapons weapons;
66 extern Person player[maxplayers];
67 extern int numplayers;
68 extern int bloodtoggle;
69 extern bool invertmouse;
71 extern float precipdelay;
72 extern XYZ viewerfacing;
73 extern bool ambientsound;
74 extern bool mousejump;
75 extern float viewdistance;
77 extern bool autoslomo;
78 extern int newnetmessages;
79 extern char netmessages[256];
80 extern bool keyboardfrozen;
81 extern int netdatanew;
82 extern bool loadingstuff;
83 extern char mapname[256];
84 extern XYZ windvector;
85 extern bool buttons[3];
86 extern bool debugmode;
89 extern int oldmainmenu;
90 extern bool visibleloading;
91 extern int loadscreencolor;
92 extern float flashamount,flashr,flashg,flashb;
93 extern int flashdelay;
94 extern XYZ envsound[30];
95 extern float envsoundvol[30];
96 extern int numenvsounds;
97 extern float envsoundlife[30];
98 extern float usermousesensitivity;
99 extern bool ismotionblur;
101 extern bool trilinear;
102 extern bool damageeffects;
103 extern bool showpoints;
104 extern bool texttoggle;
105 extern bool alwaysblur;
106 extern float gamespeed;
109 extern bool immediate;
110 extern bool velocityblur;
113 extern float bonusvalue;
114 extern float bonustotal;
115 extern float bonustime;
116 extern float startbonustotal;
117 extern float tintr,tintg,tintb;
118 extern float bonusnum[100];
119 extern bool skyboxtexture;
120 extern float skyboxr;
121 extern float skyboxg;
122 extern float skyboxb;
123 extern float skyboxlightr;
124 extern float skyboxlightg;
125 extern float skyboxlightb;
126 extern float fadestart;
127 extern float slomospeed;
128 extern float slomofreq;
129 extern int tutoriallevel;
130 extern float smoketex;
131 extern float tutorialstagetime;
132 extern int tutorialstage;
133 extern float tutorialmaxtime;
134 extern float tutorialsuccess;
135 extern bool againbonus;
136 extern bool reversaltrain;
137 extern bool canattack;
138 extern bool cananger;
139 extern float damagedealt;
140 extern float damagetaken;
142 extern int editoractive;
143 extern int editorpathtype;
144 extern bool oldbuttons[3];
146 extern float hostiletime;
148 extern bool gamestarted;
150 extern int numhotspots;
151 extern int winhotspot;
152 extern int windialogue;
153 extern int killhotspot;
154 extern XYZ hotspot[40];
155 extern int hotspottype[40];
156 extern float hotspotsize[40];
157 extern char hotspottext[40][256];
158 extern int currenthotspot;
160 extern int kBitsPerPixel;
163 extern int numaccounts;
164 extern int accountactive;
165 extern int accountdifficulty[10];
166 extern int accountprogress[10];
167 extern float accountpoints[10];
168 extern float accounthighscore[10][50];
169 extern float accountfasttime[10][50];
170 extern bool accountunlocked[10][60];
171 extern char accountname[10][256];
173 extern bool stillloading;
174 extern bool winfreeze;
177 extern int numflipfail;
179 extern int numstaffattack;
180 extern int numswordattack;
181 extern int numknifeattack;
182 extern int numunarmedattack;
183 extern int numescaped;
184 extern int numflipped;
185 extern int numwallflipped;
186 extern int numthrowkill;
187 extern int numafterkill;
188 extern int numreversals;
189 extern int numattacks;
190 extern int maxalarmed;
191 extern int numresponded;
193 extern int numdialogues;
194 extern int numdialogueboxes[max_dialogues];
195 extern int dialoguetype[max_dialogues];
196 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
197 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
198 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
199 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
200 extern char dialoguename[max_dialogues][max_dialoguelength][64];
201 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
202 extern XYZ participantlocation[max_dialogues][10];
203 extern int participantfocus[max_dialogues][max_dialoguelength];
204 extern int participantaction[max_dialogues][max_dialoguelength];
205 extern float participantrotation[max_dialogues][10];
206 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
207 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
208 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
209 extern int indialogue;
210 extern int whichdialogue;
211 extern int directing;
212 extern float dialoguetime;
213 extern int dialoguegonethrough[20];
215 extern bool campaign;
217 extern float oldgamespeed;
219 extern float accountcampaignhighscore[10];
220 extern float accountcampaignfasttime[10];
221 extern float accountcampaignscore[10];
222 extern float accountcampaigntime[10];
224 extern int accountcampaignchoicesmade[10];
225 extern int accountcampaignchoices[10][5000];
226 /********************> Tick() <*****/
227 extern FSOUND_STREAM * strm[20];
228 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
229 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
231 extern void ScreenShot(const char * fname);
232 void Screenshot (void)
235 time_t t = time(NULL);
236 struct tm *tme = localtime(&t);
237 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);
239 mkdir("Screenshots", S_IRWXU);
240 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
243 GraphicsExportComponent QT_exporter;
244 OSErr MAC_error_code;
245 CGrafPtr MAC_currentPort;
246 GDHandle MAC_currentDevice;
247 unsigned char* MAC_pixels;
248 Rect MAC_picture_rectangle;
249 GWorldPtr MAC_offscreen_graphics_port;
251 static int numscreenshots=0;
254 static char buf[256];
255 if(numscreenshots==0){
286 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
287 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
288 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
289 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
310 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
311 //assert(MAC_gWorld != NULL);
313 // Allocate memory for loading image
314 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
315 if (MAC_pixels == NULL) {
316 //UTIL_Error("Could not create Texture data.");
321 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
323 // Make a picture Rectangle
324 MAC_picture_rectangle.left = 0;
325 MAC_picture_rectangle.right = screenwidth;
326 MAC_picture_rectangle.top = 0;
327 MAC_picture_rectangle.bottom = screenheight;
329 // Create new offscreen GWorld
330 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
331 if (MAC_error_code) {
332 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
334 //UTIL_Error("Could not create offscreen GWorld. ");
339 // Copy OpenGL Context to new GWorld
340 glReadBuffer(GL_FRONT);
341 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
344 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
345 unsigned char temp = MAC_pixels[byte+0];
346 MAC_pixels[byte+0] = MAC_pixels[byte+3];
347 MAC_pixels[byte+3] = MAC_pixels[byte+2];
348 MAC_pixels[byte+2] = MAC_pixels[byte+1];
349 MAC_pixels[byte+1] = temp;
352 // Flip the image :( This could probably be optimized
357 for (int horz = 0; horz < screenwidth; ++horz)
358 for (vert = 0; vert < screenheight / 2; ++vert) {
359 src_index = (screenwidth * vert + horz) * 4;
360 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
362 temp=MAC_pixels[src_index+0];
363 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
364 MAC_pixels[dst_index+0]=temp;
366 temp=MAC_pixels[src_index+1];
367 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
368 MAC_pixels[dst_index+1]=temp;
370 temp=MAC_pixels[src_index+2];
371 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
372 MAC_pixels[dst_index+2]=temp;
374 temp=MAC_pixels[src_index+3];
375 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
376 MAC_pixels[dst_index+3]=temp;
382 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
383 if (MAC_error_code) {
384 //UTIL_Warning("Unable to export screenshot.");
385 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
386 ::DisposeGWorld(MAC_offscreen_graphics_port);
391 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
392 if (MAC_error_code) {
393 ::CloseComponent(QT_exporter);
394 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
395 ::DisposeGWorld(MAC_offscreen_graphics_port);
397 //UTIL_Warning("Unable to export screenshot.");
401 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
402 if (MAC_error_code) {
403 ::CloseComponent(QT_exporter);
404 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
405 ::DisposeGWorld(MAC_offscreen_graphics_port);
407 //UTIL_Warning("Unable to export screenshot.");
411 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
412 if (MAC_error_code) {
413 ::CloseComponent(QT_exporter);
414 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
415 ::DisposeGWorld(MAC_offscreen_graphics_port);
417 //UTIL_Warning("Unable to export screenshot.");
421 ::CloseComponent(QT_exporter);
422 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
423 ::DisposeGWorld(MAC_offscreen_graphics_port);
430 void Game::SetUpLighting(){
431 if(environment==snowyenvironment){
437 light.ambient[2]=.44;
439 if(environment==desertenvironment){
444 light.ambient[1]=.35;
448 if(environment==grassyenvironment){
454 light.ambient[2]=.44;
465 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
466 light.color[0]*=(skyboxlightr+average)/2;
467 light.color[1]*=(skyboxlightg+average)/2;
468 light.color[2]*=(skyboxlightb+average)/2;
469 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
470 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
471 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
475 light.ambient[2]=0; */
478 int Game::findPathDist(int start,int end){
479 int i,j,k,smallestcount,count,connected;
480 int last,last2,last3,last4;
490 while(last!=end&&count<30){
492 for(j=0;j<numpathpoints;j++){
493 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
496 if(numpathpointconnect[j])
497 for(k=0;k<numpathpointconnect[j];k++){
498 if(pathpointconnect[j][k]==last)connected=1;
501 if(numpathpointconnect[last])
502 for(k=0;k<numpathpointconnect[last];k++){
503 if(pathpointconnect[last][k]==j)connected=1;
506 if(closest==-1||Random()%2==0){
517 if(count<smallestcount)smallestcount=count;
519 return smallestcount;
522 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
523 static XYZ colpoint,colviewer,coltarget;
524 static float minx,minz,maxx,maxz,miny,maxy;
533 if(minx>endpoint.x)minx=endpoint.x;
535 if(miny>endpoint.y)miny=endpoint.y;
537 if(minz>endpoint.z)minz=endpoint.z;
540 if(maxx<endpoint.x)maxx=endpoint.x;
542 if(maxy<endpoint.y)maxy=endpoint.y;
544 if(maxz<endpoint.z)maxz=endpoint.z;
553 for(i=0;i<objects.numobjects;i++){
554 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){
555 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
556 colviewer=startpoint;
558 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
563 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
568 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
569 static XYZ colpoint,colviewer,coltarget;
570 static float minx,minz,maxx,maxz,miny,maxy;
579 if(minx>endpoint.x)minx=endpoint.x;
581 if(miny>endpoint.y)miny=endpoint.y;
583 if(minz>endpoint.z)minz=endpoint.z;
586 if(maxx<endpoint.x)maxx=endpoint.x;
588 if(maxy<endpoint.y)maxy=endpoint.y;
590 if(maxz<endpoint.z)maxz=endpoint.z;
600 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){
601 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
602 colviewer=startpoint;
604 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
609 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
614 void Game::Setenvironment(int which)
618 LOG(" Setting environment...");
623 FSOUND_SetPaused(channels[music1snow], true);
624 FSOUND_SetPaused(channels[music1grass], true);
625 FSOUND_SetPaused(channels[music1desert], true);
626 FSOUND_SetPaused(channels[wind], true);
627 FSOUND_SetPaused(channels[desertambient], true);
629 FSOUND_SetPaused(channels[stream_music1snow], true);
630 FSOUND_SetPaused(channels[stream_music1grass], true);
631 FSOUND_SetPaused(channels[stream_music1desert], true);
632 FSOUND_SetPaused(channels[stream_wind], true);
633 FSOUND_SetPaused(channels[stream_desertambient], true);
636 if(environment==snowyenvironment){
640 //PlaySoundEx( wind, samp[wind], NULL, true);
641 PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
642 FSOUND_SetPaused(channels[stream_wind], false);
643 FSOUND_SetVolume(channels[stream_wind], 256);
646 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
647 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
648 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
649 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
651 FSOUND_Sample_Free(samp[footstepsound]);
652 FSOUND_Sample_Free(samp[footstepsound2]);
653 FSOUND_Sample_Free(samp[footstepsound3]);
654 FSOUND_Sample_Free(samp[footstepsound4]);
655 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
656 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
657 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
658 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
659 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
660 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
661 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
662 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
664 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
666 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
668 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
673 temptexdetail=texdetail;
674 if(texdetail>1)texdetail=4;
675 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
676 ":Data:Textures:Skybox(snow):Left.jpg",
677 ":Data:Textures:Skybox(snow):Back.jpg",
678 ":Data:Textures:Skybox(snow):Right.jpg",
679 ":Data:Textures:Skybox(snow):Up.jpg",
680 ":Data:Textures:Skybox(snow):Down.jpg",
681 ":Data:Textures:Skybox(snow):Cloud.jpg",
682 ":Data:Textures:Skybox(snow):Reflect.jpg");
687 texdetail=temptexdetail;
689 if(environment==desertenvironment){
692 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
693 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
694 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
695 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
699 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
700 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
701 FSOUND_SetPaused(channels[stream_desertambient], false);
702 FSOUND_SetVolume(channels[stream_desertambient], 256);
705 FSOUND_Sample_Free(samp[footstepsound]);
706 FSOUND_Sample_Free(samp[footstepsound2]);
707 FSOUND_Sample_Free(samp[footstepsound3]);
708 FSOUND_Sample_Free(samp[footstepsound4]);
709 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
710 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
711 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
712 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
713 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
714 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
715 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
716 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
718 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
720 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
722 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
726 temptexdetail=texdetail;
727 if(texdetail>1)texdetail=4;
728 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
729 ":Data:Textures:Skybox(sand):Left.jpg",
730 ":Data:Textures:Skybox(sand):Back.jpg",
731 ":Data:Textures:Skybox(sand):Right.jpg",
732 ":Data:Textures:Skybox(sand):Up.jpg",
733 ":Data:Textures:Skybox(sand):Down.jpg",
734 ":Data:Textures:Skybox(sand):Cloud.jpg",
735 ":Data:Textures:Skybox(sand):Reflect.jpg");
740 texdetail=temptexdetail;
742 if(environment==grassyenvironment){
745 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
746 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
747 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
748 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
751 PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
752 FSOUND_SetPaused(channels[stream_wind], false);
753 FSOUND_SetVolume(channels[stream_wind], 100);
756 FSOUND_Sample_Free(samp[footstepsound]);
757 FSOUND_Sample_Free(samp[footstepsound2]);
758 FSOUND_Sample_Free(samp[footstepsound3]);
759 FSOUND_Sample_Free(samp[footstepsound4]);
760 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0, 0);
761 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0, 0);
762 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
763 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
764 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
765 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
766 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
767 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
769 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
771 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
773 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
777 temptexdetail=texdetail;
778 if(texdetail>1)texdetail=4;
779 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
780 ":Data:Textures:Skybox(grass):Left.jpg",
781 ":Data:Textures:Skybox(grass):Back.jpg",
782 ":Data:Textures:Skybox(grass):Right.jpg",
783 ":Data:Textures:Skybox(grass):Up.jpg",
784 ":Data:Textures:Skybox(grass):Down.jpg",
785 ":Data:Textures:Skybox(grass):Cloud.jpg",
786 ":Data:Textures:Skybox(grass):Reflect.jpg");
790 texdetail=temptexdetail;
792 temptexdetail=texdetail;
794 terrain.load(":Data:Textures:heightmap.png");
796 texdetail=temptexdetail;
800 void Game::Loadlevel(int which){
803 if(which==0)Loadlevel((char *)":Data:Maps:map1");
804 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
805 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
806 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
807 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
808 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
809 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
810 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
811 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
812 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
813 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
814 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
815 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
816 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
817 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
818 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
819 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
820 else Loadlevel((char *)":Data:Maps:mapsave");
825 /*char * Game::MD5_string (unsigned char *string){
829 strcpy(temp2,(const char *)string);
830 strcat((char *)temp2,(const char *)"Lugaru");
831 sprintf (temp, "%d",strlen((char *)temp2));
832 strcat((char *)temp2,temp);
835 unsigned int len = strlen ( (char *)temp2);
837 context.update ((unsigned char *)temp2, len);
840 return context.hex_digest();
845 void Game::Loadlevel(char *name){
852 float headprop,legprop,armprop,bodyprop;
856 LOG(std::string("Loading level...") + name);
858 if(!gameon)visibleloading=1;
860 if(stealthloading)visibleloading=0;
862 if(!stillloading)loadtime=0;
867 if(tutoriallevel!=-1)tutoriallevel=0;
868 else tutoriallevel=1;
870 if(tutoriallevel==1)tutorialstage=0;
871 if(tutorialstage==0){
879 FSOUND_SetPaused(channels[whooshsound], true);
880 FSOUND_SetPaused(channels[stream_firesound], true);
884 tfile=fopen( name, "rb" );
887 FSOUND_SetPaused(channels[stream_firesound], true);
898 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
904 dialoguegonethrough[i]=0;
913 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
915 if(difficulty!=2)minimap=1;
952 bonustotal=startbonustotal;
958 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
959 FSOUND_SetVolume(channels[consolesuccesssound], 256);
960 FSOUND_SetPaused(channels[consolesuccesssound], false);
968 sprites.numsprites=0;
969 for(i=0;i<objects.numobjects;i++)
971 objects.model[i].numdecals=0;
974 j=objects.numobjects;
977 objects.DeleteObject(0);
978 if(visibleloading){loadscreencolor=4; LoadingScreen();}
981 for(i=0;i<subdivision;i++)
983 for(j=0;j<subdivision;j++)
985 terrain.patchobjectnum[i][j]=0;
988 if(visibleloading){loadscreencolor=4; LoadingScreen();}
991 weapons.numweapons=0;
993 funpackf(tfile, "Bi", &mapvers);
994 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
996 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
997 else maptype=mapkilleveryone;
998 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1000 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1006 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1014 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1017 skyboxlightr=skyboxr;
1018 skyboxlightg=skyboxg;
1019 skyboxlightb=skyboxb;
1021 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);
1022 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1023 player[0].originalcoords=player[0].coords;
1024 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1026 for(j=0;j<player[0].num_weapons;j++)
1028 player[0].weaponids[j]=weapons.numweapons;
1029 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1030 weapons.owner[weapons.numweapons]=0;
1031 weapons.numweapons++;
1035 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1037 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1038 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1039 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1040 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1042 funpackf(tfile, "Bi", &player[0].numclothes);
1046 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1050 player[0].whichskin=0;
1051 player[0].creature=rabbittype;
1054 for(i=0;i<max_dialogues;i++)
1056 for(j=0;j<max_dialoguelength;j++)
1060 dialoguetext[i][j][k]='\0';
1064 dialoguename[i][j][k]='\0';
1069 player[0].lastattack=-1;
1070 player[0].lastattack2=-1;
1071 player[0].lastattack3=-1;
1075 funpackf(tfile, "Bi", &numdialogues);
1078 for(k=0;k<numdialogues;k++)
1080 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1081 funpackf(tfile, "Bi", &dialoguetype[k]);
1084 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1085 funpackf(tfile, "Bf", &participantrotation[k][l]);
1087 if(numdialogueboxes)
1089 for(l=0;l<numdialogueboxes[k];l++)
1091 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1092 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1093 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1094 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1095 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1099 funpackf(tfile, "Bi",&templength);
1100 if(templength>128||templength<=0)templength=128;
1101 for(m=0;m<templength;m++){
1102 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1103 if(dialoguetext[k][l][m]=='\0')break;
1106 funpackf(tfile, "Bi",&templength);
1107 if(templength>64||templength<=0)templength=64;
1108 for(m=0;m<templength;m++){
1109 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1110 if(dialoguename[k][l][m]=='\0'){
1114 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1115 funpackf(tfile, "Bi", &participantfocus[k][l]);
1116 funpackf(tfile, "Bi", &participantaction[k][l]);
1119 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1121 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1127 else numdialogues=0;
1129 if(player[0].numclothes)
1131 for(k=0;k<player[0].numclothes;k++)
1133 funpackf(tfile, "Bi", &templength);
1134 for(l=0;l<templength;l++)
1135 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1136 player[0].clothes[k][templength]='\0';
1137 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1141 funpackf(tfile, "Bi", &environment);
1143 funpackf(tfile, "Bi", &objects.numobjects);
1144 if(objects.numobjects)
1146 for(i=0;i<objects.numobjects;i++)
1148 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]);
1149 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1155 funpackf(tfile, "Bi", &numhotspots);
1158 for(i=0;i<numhotspots;i++)
1160 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1161 funpackf(tfile, "Bi", &templength);
1163 for(l=0;l<templength;l++)
1164 funpackf(tfile, "Bb", &hotspottext[i][l]);
1165 hotspottext[i][templength]='\0';
1166 if(hotspottype[i]==-111)indemo=1;
1172 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1177 for(i=0;i<objects.numobjects;i++)
1179 objects.center+=objects.position[i];
1181 objects.center/=objects.numobjects;
1184 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1186 float maxdistance=0;
1189 for(i=0;i<objects.numobjects;i++)
1191 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1192 if(tempdist>maxdistance)
1195 maxdistance=tempdist;
1198 objects.radius=fast_sqrt(maxdistance);
1201 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1202 //mapcenter=objects.center;
1203 //mapradius=objects.radius;
1205 funpackf(tfile, "Bi", &numplayers);
1206 int howmanyremoved=0;
1207 bool removeanother=0;
1208 if(numplayers>1&&numplayers<maxplayers)
1210 for(i=1;i<numplayers;i++)
1212 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1215 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);
1216 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1217 else player[i-howmanyremoved].howactive=typeactive;
1218 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1219 else player[i-howmanyremoved].scale=-1;
1220 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1221 else player[i-howmanyremoved].immobile=0;
1222 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1223 else player[i-howmanyremoved].rotation=0;
1224 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1225 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1231 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1233 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1235 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1236 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1237 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1238 weapons.numweapons++;
1241 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1242 //player[i-howmanyremoved].numwaypoints=10;
1243 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1245 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1246 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1247 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1248 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1249 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1252 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1253 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1255 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1256 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1257 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1258 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1260 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1268 if(player[i-howmanyremoved].creature==wolftype)
1270 player[i-howmanyremoved].proportionhead=1.1*headprop;
1271 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1272 player[i-howmanyremoved].proportionarms=1.1*armprop;
1273 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1276 if(player[i-howmanyremoved].creature==rabbittype)
1278 player[i-howmanyremoved].proportionhead=1.2*headprop;
1279 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1280 player[i-howmanyremoved].proportionarms=1.00*armprop;
1281 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1282 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1285 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1286 if(player[i-howmanyremoved].numclothes)
1288 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1291 funpackf(tfile, "Bi", &templength);
1292 for(l=0;l<templength;l++)
1293 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1294 player[i-howmanyremoved].clothes[k][templength]='\0';
1295 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1301 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1303 numplayers-=howmanyremoved;
1304 funpackf(tfile, "Bi", &numpathpoints);
1305 if(numpathpoints>30||numpathpoints<0)
1309 for(j=0;j<numpathpoints;j++)
1311 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1312 for(k=0;k<numpathpointconnect[j];k++){
1313 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1317 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1319 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1322 if(environment!=oldenvironment)Setenvironment(environment);
1323 oldenvironment=environment;
1327 j=objects.numobjects;
1328 objects.numobjects=0;
1331 //if(objects.type[i]!=spiketype)
1332 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1333 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1336 //if(skyboxtexture){
1337 terrain.DoShadows();
1338 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1339 objects.DoShadows();
1340 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1342 else terrain.DoLighting();
1348 oldlevel=whichlevel;
1351 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1352 for(i=0;i<numplayers;i++)
1354 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1358 if(i==0||player[i].scale<0)player[i].scale=.2;
1359 player[i].skeleton.free=0;
1360 player[i].skeleton.id=i;
1361 //if(Random()%2==0)player[i].creature=wolftype;
1362 //else player[i].creature=rabbittype;
1363 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1364 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);
1367 if(player[i].creature!=wolftype){
1368 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);
1369 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1371 if(player[i].creature==wolftype){
1372 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);
1378 texsize=512*512*3/texdetail/texdetail;
1379 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1380 //player[i].skeleton.skinText.resize(texsize);
1382 if(player[i].creature==rabbittype)
1384 if(player[i].whichskin==0){
1385 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1387 else if(player[i].whichskin==1){
1388 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1390 else if(player[i].whichskin==2){
1391 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1393 else if(player[i].whichskin==3){
1394 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1396 else if(player[i].whichskin==4){
1397 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1399 else if(player[i].whichskin==5){
1400 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1402 else if(player[i].whichskin==6){
1403 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1405 else if(player[i].whichskin==7){
1406 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1408 else if(player[i].whichskin==8){
1409 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1411 else if(player[i].whichskin==9){
1412 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1415 if(player[i].creature==wolftype)
1417 //k=abs(Random()%3);
1418 if(player[i].whichskin==0){
1419 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1421 else if(player[i].whichskin==1){
1422 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1424 else if(player[i].whichskin==2){
1425 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1429 if(player[i].numclothes)
1431 for(j=0;j<player[i].numclothes;j++)
1433 tintr=player[i].clothestintr[j];
1434 tintg=player[i].clothestintg[j];
1435 tintb=player[i].clothestintb[j];
1436 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1438 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1441 player[i].currentanimation=bounceidleanim;
1442 player[i].targetanimation=bounceidleanim;
1443 player[i].currentframe=0;
1444 player[i].targetframe=1;
1446 player[i].speed=1+(float)(Random()%100)/1000;
1447 if(difficulty==0)player[i].speed-=.2;
1448 if(difficulty==1)player[i].speed-=.1;
1450 player[i].velocity=0;
1451 player[i].oldcoords=player[i].coords;
1452 player[i].realoldcoords=player[i].coords;
1455 player[i].skeleton.id=i;
1456 player[i].updatedelay=0;
1457 player[i].normalsupdatedelay=0;
1459 player[i].aitype=passivetype;
1460 player[i].aitarget=0;
1461 player[i].madskills=0;
1465 player[i].proportionhead=1.2;
1466 player[i].proportionbody=1.05;
1467 player[i].proportionarms=1.00;
1468 player[i].proportionlegs=1.1;
1469 player[i].proportionlegs.y=1.05;
1471 player[i].headless=0;
1472 player[i].currentoffset=0;
1473 player[i].targetoffset=0;
1474 /*player[i].armorhead=1;
1475 player[i].armorhigh=1;
1476 player[i].armorlow=1;
1477 player[i].protectionhead=1;
1478 player[i].protectionhigh=1;
1479 player[i].protectionlow=1;
1480 player[i].metalhead=1;
1481 player[i].metalhigh=1;
1482 player[i].metallow=1;
1484 player[i].speedmult=1;*/
1486 player[i].damagetolerance=200;
1488 if(player[i].creature==wolftype)
1490 /*player[i].proportionhead=1.1;
1491 player[i].proportionbody=1.1;
1492 player[i].proportionarms=1.1;
1493 player[i].proportionlegs=1.1;
1494 player[i].proportionlegs.y=1.1;*/
1495 if(i==0||player[i].scale<0)player[i].scale=.23;
1497 player[i].damagetolerance=300;
1500 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1503 player[i].proportionhead.z=0;
1504 player[i].proportionbody.z=0;
1505 player[i].proportionarms.z=0;
1506 player[i].proportionlegs.z=0;
1509 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1511 player[i].headmorphness=0;
1512 player[i].targetheadmorphness=1;
1513 player[i].headmorphstart=0;
1514 player[i].headmorphend=0;
1516 player[i].pausetime=0;
1519 player[i].jumppower=5;
1521 player[i].permanentdamage=0;
1522 player[i].superpermanentdamage=0;
1524 player[i].forwardkeydown=0;
1525 player[i].leftkeydown=0;
1526 player[i].backkeydown=0;
1527 player[i].rightkeydown=0;
1528 player[i].jumpkeydown=0;
1529 player[i].crouchkeydown=0;
1530 player[i].throwkeydown=0;
1532 player[i].collided=-10;
1534 player[i].bloodloss=0;
1535 player[i].weaponactive=-1;
1536 player[i].weaponstuck=-1;
1537 player[i].bleeding=0;
1538 player[i].deathbleeding=0;
1539 player[i].stunned=0;
1540 player[i].hasvictim=0;
1541 player[i].wentforweapon=0;
1544 player[0].aitype=playercontrolled;
1545 player[0].weaponactive=-1;
1549 //player[0].speedmult=1/.9;
1550 player[0].power=1/.9;
1555 //player[0].speedmult=1/.8;
1556 player[0].power=1/.8;
1559 //player[0].weaponstuck=1;
1561 if(difficulty==1)player[0].damagetolerance=250;
1562 if(difficulty==0)player[0].damagetolerance=300;
1563 if(difficulty==0)player[0].armorhead*=1.5;
1564 if(difficulty==0)player[0].armorhigh*=1.5;
1565 if(difficulty==0)player[0].armorlow*=1.5;
1566 cameraloc=player[0].coords;
1568 rotation=player[0].rotation;
1570 hawkcoords=player[0].coords;
1573 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1574 //weapons.numweapons=numplayers;
1575 for(i=0;i<weapons.numweapons;i++)
1577 weapons.bloody[i]=0;
1578 weapons.blooddrip[i]=0;
1579 weapons.blooddripdelay[i]=0;
1580 weapons.onfire[i]=0;
1581 weapons.flamedelay[i]=0;
1582 weapons.damage[i]=0;
1583 //weapons.type[i]=sword;
1584 if(weapons.type[i]==sword){
1585 weapons.mass[i]=1.5;
1586 weapons.tipmass[i]=1;
1587 weapons.length[i]=.8;
1589 if(weapons.type[i]==staff){
1591 weapons.tipmass[i]=1;
1592 weapons.length[i]=1.5;
1594 if(weapons.type[i]==knife){
1596 weapons.tipmass[i]=1.2;
1597 weapons.length[i]=.25;
1599 weapons.position[i]=-1000;
1600 weapons.tippoint[i]=-1000;
1603 /* for(i=0;i<32;i++){
1605 FSOUND_StopSound(i);
1608 LOG("Starting background music...");
1610 FSOUND_StopSound(FSOUND_ALL);
1611 if(environment==snowyenvironment)
1615 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1616 FSOUND_SetPaused(channels[stream_wind], false);
1617 FSOUND_SetVolume(channels[stream_wind], 256);
1620 else if(environment==desertenvironment)
1624 //PlaySoundEx(desertambient,
1625 // samp[desertambient], NULL, true);
1626 PlayStreamEx(stream_desertambient,
1627 strm[stream_desertambient], NULL, true);
1628 FSOUND_SetPaused(channels[stream_desertambient], false);
1629 FSOUND_SetVolume(channels[stream_desertambient], 256);
1632 else if(environment==grassyenvironment)
1636 //PlaySoundEx(wind, samp[wind], NULL, true);
1637 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1638 FSOUND_SetPaused(channels[stream_wind], false);
1639 FSOUND_SetVolume(channels[stream_wind], 100);
1642 oldmusicvolume[0]=0;
1643 oldmusicvolume[1]=0;
1644 oldmusicvolume[2]=0;
1645 oldmusicvolume[3]=0;
1648 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1649 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1650 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1651 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1652 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1653 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1654 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1655 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1670 static int i,k,j,l,m;
1671 static XYZ facing,flatfacing,absflatfacing;
1672 static XYZ rotatetarget;
1674 static float oldtargetrotation;
1675 static int target, numgood;
1676 static XYZ tempcoords1,tempcoords2;
1679 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1680 static int whichhit;
1681 static bool donesomething;
1682 static bool oldjumpkeydown;
1686 float headprop,bodyprop,armprop,legprop;
1690 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1691 FSOUND_SetVolume(channels[consolesuccesssound], 256);
1692 FSOUND_SetPaused(channels[consolesuccesssound], false);
1696 consoletext[k][j]=consoletext[k-1][j];
1698 consolechars[k]=consolechars[k-1];
1702 displaytext[k][j]=displaytext[k-1][j];
1704 displaychars[k]=displaychars[k-1];
1705 displaytime[k]=displaytime[k-1];
1708 consoletext[1][j]=' ';
1709 displaytext[1][j]=' ';
1711 sprintf (consoletext[1], netmessages);
1712 sprintf (displaytext[1], netmessages);
1713 consolechars[1]=255;
1714 displaychars[1]=255;
1719 displaytime[i]+=multiplier;
1722 static unsigned char theKeyMap[16];
1723 GetKeys( theKeyMap );
1728 static bool mainmenutogglekeydown;
1730 if(mainmenu&&endgame==1)mainmenu=10;
1731 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1733 displaytext[0][j]=' ';
1738 mainmenutogglekeydown=1;
1740 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)){
1742 if(mainmenu==1||mainmenu==2||mainmenu==0){
1743 if(mainmenu==0&&!winfreeze)mainmenu=2;
1744 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1745 else if(mainmenu==0&&winfreeze){
1746 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1748 else stealthloading=0;
1750 if(!stealthloading){
1751 float gLoc[3]={0,0,0};
1752 float vel[3]={0,0,0};
1753 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1754 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1755 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1756 FSOUND_SetVolume(channels[firestartsound], 256);
1757 FSOUND_SetPaused(channels[firestartsound], false);
1758 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1769 for(i=0;i<campaignnumlevels;i++){
1771 levelhighlight[i]=0;
1776 if(accountcampaignchoicesmade[accountactive])
1777 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1778 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1779 levelvisible[levelorder[i+1]]=1;
1781 int whichlevelstart;
1782 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1783 if(whichlevelstart<0){
1784 campaignchoicenum=1;
1785 campaignchoicewhich[0]=0;
1789 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1790 if(campaignchoicenum)
1791 for(i=0;i<campaignchoicenum;i++){
1792 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1793 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1794 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1801 if(firstload)TickOnceAfter();
1802 if(!firstload)LoadStuff();
1819 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1820 //accountcampaignchoicesmade[accountactive]++;
1823 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1831 FSOUND_SetPaused(channels[music3], true);
1835 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1836 if(mainmenu&&musictoggle){
1837 if(mainmenu==1||mainmenu==2||mainmenu==100){
1838 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
1839 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1840 FSOUND_SetPaused(channels[stream_music3], false);
1841 FSOUND_SetVolume(channels[stream_music3], 256);
1842 FSOUND_SetPaused(channels[music1], true);
1846 FSOUND_SetPaused(channels[stream_music3], true);
1847 FSOUND_SetPaused(channels[music1], false);
1851 float gLoc[3]={0,0,0};
1852 float vel[3]={0,0,0};
1853 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1854 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1855 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1856 FSOUND_SetVolume(channels[fireendsound], 256);
1857 FSOUND_SetPaused(channels[fireendsound], false);
1858 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1866 if(newdetail>2)newdetail=detail;
1867 if(newdetail<0)newdetail=detail;
1868 #if !USE_SDL // we'll take anything that works.
1869 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1870 if(newscreenheight>3000)newscreenheight=screenheight;
1872 if(newscreenwidth<0)newscreenwidth=screenwidth;
1873 if(newscreenheight<0)newscreenheight=screenheight;
1875 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1876 opstream << "Screenwidth:\n";
1877 opstream << newscreenwidth;
1878 opstream << "\nScreenheight:\n";
1879 opstream << newscreenheight;
1880 opstream << "\nMouse sensitivity:\n";
1881 opstream << usermousesensitivity;
1882 opstream << "\nBlur(0,1):\n";
1883 opstream << ismotionblur;
1884 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1885 opstream << newdetail;
1886 opstream << "\nFloating jump:\n";
1887 opstream << floatjump;
1888 opstream << "\nMouse jump:\n";
1889 opstream << mousejump;
1890 opstream << "\nAmbient sound:\n";
1891 opstream << ambientsound;
1892 opstream << "\nBlood (0,1,2):\n";
1893 opstream << bloodtoggle;
1894 opstream << "\nAuto slomo:\n";
1895 opstream << autoslomo;
1896 opstream << "\nFoliage:\n";
1897 opstream << foliage;
1898 opstream << "\nMusic:\n";
1899 opstream << musictoggle;
1900 opstream << "\nTrilinear:\n";
1901 opstream << trilinear;
1902 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1904 opstream << "\nInvert mouse:\n";
1905 opstream << invertmouse;
1906 opstream << "\nGamespeed:\n";
1907 if(oldgamespeed==0)oldgamespeed=1;
1908 opstream << oldgamespeed;
1909 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1910 opstream << difficulty;
1911 opstream << "\nDamage effects(blackout, doublevision):\n";
1912 opstream << damageeffects;
1913 opstream << "\nText:\n";
1914 opstream << texttoggle;
1915 opstream << "\nDebug:\n";
1916 opstream << debugmode;
1917 opstream << "\nVBL Sync:\n";
1918 opstream << vblsync;
1919 opstream << "\nShow Points:\n";
1920 opstream << showpoints;
1921 opstream << "\nAlways Blur:\n";
1922 opstream << alwaysblur;
1923 opstream << "\nImmediate mode (turn on on G5):\n";
1924 opstream << immediate;
1925 opstream << "\nVelocity blur:\n";
1926 opstream << velocityblur;
1927 opstream << "\nVolume:\n";
1929 opstream << "\nForward key:\n";
1930 opstream << KeyToChar(forwardkey);
1931 opstream << "\nBack key:\n";
1932 opstream << KeyToChar(backkey);
1933 opstream << "\nLeft key:\n";
1934 opstream << KeyToChar(leftkey);
1935 opstream << "\nRight key:\n";
1936 opstream << KeyToChar(rightkey);
1937 opstream << "\nJump key:\n";
1938 opstream << KeyToChar(jumpkey);
1939 opstream << "\nCrouch key:\n";
1940 opstream << KeyToChar(crouchkey);
1941 opstream << "\nDraw key:\n";
1942 opstream << KeyToChar(drawkey);
1943 opstream << "\nThrow key:\n";
1944 opstream << KeyToChar(throwkey);
1945 opstream << "\nAttack key:\n";
1946 opstream << KeyToChar(attackkey);
1947 opstream << "\nChat key:\n";
1948 opstream << KeyToChar(chatkey);
1951 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1952 float gLoc[3]={0,0,0};
1953 float vel[3]={0,0,0};
1954 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1955 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1956 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1957 FSOUND_SetVolume(channels[fireendsound], 256);
1958 FSOUND_SetPaused(channels[fireendsound], false);
1959 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1967 if(mainmenu==3&&gameon)mainmenu=2;
1968 if(mainmenu==3&&!gameon)mainmenu=1;
1969 if(mainmenu==5&&gameon)mainmenu=2;
1970 if(mainmenu==5&&!gameon)mainmenu=1;
1971 if(mainmenu==4)mainmenu=3;
1972 if(mainmenu==6)mainmenu=5;
1973 if(mainmenu==7)mainmenu=1;
1974 if(mainmenu==9)mainmenu=5;
1975 if(mainmenu==11)mainmenu=5;
1976 if(mainmenu==12)mainmenu=5;
1977 if(mainmenu==13)mainmenu=12;
1978 if(mainmenu==14)mainmenu=13;
1979 if(mainmenu==10)mainmenu=5;
1985 mainmenutogglekeydown=1;
1987 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1988 mainmenutogglekeydown=0;
1992 /*static bool minimaptogglekeydown;
1993 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1995 minimaptogglekeydown=1;
1997 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1998 minimaptogglekeydown=0;
2002 static bool minimaptogglekeydown;
2003 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
2004 if(tutorialstage!=51)
2005 tutorialstagetime=tutorialmaxtime;
2006 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
2007 FSOUND_SetVolume(channels[consolefailsound], 128);
2008 FSOUND_SetPaused(channels[consolefailsound], false);
2009 minimaptogglekeydown=1;
2011 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
2012 minimaptogglekeydown=0;
2017 if(mainmenu==1||mainmenu==2){
2018 if(Button()&&!oldbutton&&selected==1){
2020 float gLoc[3]={0,0,0};
2021 float vel[3]={0,0,0};
2022 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2023 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2024 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2025 FSOUND_SetVolume(channels[firestartsound], 256);
2026 FSOUND_SetPaused(channels[firestartsound], false);
2027 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2036 if(accountactive!=-1)mainmenu=5;
2043 if(firstload)TickOnceAfter();
2044 if(!firstload)LoadStuff();
2050 FSOUND_SetPaused(channels[music3], true); */
2056 FSOUND_SetPaused(channels[stream_music3], true);
2057 FSOUND_SetPaused(channels[music1], false);
2061 if(Button()&&!oldbutton&&selected==2){
2062 float gLoc[3]={0,0,0};
2063 float vel[3]={0,0,0};
2064 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2065 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2066 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2067 FSOUND_SetVolume(channels[firestartsound], 256);
2068 FSOUND_SetPaused(channels[firestartsound], false);
2069 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2081 if(newdetail>2)newdetail=detail;
2082 if(newdetail<0)newdetail=detail;
2083 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2084 if(newscreenwidth<0)newscreenwidth=screenwidth;
2085 if(newscreenheight>3000)newscreenheight=screenheight;
2086 if(newscreenheight<0)newscreenheight=screenheight;
2089 if(Button()&&!oldbutton&&selected==3){
2090 float gLoc[3]={0,0,0};
2091 float vel[3]={0,0,0};
2092 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2093 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2094 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2095 FSOUND_SetVolume(channels[fireendsound], 256);
2096 FSOUND_SetPaused(channels[fireendsound], false);
2097 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2108 if(registered)FSOUND_SetPaused(channels[stream_music3], true);
2116 if(Button())oldbutton=1;
2121 if(Button()&&!oldbutton&&selected!=-1){
2122 float gLoc[3]={0,0,0};
2123 float vel[3]={0,0,0};
2124 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2125 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2126 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2127 FSOUND_SetVolume(channels[firestartsound], 256);
2128 FSOUND_SetPaused(channels[firestartsound], false);
2129 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2131 if(Button()&&!oldbutton&&selected==0){
2133 extern SDL_Rect **resolutions;
2134 bool isCustomResolution = true;
2136 for (int i = 0; (!found) && (resolutions[i]); i++)
2138 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2139 isCustomResolution = false;
2141 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2144 if (resolutions[i] != NULL)
2146 newscreenwidth = (int) resolutions[i]->w;
2147 newscreenheight = (int) resolutions[i]->h;
2149 else if (isCustomResolution)
2151 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2153 newscreenwidth = (int) resolutions[0]->w;
2154 newscreenheight = (int) resolutions[0]->h;
2158 newscreenwidth = screenwidth;
2159 newscreenheight = screenheight;
2164 newscreenwidth = (int) resolutions[0]->w;
2165 newscreenheight = (int) resolutions[0]->h;
2173 newscreenwidth = (int) resolutions[0]->w;
2174 newscreenheight = (int) resolutions[0]->h;
2180 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2181 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2182 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2183 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2184 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2185 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2186 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2187 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2188 if(newscreenwidth==1920&&newscreenheight==1200)whichres=8;
2190 if(whichres==-1||whichres==8){
2192 newscreenheight=480;
2196 newscreenheight=600;
2199 newscreenwidth=1024;
2200 newscreenheight=768;
2203 newscreenwidth=1280;
2204 newscreenheight=1024;
2207 newscreenwidth=1600;
2208 newscreenheight=1200;
2212 newscreenheight=524;
2215 newscreenwidth=1024;
2216 newscreenheight=640;
2219 newscreenwidth=1344;
2220 newscreenheight=840;
2223 newscreenwidth=1920;
2224 newscreenheight=1200;
2228 if(Button()&&!oldbutton&&selected==1){
2230 if(newdetail>2)newdetail=0;
2232 if(Button()&&!oldbutton&&selected==2){
2234 if(bloodtoggle>2)bloodtoggle=0;
2236 if(Button()&&!oldbutton&&selected==3){
2238 if(difficulty>2)difficulty=0;
2240 if(Button()&&!oldbutton&&selected==4){
2241 ismotionblur=1-ismotionblur;
2243 if(Button()&&!oldbutton&&selected==5){
2246 if(Button()&&!oldbutton&&selected==6){
2247 musictoggle=1-musictoggle;
2250 FSOUND_SetPaused(channels[music1], true);
2251 FSOUND_SetPaused(channels[stream_music2], true);
2252 FSOUND_SetPaused(channels[stream_music3], true);
2255 oldmusicvolume[i]=0;
2261 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2262 FSOUND_SetPaused(channels[stream_music3], false);
2263 FSOUND_SetVolume(channels[stream_music3], 256);
2266 if(Button()&&!oldbutton&&selected==9){
2267 invertmouse=1-invertmouse;
2269 if(Button()&&!oldbutton&&selected==10){
2270 usermousesensitivity+=.2;
2271 if(usermousesensitivity>2)usermousesensitivity=.2;
2273 if(Button()&&!oldbutton&&selected==11){
2275 if(volume>1.0001f)volume=0;
2276 FSOUND_SetSFXMasterVolume((int)(volume*255));
2278 if(Button()&&!oldbutton&&selected==7){
2279 /*float gLoc[3]={0,0,0};
2280 float vel[3]={0,0,0};
2281 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2282 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2283 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2284 FSOUND_SetVolume(channels[firestartsound], 256);
2285 FSOUND_SetPaused(channels[firestartsound], false);
2286 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2299 if(Button()&&!oldbutton&&selected==8){
2300 float gLoc[3]={0,0,0};
2301 float vel[3]={0,0,0};
2302 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2303 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2304 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2305 FSOUND_SetVolume(channels[fireendsound], 256);
2306 FSOUND_SetPaused(channels[fireendsound], false);
2307 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2315 if(newdetail>2)newdetail=detail;
2316 if(newdetail<0)newdetail=detail;
2317 #if !USE_SDL // we'll take anything that works.
2318 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2319 if(newscreenheight>3000)newscreenheight=screenheight;
2321 if(newscreenwidth<0)newscreenwidth=screenwidth;
2322 if(newscreenheight<0)newscreenheight=screenheight;
2325 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2326 opstream << "Screenwidth:\n";
2327 opstream << newscreenwidth;
2328 opstream << "\nScreenheight:\n";
2329 opstream << newscreenheight;
2330 opstream << "\nMouse sensitivity:\n";
2331 opstream << usermousesensitivity;
2332 opstream << "\nBlur(0,1):\n";
2333 opstream << ismotionblur;
2334 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2335 opstream << newdetail;
2336 opstream << "\nFloating jump:\n";
2337 opstream << floatjump;
2338 opstream << "\nMouse jump:\n";
2339 opstream << mousejump;
2340 opstream << "\nAmbient sound:\n";
2341 opstream << ambientsound;
2342 opstream << "\nBlood (0,1,2):\n";
2343 opstream << bloodtoggle;
2344 opstream << "\nAuto slomo:\n";
2345 opstream << autoslomo;
2346 opstream << "\nFoliage:\n";
2347 opstream << foliage;
2348 opstream << "\nMusic:\n";
2349 opstream << musictoggle;
2350 opstream << "\nTrilinear:\n";
2351 opstream << trilinear;
2352 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2354 opstream << "\nInvert mouse:\n";
2355 opstream << invertmouse;
2356 opstream << "\nGamespeed:\n";
2357 if(oldgamespeed==0)oldgamespeed=1;
2358 opstream << oldgamespeed;
2359 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2360 opstream << difficulty;
2361 opstream << "\nDamage effects(blackout, doublevision):\n";
2362 opstream << damageeffects;
2363 opstream << "\nText:\n";
2364 opstream << texttoggle;
2365 opstream << "\nDebug:\n";
2366 opstream << debugmode;
2367 opstream << "\nVBL Sync:\n";
2368 opstream << vblsync;
2369 opstream << "\nShow Points:\n";
2370 opstream << showpoints;
2371 opstream << "\nAlways Blur:\n";
2372 opstream << alwaysblur;
2373 opstream << "\nImmediate mode (turn on on G5):\n";
2374 opstream << immediate;
2375 opstream << "\nVelocity blur:\n";
2376 opstream << velocityblur;
2377 opstream << "\nVolume:\n";
2379 opstream << "\nForward key:\n";
2380 opstream << KeyToChar(forwardkey);
2381 opstream << "\nBack key:\n";
2382 opstream << KeyToChar(backkey);
2383 opstream << "\nLeft key:\n";
2384 opstream << KeyToChar(leftkey);
2385 opstream << "\nRight key:\n";
2386 opstream << KeyToChar(rightkey);
2387 opstream << "\nJump key:\n";
2388 opstream << KeyToChar(jumpkey);
2389 opstream << "\nCrouch key:\n";
2390 opstream << KeyToChar(crouchkey);
2391 opstream << "\nDraw key:\n";
2392 opstream << KeyToChar(drawkey);
2393 opstream << "\nThrow key:\n";
2394 opstream << KeyToChar(throwkey);
2395 opstream << "\nAttack key:\n";
2396 opstream << KeyToChar(attackkey);
2397 opstream << "\nChat key:\n";
2398 opstream << KeyToChar(chatkey);
2401 if(mainmenu==3&&gameon)mainmenu=2;
2402 if(mainmenu==3&&!gameon)mainmenu=1;
2404 if(Button())oldbutton=1;
2408 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2409 float gLoc[3]={0,0,0};
2410 float vel[3]={0,0,0};
2411 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2412 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2413 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2414 FSOUND_SetVolume(channels[firestartsound], 256);
2415 FSOUND_SetPaused(channels[firestartsound], false);
2416 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2418 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2426 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2428 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2429 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2430 float gLoc[3]={0,0,0};
2431 float vel[3]={0,0,0};
2432 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2433 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2434 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2435 FSOUND_SetVolume(channels[fireendsound], 256);
2436 FSOUND_SetPaused(channels[fireendsound], false);
2437 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2441 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2442 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2446 if(keyselect==0)forwardkey=keynum;
2447 if(keyselect==1)backkey=keynum;
2448 if(keyselect==2)leftkey=keynum;
2449 if(keyselect==3)rightkey=keynum;
2450 if(keyselect==4)crouchkey=keynum;
2451 if(keyselect==5)jumpkey=keynum;
2452 if(keyselect==6)drawkey=keynum;
2453 if(keyselect==7)throwkey=keynum;
2454 if(keyselect==8)attackkey=keynum;
2459 if(Button()&&!oldbutton&&selected==9){
2460 float gLoc[3]={0,0,0};
2461 float vel[3]={0,0,0};
2462 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2463 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2464 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2465 FSOUND_SetVolume(channels[fireendsound], 256);
2466 FSOUND_SetPaused(channels[fireendsound], false);
2467 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2477 if(newdetail>2)newdetail=detail;
2478 if(newdetail<0)newdetail=detail;
2479 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2480 if(newscreenwidth<0)newscreenwidth=screenwidth;
2481 if(newscreenheight>3000)newscreenheight=screenheight;
2482 if(newscreenheight<0)newscreenheight=screenheight;
2487 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2488 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
2489 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2490 FSOUND_SetPaused(channels[stream_music3], false);
2491 FSOUND_SetVolume(channels[stream_music3], 256);
2495 accountcampaignchoicesmade[accountactive]=0;
2496 accountcampaignscore[accountactive]=0;
2497 accountcampaigntime[accountactive]=0;
2499 float gLoc[3]={0,0,0};
2500 float vel[3]={0,0,0};
2501 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2502 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2503 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2504 FSOUND_SetVolume(channels[fireendsound], 256);
2505 FSOUND_SetPaused(channels[fireendsound], false);
2506 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2516 accountcampaignchoicesmade[accountactive]=0;
2517 accountcampaignscore[accountactive]=0;
2518 accountcampaigntime[accountactive]=0;
2522 if(Button()&&!oldbutton&&selected==1){
2523 float gLoc[3]={0,0,0};
2524 float vel[3]={0,0,0};
2525 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2526 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2527 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2528 FSOUND_SetVolume(channels[firestartsound], 256);
2529 FSOUND_SetPaused(channels[firestartsound], false);
2530 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2543 if(firstload)TickOnceAfter();
2544 if(!firstload)LoadStuff();
2551 FSOUND_SetPaused(channels[stream_music3], true);
2553 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2554 float gLoc[3]={0,0,0};
2555 float vel[3]={0,0,0};
2556 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2557 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2558 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2559 FSOUND_SetVolume(channels[firestartsound], 256);
2560 FSOUND_SetPaused(channels[firestartsound], false);
2561 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2574 if(firstload)TickOnceAfter();
2575 if(!firstload)LoadStuff();
2591 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2592 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2596 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2601 FSOUND_SetPaused(channels[stream_music3], true);
2603 if(Button()&&!oldbutton&&selected==4){
2604 float gLoc[3]={0,0,0};
2605 float vel[3]={0,0,0};
2606 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2607 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2608 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2609 FSOUND_SetVolume(channels[fireendsound], 256);
2610 FSOUND_SetPaused(channels[fireendsound], false);
2611 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2619 if(mainmenu==5&&gameon)mainmenu=2;
2620 if(mainmenu==5&&!gameon)mainmenu=1;
2622 if(Button()&&!oldbutton&&selected==5){
2623 float gLoc[3]={0,0,0};
2624 float vel[3]={0,0,0};
2625 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2626 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2627 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2628 FSOUND_SetVolume(channels[fireendsound], 256);
2629 FSOUND_SetPaused(channels[fireendsound], false);
2630 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2640 if(Button()&&!oldbutton&&selected==3){
2641 float gLoc[3]={0,0,0};
2642 float vel[3]={0,0,0};
2643 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2644 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2645 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2646 FSOUND_SetVolume(channels[firestartsound], 256);
2647 FSOUND_SetPaused(channels[firestartsound], false);
2648 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2658 if(Button()&&!oldbutton&&selected==2){
2659 float gLoc[3]={0,0,0};
2660 float vel[3]={0,0,0};
2661 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2662 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2663 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2664 FSOUND_SetVolume(channels[firestartsound], 256);
2665 FSOUND_SetPaused(channels[firestartsound], false);
2666 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2676 if(Button())oldbutton=1;
2680 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2681 float gLoc[3]={0,0,0};
2682 float vel[3]={0,0,0};
2683 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2684 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2685 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2686 FSOUND_SetVolume(channels[firestartsound], 256);
2687 FSOUND_SetPaused(channels[firestartsound], false);
2688 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2700 targetlevel=selected;
2701 if(firstload)TickOnceAfter();
2702 if(!firstload)LoadStuff();
2704 Loadlevel(selected);
2710 FSOUND_SetPaused(channels[stream_music3], true);
2712 if(Button()&&!oldbutton&&selected==numchallengelevels){
2713 float gLoc[3]={0,0,0};
2714 float vel[3]={0,0,0};
2715 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2716 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2717 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2718 FSOUND_SetVolume(channels[fireendsound], 256);
2719 FSOUND_SetPaused(channels[fireendsound], false);
2720 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2730 if(Button())oldbutton=1;
2734 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2735 float gLoc[3]={0,0,0};
2736 float vel[3]={0,0,0};
2737 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2738 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2739 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2740 FSOUND_SetVolume(channels[firestartsound], 256);
2741 FSOUND_SetPaused(channels[firestartsound], false);
2742 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2754 targetlevel=selected;
2755 if(firstload)TickOnceAfter();
2756 if(!firstload)LoadStuff();
2758 Loadlevel(selected);
2764 FSOUND_SetPaused(channels[stream_music3], true);
2766 if(Button()&&!oldbutton&&selected==numchallengelevels){
2767 float gLoc[3]={0,0,0};
2768 float vel[3]={0,0,0};
2769 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2770 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2771 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2772 FSOUND_SetVolume(channels[fireendsound], 256);
2773 FSOUND_SetPaused(channels[fireendsound], false);
2774 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2784 if(Button())oldbutton=1;
2789 if(Button()&&!oldbutton&&selected==3){
2790 float gLoc[3]={0,0,0};
2791 float vel[3]={0,0,0};
2792 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2793 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2794 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2795 FSOUND_SetVolume(channels[fireendsound], 256);
2796 FSOUND_SetPaused(channels[fireendsound], false);
2797 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2807 if(Button())oldbutton=1;
2811 if(mainmenu==15||mainmenu==16){
2812 if(Button()&&!oldbutton&&selected==1){
2813 float gLoc[3]={0,0,0};
2814 float vel[3]={0,0,0};
2815 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2816 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2817 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2818 FSOUND_SetVolume(channels[fireendsound], 256);
2819 FSOUND_SetPaused(channels[fireendsound], false);
2820 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2828 if(mainmenu==15)mainmenu=5;
2831 if(Button())oldbutton=1;
2837 if(Button()&&!oldbutton&&selected==3){
2839 float gLoc[3]={0,0,0};
2840 float vel[3]={0,0,0};
2841 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2842 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2843 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2844 FSOUND_SetVolume(channels[fireendsound], 256);
2845 FSOUND_SetPaused(channels[fireendsound], false);
2846 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2857 if(Button()&&!oldbutton&&selected==4){
2860 float gLoc[3]={0,0,0};
2861 float vel[3]={0,0,0};
2862 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2863 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2864 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2865 FSOUND_SetVolume(channels[fireendsound], 256);
2866 FSOUND_SetPaused(channels[fireendsound], false);
2867 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2877 if(Button()&&!oldbutton&&selected==5){
2879 float gLoc[3]={0,0,0};
2880 float vel[3]={0,0,0};
2881 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2882 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2883 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2884 FSOUND_SetVolume(channels[fireendsound], 256);
2885 FSOUND_SetPaused(channels[fireendsound], false);
2886 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2896 if(Button())oldbutton=1;
2900 if(Button()&&!oldbutton&&selected!=-1){
2901 float gLoc[3]={0,0,0};
2902 float vel[3]={0,0,0};
2903 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2904 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2905 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2906 FSOUND_SetVolume(channels[firestartsound], 256);
2907 FSOUND_SetPaused(channels[firestartsound], false);
2908 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2910 if(Button()&&!oldbutton&&selected==1){
2911 float gLoc[3]={0,0,0};
2912 float vel[3]={0,0,0};
2913 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2914 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2915 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2916 FSOUND_SetVolume(channels[fireendsound], 256);
2917 FSOUND_SetPaused(channels[fireendsound], false);
2918 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2926 for(i=accountactive;i<numaccounts-1;i++){
2927 accountdifficulty[i]=accountdifficulty[i+1];
2928 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2929 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2930 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2932 accountpoints[i]=accountpoints[i+1];
2934 accounthighscore[i][j]=accounthighscore[i+1][j];
2935 accountfasttime[i][j]=accountfasttime[i+1][j];
2938 accountunlocked[i][j]=accountunlocked[i+1][j];
2941 accountname[i][j]=accountname[i+1][j];
2943 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2944 accountprogress[i]=accountprogress[i+1];
2945 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2946 accountcampaignscore[i]=accountcampaignscore[i+1];
2947 accountcampaigntime[i]=accountcampaigntime[i+1];
2956 if(Button()&&!oldbutton&&selected==2){
2957 float gLoc[3]={0,0,0};
2958 float vel[3]={0,0,0};
2959 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2960 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2961 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2962 FSOUND_SetVolume(channels[fireendsound], 256);
2963 FSOUND_SetPaused(channels[fireendsound], false);
2964 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2974 if(Button())oldbutton=1;
2978 if(Button()&&!oldbutton&&selected!=-1){
2979 float gLoc[3]={0,0,0};
2980 float vel[3]={0,0,0};
2981 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2982 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2983 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2984 FSOUND_SetVolume(channels[firestartsound], 256);
2985 FSOUND_SetPaused(channels[firestartsound], false);
2986 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2988 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2991 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2992 accountactive=selected-1;
3000 if(Button()&&!oldbutton&&selected==numaccounts+1){
3001 float gLoc[3]={0,0,0};
3002 float vel[3]={0,0,0};
3003 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
3004 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
3005 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
3006 FSOUND_SetVolume(channels[fireendsound], 256);
3007 FSOUND_SetPaused(channels[fireendsound], false);
3008 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
3019 displaytext[0][j]=' ';
3025 if(Button())oldbutton=1;
3029 if(Button()&&!oldbutton&&selected!=-1){
3030 float gLoc[3]={0,0,0};
3031 float vel[3]={0,0,0};
3032 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3033 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3034 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3035 FSOUND_SetVolume(channels[firestartsound], 256);
3036 FSOUND_SetPaused(channels[firestartsound], false);
3037 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3039 if(selected==0)accountdifficulty[accountactive]=0;
3040 if(selected==1)accountdifficulty[accountactive]=1;
3041 if(selected==2)accountdifficulty[accountactive]=2;
3052 if(Button())oldbutton=1;
3057 if(Button())oldbutton=1;
3060 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
3063 if(newdetail>2)newdetail=detail;
3064 if(newdetail<0)newdetail=detail;
3065 #if !USE_SDL // we'll take anything that works.
3066 if(newscreenwidth>3000)newscreenwidth=screenwidth;
3067 if(newscreenheight>3000)newscreenheight=screenheight;
3069 if(newscreenwidth<0)newscreenwidth=screenwidth;
3070 if(newscreenheight<0)newscreenheight=screenheight;
3072 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
3073 opstream << "Screenwidth:\n";
3074 opstream << newscreenwidth;
3075 opstream << "\nScreenheight:\n";
3076 opstream << newscreenheight;
3077 opstream << "\nMouse sensitivity:\n";
3078 opstream << usermousesensitivity;
3079 opstream << "\nBlur(0,1):\n";
3080 opstream << ismotionblur;
3081 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
3082 opstream << newdetail;
3083 opstream << "\nFloating jump:\n";
3084 opstream << floatjump;
3085 opstream << "\nMouse jump:\n";
3086 opstream << mousejump;
3087 opstream << "\nAmbient sound:\n";
3088 opstream << ambientsound;
3089 opstream << "\nBlood (0,1,2):\n";
3090 opstream << bloodtoggle;
3091 opstream << "\nAuto slomo:\n";
3092 opstream << autoslomo;
3093 opstream << "\nFoliage:\n";
3094 opstream << foliage;
3095 opstream << "\nMusic:\n";
3096 opstream << musictoggle;
3097 opstream << "\nTrilinear:\n";
3098 opstream << trilinear;
3099 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3101 opstream << "\nInvert mouse:\n";
3102 opstream << invertmouse;
3103 opstream << "\nGamespeed:\n";
3104 if(oldgamespeed==0)oldgamespeed=1;
3105 opstream << oldgamespeed;
3106 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3107 opstream << difficulty;
3108 opstream << "\nDamage effects(blackout, doublevision):\n";
3109 opstream << damageeffects;
3110 opstream << "\nText:\n";
3111 opstream << texttoggle;
3112 opstream << "\nDebug:\n";
3113 opstream << debugmode;
3114 opstream << "\nVBL Sync:\n";
3115 opstream << vblsync;
3116 opstream << "\nShow Points:\n";
3117 opstream << showpoints;
3118 opstream << "\nAlways Blur:\n";
3119 opstream << alwaysblur;
3120 opstream << "\nImmediate mode (turn on on G5):\n";
3121 opstream << immediate;
3122 opstream << "\nVelocity blur:\n";
3123 opstream << velocityblur;
3124 opstream << "\nVolume:\n";
3126 opstream << "\nForward key:\n";
3127 opstream << KeyToChar(forwardkey);
3128 opstream << "\nBack key:\n";
3129 opstream << KeyToChar(backkey);
3130 opstream << "\nLeft key:\n";
3131 opstream << KeyToChar(leftkey);
3132 opstream << "\nRight key:\n";
3133 opstream << KeyToChar(rightkey);
3134 opstream << "\nJump key:\n";
3135 opstream << KeyToChar(jumpkey);
3136 opstream << "\nCrouch key:\n";
3137 opstream << KeyToChar(crouchkey);
3138 opstream << "\nDraw key:\n";
3139 opstream << KeyToChar(drawkey);
3140 opstream << "\nThrow key:\n";
3141 opstream << KeyToChar(throwkey);
3142 opstream << "\nAttack key:\n";
3143 opstream << KeyToChar(attackkey);
3144 opstream << "\nChat key:\n";
3145 opstream << KeyToChar(chatkey);
3150 if(mainmenu==1||mainmenu==2){
3151 if(loaddistrib>4)transition+=multiplier/8;
3159 FSOUND_SetFrequency(channels[stream_music3], 22050);
3161 if(entername||mainmenu==13||mainmenu==14){
3163 if(IsKeyDown(theKeyMap, i)){
3164 togglekeydelay[i]+=multiplier;
3165 if(togglekeydelay[i]>.4){
3167 togglekeydelay[i]=.36;
3170 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3171 for(j=255;j>=displayselected+1;j--){
3172 displaytext[0][j]=displaytext[0][j-1];
3174 displaytext[0][displayselected]=KeyToSingleChar(i);
3175 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3179 if(i==MAC_DELETE_KEY&&displayselected!=0){
3180 for(j=displayselected-1;j<255;j++){
3181 displaytext[0][j]=displaytext[0][j+1];
3183 displaytext[0][255]=' ';
3187 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3190 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3193 if(i==MAC_RETURN_KEY&&entername){
3194 if(displaychars[0]){
3196 strcpy(accountname[numaccounts-1],displaytext[0]);
3197 accountactive=numaccounts-1;
3198 accountdifficulty[accountactive]=1;
3199 accountprogress[accountactive]=0;
3200 accountpoints[accountactive]=0;
3201 accountcampaigntime[accountactive]=0;
3202 accountcampaignscore[accountactive]=0;
3203 accountcampaignfasttime[accountactive]=0;
3204 accountcampaignhighscore[accountactive]=0;
3206 accounthighscore[accountactive][j]=0;
3207 accountfasttime[accountactive][j]=0;
3210 accountunlocked[accountactive][j]=0;
3212 accountcampaignchoicesmade[accountactive]=0;
3215 displaytext[0][j]=' ';
3229 float gLoc[3]={0,0,0};
3230 float vel[3]={0,0,0};
3231 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3232 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3233 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3234 FSOUND_SetVolume(channels[firestartsound], 256);
3235 FSOUND_SetPaused(channels[firestartsound], false);
3236 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3239 displaytext[0][j]=' ';
3247 if(i==MAC_RETURN_KEY&&mainmenu==14){
3248 if(displaychars[0]){
3249 char serialstring[256];
3250 char tempstring[256];
3251 #if defined(__APPLE__)
3252 sprintf (tempstring, "%s", registrationname);
3253 #elif defined(_MSC_VER) || defined(__linux__)
3254 sprintf (tempstring, "%s-windows", registrationname);
3256 #error Please make sure you have the right registration key stuff here!
3263 longnum = MD5_string ( tempstring);
3264 //longnum = 1111111111111111;
3265 num1 = longnum/100000000;
3266 num2 = longnum%100000000;
3267 sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3271 if(num1/10000>999)numchars+=4;
3272 else if(num1/10000>99)numchars+=3;
3273 else if(num1/10000>9)numchars+=2;
3275 if(num1%10000>999)numchars+=4;
3276 else if(num1%10000>99)numchars+=3;
3277 else if(num1%10000>9)numchars+=2;
3279 if(num2/10000>999)numchars+=4;
3280 else if(num2/10000>99)numchars+=3;
3281 else if(num2/10000>9)numchars+=2;
3283 if(num2%10000>999)numchars+=4;
3284 else if(num2%10000>99)numchars+=3;
3285 else if(num2%10000>9)numchars+=2;
3290 for(j=0;j<numchars;j++){
3291 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3294 if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
3296 if(goodcode<0)goodcode=0;
3303 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3307 numchars=strlen(registrationname);
3308 fpackf(tfile, "Bb", registered);
3309 fpackf(tfile, "Bi", numchars);
3312 for(j=0;j<numchars;j++)
3314 fpackf(tfile, "Bb", registrationname[j]);
3317 fpackf(tfile, "Bi", num1);
3318 fpackf(tfile, "Bi", num2);
3332 float gLoc[3]={0,0,0};
3333 float vel[3]={0,0,0};
3334 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3335 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3336 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3337 FSOUND_SetVolume(channels[firestartsound], 256);
3338 FSOUND_SetPaused(channels[firestartsound], false);
3339 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3342 displaytext[0][j]=' ';
3348 if(i==MAC_RETURN_KEY&&mainmenu==13){
3349 if(displaychars[0]){
3350 sprintf (registrationname, "%s", displaytext[0]);
3351 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3361 float gLoc[3]={0,0,0};
3362 float vel[3]={0,0,0};
3363 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3364 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3365 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3366 FSOUND_SetVolume(channels[firestartsound], 256);
3367 FSOUND_SetPaused(channels[firestartsound], false);
3368 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3371 displaytext[0][j]=' ';
3375 /*char tempstring[50];
3376 sprintf (tempstring, registrationname);
3382 longnum = MD5_string ( tempstring);
3383 num1 = longnum/100000000;
3384 num2 = longnum%100000000;
3385 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3387 displaychars[0]=strlen(displaytext[0]);
3396 togglekeydelay[i]=0;
3400 displayblinkdelay-=multiplier;
3401 if(displayblinkdelay<=0){
3402 displayblinkdelay=.3;
3403 displayblink=1-displayblink;
3409 if(hostile==1)hostiletime+=multiplier;
3411 if(!winfreeze)leveltime+=multiplier;
3412 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3419 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3421 chattogglekeydown=1;
3422 togglekey[chatkey]=1;
3423 togglekeydelay[chatkey]=-20;
3426 if(!IsKeyDown(theKeyMap, chatkey)){
3427 chattogglekeydown=0;
3432 if(IsKeyDown(theKeyMap, i)){
3433 togglekeydelay[i]+=multiplier;
3434 if(togglekeydelay[i]>.4){
3436 togglekeydelay[i]=.36;
3439 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3440 for(j=255;j>=displayselected+1;j--){
3441 displaytext[0][j]=displaytext[0][j-1];
3443 displaytext[0][displayselected]=KeyToSingleChar(i);
3444 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3448 if(i==MAC_DELETE_KEY&&displayselected!=0){
3449 for(j=displayselected-1;j<255;j++){
3450 displaytext[0][j]=displaytext[0][j+1];
3452 displaytext[0][255]=' ';
3456 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3459 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3462 if(i==MAC_RETURN_KEY){
3463 if(displaychars[0]){
3464 /*for(j=0;j<displaychars[0];j++){
3465 talkname[j]=displaytext[0][j];
3467 talkname[displaychars[0]]='\0';
3468 sprintf (chatname, "%s: %s",playerName,talkname);
3469 //NetworkSendInformation(chatname);
3472 displaytext[0][j]=' ';
3484 togglekeydelay[i]=0;
3488 displayblinkdelay-=multiplier;
3489 if(displayblinkdelay<=0){
3490 displayblinkdelay=.3;
3491 displayblink=1-displayblink;
3495 if(chatting)keyboardfrozen=1;
3497 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3500 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3502 freezetogglekeydown=1;
3505 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3506 freezetogglekeydown=0;
3509 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3511 if(!console)freeze=0;
3513 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3515 consoletogglekeydown=1;
3518 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3519 consoletogglekeydown=0;
3522 if(console)freeze=1;
3524 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3526 if(IsKeyDown(theKeyMap, i)){
3527 togglekeydelay[i]+=multiplier;
3528 if(togglekeydelay[i]>.4){
3530 togglekeydelay[i]=.36;
3533 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3534 for(j=255;j>=consoleselected+1;j--){
3535 consoletext[0][j]=consoletext[0][j-1];
3537 consoletext[0][consoleselected]=KeyToSingleChar(i);
3538 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3542 else if(i==MAC_ENTER_KEY){
3543 for(j=255;j>=consoleselected+1;j--){
3544 consoletext[0][j]=consoletext[0][j-1];
3546 consoletext[0][consoleselected]='\n';
3550 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3551 for(j=consoleselected-1;j<255;j++){
3552 consoletext[0][j]=consoletext[0][j+1];
3554 consoletext[0][255]=' ';
3558 if(i==MAC_ARROW_UP_KEY){
3559 if(archiveselected<14)archiveselected++;
3561 consolechars[0]=consolechars[archiveselected];
3562 consoletext[0][j]=consoletext[archiveselected][j];
3563 consoleselected=consolechars[0];
3566 if(i==MAC_ARROW_DOWN_KEY){
3567 if(archiveselected>0)archiveselected--;
3569 consolechars[0]=consolechars[archiveselected];
3570 consoletext[0][j]=consoletext[archiveselected][j];
3571 consoleselected=consolechars[0];
3574 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3577 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3580 if(i==MAC_RETURN_KEY){
3583 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3584 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3585 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3586 FSOUND_SetPaused(channels[consolesuccesssound], false);
3590 /*if(Compare(consoletext[0],"send ",0,4)){
3591 for(j=5;j<consolechars[0];j++){
3592 talkname[j-5]=consoletext[0][j];
3594 talkname[consolechars[0]-5]='\0';
3595 sprintf (chatname, "%s: %s",playerName,talkname);
3596 //NetworkSendInformation(chatname);
3599 if(Compare(consoletext[0],"name ",0,4)){
3601 numchars=consolechars[0]-5;
3602 if(numchars>32)numchars=32;
3603 for(j=5;j<numchars+5;j++){
3604 talkname[j-5]=consoletext[0][j];
3606 talkname[numchars]='\0';
3607 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3608 //NetworkSendInformation(chatname);
3609 sprintf (playerName, "%s",talkname);
3610 //NetworkSendName(playerName);
3613 if(Compare(consoletext[0],"map ",0,3)){
3625 for(j=4;j<consolechars[0];j++){
3626 mapname[j-4+11]=consoletext[0][j];
3628 mapname[consolechars[0]-4+11]='\0';
3634 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3636 unsigned char playerNameStr[32];
3637 char theIPAddress[256];
3639 NMUInt32 port = 25710;
3641 strcpy(playerName, "Client");
3642 GameC2PStr( playerName, playerNameStr );
3644 for(j=0;j<consolechars[0]-8;j++){
3645 theIPAddress[j]=consoletext[0][j+8];
3647 theIPAddress[consolechars[0]-8]='\0';
3649 sprintf( thePort, "%li", port );
3650 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3653 if(consolechars[0]>0){
3656 consoletext[k][j]=consoletext[k-1][j];
3658 consolechars[k]=consolechars[k-1];
3661 consoletext[0][j]=' ';
3663 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3664 else sprintf (consoletext[0], "Could not open connection");
3666 consolechars[0]=255;
3673 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3674 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3675 FSOUND_SetPaused(channels[consolesuccesssound], false);
3677 if(consolechars[0]>0){
3680 consoletext[k][j]=consoletext[k-1][j];
3682 consolechars[k]=consolechars[k-1];
3685 consoletext[0][j]=' ';
3687 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3689 consolechars[0]=255;
3695 if(Compare(consoletext[0],"host ",0,4)){
3696 unsigned char gameNameStr[32], playerNameStr[32];
3697 char gameName[32];//, playerName[32];
3705 strcpy(gameName, "Host's game");
3706 strcpy(playerName, "Host");
3707 GameC2PStr( gameName, gameNameStr );
3708 GameC2PStr( playerName, playerNameStr );
3710 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3713 if(consolechars[0]>0){
3716 consoletext[k][j]=consoletext[k-1][j];
3718 consolechars[k]=consolechars[k-1];
3721 consoletext[0][j]=' ';
3723 sprintf (consoletext[0], "Error #%d!!!",v);
3725 consolechars[0]=255;
3732 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3733 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3734 FSOUND_SetPaused(channels[consolesuccesssound], false);
3736 if(consolechars[0]>0){
3739 consoletext[k][j]=consoletext[k-1][j];
3741 consolechars[k]=consolechars[k-1];
3744 consoletext[0][j]=' ';
3746 sprintf (consoletext[0], "Game hosted");
3748 consolechars[0]=255;
3754 if(Compare(consoletext[0],"save ",0,4)){
3766 for(j=5;j<consolechars[0];j++){
3767 mapname[j-5+11]=consoletext[0][j];
3769 mapname[consolechars[0]-5+11]='\0';
3771 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3772 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3773 FSOUND_SetPaused(channels[consolesuccesssound], false);
3780 tfile=fopen( mapname, "wb" );
3781 fpackf(tfile, "Bi", mapvers);
3782 //fpackf(tfile, "Bi", indemo);
3783 fpackf(tfile, "Bi", maptype);
3784 fpackf(tfile, "Bi", hostile);
3785 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3786 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3787 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3788 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);
3789 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3790 for(j=0;j<player[0].num_weapons;j++){
3791 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3794 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3795 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3796 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3797 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3799 fpackf(tfile, "Bi", player[0].numclothes);
3801 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3803 fpackf(tfile, "Bi", numdialogues);
3805 for(k=0;k<numdialogues;k++){
3806 fpackf(tfile, "Bi", numdialogueboxes[k]);
3807 fpackf(tfile, "Bi", dialoguetype[k]);
3809 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3810 fpackf(tfile, "Bf", participantrotation[k][l]);
3812 if(numdialogueboxes)
3813 for(l=0;l<numdialogueboxes[k];l++){
3814 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3815 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3816 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3817 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3818 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3820 templength=strlen(dialoguetext[k][l]);
3821 fpackf(tfile, "Bi",(templength));
3822 for(m=0;m<templength;m++){
3823 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3824 if(dialoguetext[k][l][m]=='\0')break;
3827 templength=strlen(dialoguename[k][l]);
3828 fpackf(tfile, "Bi",templength);
3829 for(m=0;m<templength;m++){
3830 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3831 if(dialoguename[k][l][m]=='\0')break;
3834 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3835 fpackf(tfile, "Bi", participantfocus[k][l]);
3836 fpackf(tfile, "Bi", participantaction[k][l]);
3839 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3841 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3845 if(player[0].numclothes)
3846 for(k=0;k<player[0].numclothes;k++){
3847 templength=strlen(player[0].clothes[k]);
3848 fpackf(tfile, "Bi", templength);
3849 for(l=0;l<templength;l++)
3850 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3851 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3854 fpackf(tfile, "Bi", environment);
3856 fpackf(tfile, "Bi", objects.numobjects);
3858 if(objects.numobjects)
3859 for(k=0;k<objects.numobjects;k++){
3860 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]);
3863 fpackf(tfile, "Bi", numhotspots);
3865 for(i=0;i<numhotspots;i++){
3866 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3867 templength=strlen(hotspottext[i]);
3868 fpackf(tfile, "Bi",templength);
3869 for(l=0;l<templength;l++)
3870 fpackf(tfile, "Bb", hotspottext[i][l]);
3873 fpackf(tfile, "Bi", numplayers);
3874 if(numplayers>1&&numplayers<maxplayers)
3875 for(j=1;j<numplayers;j++){
3876 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);
3877 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3878 for(k=0;k<player[j].num_weapons;k++){
3879 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3881 if(player[j].numwaypoints<30){
3882 fpackf(tfile, "Bi", player[j].numwaypoints);
3883 for(k=0;k<player[j].numwaypoints;k++){
3884 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3885 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3886 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3887 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3889 fpackf(tfile, "Bi", player[j].waypoint);
3892 player[j].numwaypoints=0;
3893 player[j].waypoint=0;
3894 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3897 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3898 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3899 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3900 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3902 if(player[j].creature==wolftype){
3903 headprop=player[j].proportionhead.x/1.1;
3904 bodyprop=player[j].proportionbody.x/1.1;
3905 armprop=player[j].proportionarms.x/1.1;
3906 legprop=player[j].proportionlegs.x/1.1;
3909 if(player[j].creature==rabbittype){
3910 headprop=player[j].proportionhead.x/1.2;
3911 bodyprop=player[j].proportionbody.x/1.05;
3912 armprop=player[j].proportionarms.x/1.00;
3913 legprop=player[j].proportionlegs.x/1.1;
3916 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3920 fpackf(tfile, "Bi", player[j].numclothes);
3921 if(player[j].numclothes)
3922 for(k=0;k<player[j].numclothes;k++){
3924 templength=strlen(player[j].clothes[k]);
3925 fpackf(tfile, "Bi", templength);
3926 for(l=0;l<templength;l++)
3927 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3928 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3932 fpackf(tfile, "Bi", numpathpoints);
3934 for(j=0;j<numpathpoints;j++){
3935 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3936 for(k=0;k<numpathpointconnect[j];k++){
3937 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3941 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3949 tfile=fopen( mapname, "wb" );
3950 fwrite( &mapvers, 1, sizeof(int), tfile );
3951 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3952 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3953 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3954 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3955 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3956 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3957 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3958 for(j=0;j<player[0].num_weapons;j++){
3959 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3962 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3963 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3964 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3965 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3966 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3967 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3968 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3969 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3970 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3971 fwrite( &player[0].power, 1, sizeof(int), tfile );
3972 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3974 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3975 if(player[0].numclothes)
3976 for(k=0;k<player[0].numclothes;k++){
3978 templength=strlen(player[0].clothes[k]);
3979 fwrite( &templength,1,sizeof(int),tfile);
3980 for(l=0;l<templength;l++)
3981 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3982 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3983 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3984 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3987 fwrite( &environment, 1, sizeof(int), tfile );
3989 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3991 for(k=0;k<objects.numobjects;k++){
3992 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3993 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3994 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3995 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3996 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3997 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3998 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
4001 fwrite( &numplayers, 1, sizeof(int), tfile );
4002 if(numplayers>1&&numplayers<maxplayers)
4003 for(j=1;j<numplayers;j++){
4004 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
4005 fwrite( &player[j].creature, 1, sizeof(int), tfile );
4006 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
4007 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
4008 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
4009 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4010 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4011 for(k=0;k<player[j].num_weapons;k++){
4012 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4014 if(player[j].numwaypoints<30){
4015 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4016 for(k=0;k<player[j].numwaypoints;k++){
4017 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
4018 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
4019 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
4021 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4022 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4025 player[j].numwaypoints=0;
4026 player[j].waypoint=0;
4027 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4028 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4029 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4031 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
4032 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
4033 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
4034 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
4035 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
4036 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
4037 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
4038 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
4039 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
4040 fwrite( &player[j].power, 1, sizeof(int), tfile );
4041 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
4043 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
4044 if(player[j].numclothes)
4045 for(k=0;k<player[j].numclothes;k++){
4047 templength=strlen(player[j].clothes[k]);
4048 fwrite( &templength,1,sizeof(int),tfile);
4049 for(l=0;l<templength;l++)
4050 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
4051 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
4052 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
4053 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
4056 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4058 for(j=0;j<numpathpoints;j++){
4059 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
4060 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
4061 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
4062 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4063 for(k=0;k<numpathpointconnect[j];k++){
4064 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4068 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
4069 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
4070 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
4072 fwrite( &mapradius, 1, sizeof(float), tfile );
4078 if(Compare(consoletext[0],"save ",0,4)){
4090 for(j=5;j<consolechars[0];j++){
4091 mapname[j-5+11]=consoletext[0][j];
4093 mapname[consolechars[0]-5+11]='\0';
4095 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
4096 FSOUND_SetVolume(channels[consolesuccesssound], 256);
4097 FSOUND_SetPaused(channels[consolesuccesssound], false);
4100 tfile=fopen( mapname, "wb" );
4101 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4102 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4103 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4104 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4105 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4106 for(j=0;j<player[0].num_weapons;j++){
4107 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4109 fwrite( &environment, 1, sizeof(int), tfile );
4111 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4112 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4113 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4114 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4115 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4117 fwrite( &numplayers, 1, sizeof(int), tfile );
4118 if(numplayers>1&&numplayers<maxplayers)
4119 for(j=1;j<numplayers;j++){
4120 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4121 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4122 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4123 for(k=0;k<player[j].num_weapons;k++){
4124 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4126 if(player[j].numwaypoints<30){
4127 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4128 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4129 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4130 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4133 player[j].numwaypoints=0;
4134 player[j].waypoint=0;
4135 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4136 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4137 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4140 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4142 for(j=0;j<numpathpoints;j++){
4143 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4144 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4145 for(k=0;k<numpathpointconnect[j];k++){
4146 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4152 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4153 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4156 /*if(Compare(consoletext[0],"Pants ",0,5)){
4157 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4158 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4162 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4163 for(j=6;j<consolechars[0];j++){
4164 mapname[j-6]=consoletext[0][j];
4167 tintr=atof(mapname);
4172 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4173 for(j=6;j<consolechars[0];j++){
4174 mapname[j-6]=consoletext[0][j];
4177 player[0].speedmult=atof(mapname);
4182 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4183 for(j=9;j<consolechars[0];j++){
4184 mapname[j-9]=consoletext[0][j];
4187 player[0].power=atof(mapname);
4192 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4193 for(j=13;j<consolechars[0];j++){
4194 mapname[j-13]=consoletext[0][j];
4197 viewdistance=atof(mapname)*100;
4202 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4203 for(j=10;j<consolechars[0];j++){
4204 mapname[j-10]=consoletext[0][j];
4207 fadestart=atof(mapname);
4212 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4213 for(j=6;j<consolechars[0];j++){
4214 mapname[j-6]=consoletext[0][j];
4217 player[0].power=atof(mapname);
4222 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4223 for(j=6;j<consolechars[0];j++){
4224 mapname[j-6]=consoletext[0][j];
4227 slomospeed=atof(mapname);
4234 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4235 for(j=8;j<consolechars[0];j++){
4236 mapname[j-8]=consoletext[0][j];
4239 slomofreq=atoi(mapname);
4244 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4245 for(j=5;j<consolechars[0];j++){
4246 mapname[j-5]=consoletext[0][j];
4249 player[0].scale=atof(mapname)*.2;
4254 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4256 float closestdist=-1;
4259 for(i=1;i<numplayers;i++){
4260 distance=findDistancefast(&player[i].coords,&player[0].coords);
4261 if(closestdist==-1||distance<closestdist){
4262 closestdist=distance;
4267 for(j=9;j<consolechars[0];j++){
4268 mapname[j-9]=consoletext[0][j];
4271 player[closest].scale=atof(mapname)*.2;
4276 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4281 float closestdist=-1;
4284 for(i=1;i<numplayers;i++){
4285 distance=findDistancefast(&player[i].coords,&player[0].coords);
4286 if(closestdist==-1||distance<closestdist){
4287 closestdist=distance;
4295 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4296 mapname[j-startpoint]=consoletext[0][j];
4298 if(consoletext[0][j]=='\0')alldone=1;
4300 mapname[j-startpoint]='\0';
4302 headprop=atof(mapname);
4306 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4307 mapname[j-startpoint]=consoletext[0][j];
4309 if(consoletext[0][j]=='\0')alldone=1;
4311 mapname[j-startpoint]='\0';
4313 bodyprop=atof(mapname);
4317 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4318 mapname[j-startpoint]=consoletext[0][j];
4320 if(consoletext[0][j]=='\0')alldone=1;
4322 mapname[j-startpoint]='\0';
4324 armprop=atof(mapname);
4328 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4329 mapname[j-startpoint]=consoletext[0][j];
4331 if(consoletext[0][j]=='\0')alldone=1;
4333 mapname[j-startpoint]='\0';
4335 legprop=atof(mapname);
4337 if(player[closest].creature==wolftype){
4338 player[closest].proportionhead=1.1*headprop;
4339 player[closest].proportionbody=1.1*bodyprop;
4340 player[closest].proportionarms=1.1*armprop;
4341 player[closest].proportionlegs=1.1*legprop;
4344 if(player[closest].creature==rabbittype){
4345 player[closest].proportionhead=1.2*headprop;
4346 player[closest].proportionbody=1.05*bodyprop;
4347 player[closest].proportionarms=1.00*armprop;
4348 player[closest].proportionlegs=1.1*legprop;
4349 player[closest].proportionlegs.y=1.05*legprop;
4356 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4357 for(i=1;i<numplayers;i++){
4358 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4364 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4365 for(j=9;j<consolechars[0];j++){
4366 mapname[j-9]=consoletext[0][j];
4369 tutoriallevel=atoi(mapname);
4375 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4376 for(j=6;j<consolechars[0];j++){
4377 mapname[j-6]=consoletext[0][j];
4380 tintg=atof(mapname);
4385 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4386 for(j=6;j<consolechars[0];j++){
4387 mapname[j-6]=consoletext[0][j];
4390 tintb=atof(mapname);
4395 if(Compare(consoletext[0],"hostile ",0,7)){
4396 for(j=8;j<consolechars[0];j++){
4397 mapname[j-8]=consoletext[0][j];
4400 hostile=atoi(mapname);
4406 if(Compare(consoletext[0],"type active ",0,11)){
4407 editoractive=typeactive;
4412 if(Compare(consoletext[0],"indemo ",0,6)){
4414 hotspot[numhotspots]=player[0].coords;
4415 hotspotsize[numhotspots]=0;
4416 hotspottype[numhotspots]=-111;
4418 strcpy(hotspottext[numhotspots],"mapname");
4424 if(Compare(consoletext[0],"notindemo ",0,9)){
4431 if(Compare(consoletext[0],"type sitting ",0,12)){
4432 editoractive=typesitting;
4437 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4438 editoractive=typesittingwall;
4443 if(Compare(consoletext[0],"type sleeping ",0,13)){
4444 editoractive=typesleeping;
4448 if(Compare(consoletext[0],"type dead1 ",0,10)){
4449 editoractive=typedead1;
4453 if(Compare(consoletext[0],"type dead2 ",0,10)){
4454 editoractive=typedead2;
4458 if(Compare(consoletext[0],"type dead3 ",0,10)){
4459 editoractive=typedead3;
4462 if(Compare(consoletext[0],"type dead4 ",0,10)){
4463 editoractive=typedead4;
4468 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4469 editorpathtype=wpkeepwalking;
4474 if(Compare(consoletext[0],"path pause ",0,10)){
4475 editorpathtype=wppause;
4480 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4481 maptype=mapkilleveryone;
4486 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4487 maptype=mapgosomewhere;
4492 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4493 maptype=mapkillsomeone;
4499 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4500 maptype=mapkillmost;
4506 if(Compare(consoletext[0],"hs ",0,2)){
4510 hotspot[numhotspots]=player[0].coords;
4515 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4516 mapname[j-startpoint]=consoletext[0][j];
4518 if(consoletext[0][j]=='\0')alldone=1;
4520 mapname[j-startpoint]='\0';
4522 hotspotsize[numhotspots]=atof(mapname);
4526 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4527 mapname[j-startpoint]=consoletext[0][j];
4529 if(consoletext[0][j]=='\0')alldone=1;
4531 mapname[j-startpoint]='\0';
4533 hotspottype[numhotspots]=atoi(mapname);
4537 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4538 mapname[j-startpoint]=consoletext[0][j];
4540 if(consoletext[0][j]=='\0')alldone=1;
4542 mapname[j-startpoint]='\n';
4543 mapname[j-startpoint+1]='\0';
4545 strcpy(hotspottext[numhotspots],mapname);
4552 if(Compare(consoletext[0],"dialogue ",0,8)){
4559 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4560 mapname[j-startpoint]=consoletext[0][j];
4562 if(consoletext[0][j]=='\0')alldone=1;
4564 mapname[j-startpoint]='\0';
4567 dialoguetype[numdialogues]=atoi(mapname);
4585 for(j=startpoint;j<consolechars[0];j++){
4586 mapname[j-startpoint+16]=consoletext[0][j];
4588 mapname[consolechars[0]-startpoint+16]='.';
4589 mapname[consolechars[0]-startpoint+17]='t';
4590 mapname[consolechars[0]-startpoint+18]='x';
4591 mapname[consolechars[0]-startpoint+19]='t';
4592 mapname[consolechars[0]-startpoint+20]='\0';
4594 for(j=0;j<max_dialoguelength;j++){
4596 dialoguetext[numdialogues][j][k]='\0';
4599 dialoguename[numdialogues][j][k]='\0';
4603 ifstream ipstream(ConvertFileName(mapname));
4604 ipstream.ignore(256,':');
4605 ipstream >> numdialogueboxes[numdialogues];
4606 for(i=0;i<numdialogueboxes[numdialogues];i++){
4607 ipstream.ignore(256,':');
4608 ipstream.ignore(256,':');
4609 ipstream.ignore(256,' ');
4610 ipstream >> dialogueboxlocation[numdialogues][i];
4611 ipstream.ignore(256,':');
4612 ipstream >> dialogueboxcolor[numdialogues][i][0];
4613 ipstream >> dialogueboxcolor[numdialogues][i][1];
4614 ipstream >> dialogueboxcolor[numdialogues][i][2];
4615 ipstream.ignore(256,':');
4616 ipstream.getline(dialoguename[numdialogues][i],64);
4617 ipstream.ignore(256,':');
4618 ipstream.ignore(256,' ');
4619 ipstream.getline(dialoguetext[numdialogues][i],128);
4621 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4623 ipstream.ignore(256,':');
4624 ipstream >> dialogueboxsound[numdialogues][i];
4627 for(i=0;i<numdialogueboxes[numdialogues];i++){
4628 for(j=0;j<numplayers;j++){
4629 participantfacing[numdialogues][i][j]=player[j].facing;
4636 whichdialogue=numdialogues;
4644 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4652 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4653 mapname[j-startpoint]=consoletext[0][j];
4655 if(consoletext[0][j]=='\0')alldone=1;
4657 mapname[j-startpoint]='\0';
4660 whichdi=atoi(mapname);
4678 for(j=startpoint;j<consolechars[0];j++){
4679 mapname[j-startpoint+16]=consoletext[0][j];
4681 mapname[consolechars[0]-startpoint+16]='.';
4682 mapname[consolechars[0]-startpoint+17]='t';
4683 mapname[consolechars[0]-startpoint+18]='x';
4684 mapname[consolechars[0]-startpoint+19]='t';
4685 mapname[consolechars[0]-startpoint+20]='\0';
4687 for(j=0;j<max_dialoguelength;j++){
4689 dialoguetext[whichdi][j][k]='\0';
4692 dialoguename[whichdi][j][k]='\0';
4696 ifstream ipstream(ConvertFileName(mapname));
4697 ipstream.ignore(256,':');
4698 ipstream >> numdialogueboxes[whichdi];
4699 for(i=0;i<numdialogueboxes[whichdi];i++){
4700 ipstream.ignore(256,':');
4701 ipstream.ignore(256,':');
4702 ipstream.ignore(256,' ');
4703 ipstream >> dialogueboxlocation[whichdi][i];
4704 ipstream.ignore(256,':');
4705 ipstream >> dialogueboxcolor[whichdi][i][0];
4706 ipstream >> dialogueboxcolor[whichdi][i][1];
4707 ipstream >> dialogueboxcolor[whichdi][i][2];
4708 ipstream.ignore(256,':');
4709 ipstream.getline(dialoguename[whichdi][i],64);
4710 ipstream.ignore(256,':');
4711 ipstream.ignore(256,' ');
4712 ipstream.getline(dialoguetext[whichdi][i],128);
4714 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4716 ipstream.ignore(256,':');
4717 ipstream >> dialogueboxsound[whichdi][i];
4725 if(Compare(consoletext[0],"fixtype ",0,7)){
4733 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4734 mapname[j-startpoint]=consoletext[0][j];
4736 if(consoletext[0][j]=='\0')alldone=1;
4738 mapname[j-startpoint]='\0';
4739 dialoguetype[0]=atoi(mapname);
4747 if(Compare(consoletext[0],"fixrotation ",0,11)){
4748 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4753 if(Compare(consoletext[0],"ddialogue ",0,9)){
4755 if(numdialogues<0)numdialogues=0;
4760 if(Compare(consoletext[0],"immobile ",0,8)){
4761 player[0].immobile=1;
4765 if(Compare(consoletext[0],"mobile ",0,6)){
4766 player[0].immobile=0;
4770 if(Compare(consoletext[0],"play ",0,4)){
4777 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4778 mapname[j-startpoint]=consoletext[0][j];
4780 if(consoletext[0][j]=='\0')alldone=1;
4782 mapname[j-startpoint]='\0';
4785 whichdialogue=atoi(mapname);
4787 if(numdialogues>whichdialogue){
4788 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4789 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4790 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4791 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4792 player[participantfocus[whichdialogue][i]].velocity=0;
4793 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4794 player[participantfocus[whichdialogue][i]].targetframe=0;
4802 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4806 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4807 temppos=temppos-viewer;
4808 Normalise(&temppos);
4818 whichsoundplay=rabbitchitter;
4819 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4820 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4821 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4822 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4823 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4824 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4825 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4826 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4827 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4828 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4829 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4830 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4831 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4832 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4833 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4834 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4835 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4836 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4837 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4838 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4839 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4840 FSOUND_SetVolume(channels[whichsoundplay], 256);
4841 FSOUND_SetPaused(channels[whichsoundplay], false);
4849 if(Compare(consoletext[0],"dhs ",0,3)){
4851 if(numhotspots<0)numhotspots=0;
4856 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4863 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4864 mapname[j-startpoint]=consoletext[0][j];
4866 if(consoletext[0][j]=='\0')alldone=1;
4868 mapname[j-startpoint]='\0';
4870 headprop=atof(mapname);
4874 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4875 mapname[j-startpoint]=consoletext[0][j];
4877 if(consoletext[0][j]=='\0')alldone=1;
4879 mapname[j-startpoint]='\0';
4881 bodyprop=atof(mapname);
4885 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4886 mapname[j-startpoint]=consoletext[0][j];
4888 if(consoletext[0][j]=='\0')alldone=1;
4890 mapname[j-startpoint]='\0';
4892 armprop=atof(mapname);
4896 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4897 mapname[j-startpoint]=consoletext[0][j];
4899 if(consoletext[0][j]=='\0')alldone=1;
4901 mapname[j-startpoint]='\0';
4903 legprop=atof(mapname);
4905 if(player[0].creature==wolftype){
4906 player[0].proportionhead=1.1*headprop;
4907 player[0].proportionbody=1.1*bodyprop;
4908 player[0].proportionarms=1.1*armprop;
4909 player[0].proportionlegs=1.1*legprop;
4912 if(player[0].creature==rabbittype){
4913 player[0].proportionhead=1.2*headprop;
4914 player[0].proportionbody=1.05*bodyprop;
4915 player[0].proportionarms=1.00*armprop;
4916 player[0].proportionlegs=1.1*legprop;
4917 player[0].proportionlegs.y=1.05*legprop;
4923 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4924 for(i=0;i<numplayers;i++){
4925 if(i>0)player[i].immobile=1;
4931 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4932 player[0].armorhead=1;
4933 player[0].armorhigh=1;
4934 player[0].armorlow=1;
4935 player[0].protectionhead=1;
4936 player[0].protectionhigh=1;
4937 player[0].protectionlow=1;
4938 player[0].metalhead=1;
4939 player[0].metalhigh=1;
4940 player[0].metallow=1;
4942 player[0].speedmult=1;
4945 if(player[0].creature==wolftype){
4946 player[0].proportionhead=1.1;
4947 player[0].proportionbody=1.1;
4948 player[0].proportionarms=1.1;
4949 player[0].proportionlegs=1.1;
4952 if(player[0].creature==rabbittype){
4953 player[0].proportionhead=1.2;
4954 player[0].proportionbody=1.05;
4955 player[0].proportionarms=1.00;
4956 player[0].proportionlegs=1.1;
4957 player[0].proportionlegs.y=1.05;
4960 player[0].numclothes=0;
4961 if(player[0].whichskin==0){
4962 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4964 else if(player[0].whichskin==1){
4965 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4967 else if(player[0].whichskin==2){
4968 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4970 else if(player[0].whichskin==3){
4971 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4973 else if(player[0].whichskin==4){
4974 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4976 else if(player[0].whichskin==5){
4977 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4979 else if(player[0].whichskin==6){
4980 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4982 else if(player[0].whichskin==7){
4983 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4985 else if(player[0].whichskin==8){
4986 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4988 else if(player[0].whichskin==9){
4989 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4992 editoractive=typeactive;
4993 player[0].immobile=0;
5000 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
5006 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5007 mapname[j-startpoint]=consoletext[0][j];
5009 if(consoletext[0][j]=='\0')alldone=1;
5011 mapname[j-startpoint]='\0';
5013 tintr=atof(mapname);
5017 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5018 mapname[j-startpoint]=consoletext[0][j];
5020 if(consoletext[0][j]=='\0')alldone=1;
5022 mapname[j-startpoint]='\0';
5024 tintg=atof(mapname);
5028 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5029 mapname[j-startpoint]=consoletext[0][j];
5031 if(consoletext[0][j]=='\0')alldone=1;
5033 mapname[j-startpoint]='\0';
5035 tintb=atof(mapname);
5040 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
5046 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5047 mapname[j-startpoint]=consoletext[0][j];
5049 if(consoletext[0][j]=='\0')alldone=1;
5051 mapname[j-startpoint]='\0';
5053 skyboxr=atof(mapname);
5057 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5058 mapname[j-startpoint]=consoletext[0][j];
5060 if(consoletext[0][j]=='\0')alldone=1;
5062 mapname[j-startpoint]='\0';
5064 skyboxg=atof(mapname);
5068 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5069 mapname[j-startpoint]=consoletext[0][j];
5071 if(consoletext[0][j]=='\0')alldone=1;
5073 mapname[j-startpoint]='\0';
5075 skyboxb=atof(mapname);
5077 skyboxlightr=skyboxr;
5078 skyboxlightg=skyboxg;
5079 skyboxlightb=skyboxb;
5083 //if(skyboxtexture){
5084 terrain.DoShadows();
5085 objects.DoShadows();
5087 else terrain.DoLighting();
5092 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5098 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5099 mapname[j-startpoint]=consoletext[0][j];
5101 if(consoletext[0][j]=='\0')alldone=1;
5103 mapname[j-startpoint]='\0';
5105 skyboxlightr=atof(mapname);
5109 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5110 mapname[j-startpoint]=consoletext[0][j];
5112 if(consoletext[0][j]=='\0')alldone=1;
5114 mapname[j-startpoint]='\0';
5116 skyboxlightg=atof(mapname);
5120 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5121 mapname[j-startpoint]=consoletext[0][j];
5123 if(consoletext[0][j]=='\0')alldone=1;
5125 mapname[j-startpoint]='\0';
5127 skyboxlightb=atof(mapname);
5131 //if(skyboxtexture){
5132 terrain.DoShadows();
5133 objects.DoShadows();
5135 else terrain.DoLighting();
5140 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5141 skyboxtexture=1-skyboxtexture;
5144 //if(skyboxtexture){
5145 terrain.DoShadows();
5146 objects.DoShadows();
5148 else terrain.DoLighting();
5153 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
5159 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5160 mapname[j-startpoint]=consoletext[0][j];
5162 if(consoletext[0][j]=='\0')alldone=1;
5164 mapname[j-startpoint]='\0';
5166 player[0].protectionhead=atof(mapname);
5170 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5171 mapname[j-startpoint]=consoletext[0][j];
5173 if(consoletext[0][j]=='\0')alldone=1;
5175 mapname[j-startpoint]='\0';
5177 player[0].protectionhigh=atof(mapname);
5181 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5182 mapname[j-startpoint]=consoletext[0][j];
5184 if(consoletext[0][j]=='\0')alldone=1;
5186 mapname[j-startpoint]='\0';
5188 player[0].protectionlow=atof(mapname);
5193 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5199 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5200 mapname[j-startpoint]=consoletext[0][j];
5202 if(consoletext[0][j]=='\0')alldone=1;
5204 mapname[j-startpoint]='\0';
5206 player[0].armorhead=atof(mapname);
5210 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5211 mapname[j-startpoint]=consoletext[0][j];
5213 if(consoletext[0][j]=='\0')alldone=1;
5215 mapname[j-startpoint]='\0';
5217 player[0].armorhigh=atof(mapname);
5221 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5222 mapname[j-startpoint]=consoletext[0][j];
5224 if(consoletext[0][j]=='\0')alldone=1;
5226 mapname[j-startpoint]='\0';
5228 player[0].armorlow=atof(mapname);
5233 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5234 for(i=0;i<numplayers;i++){
5235 player[i].protectionhead=1.0;
5236 player[i].protectionhigh=1.0;
5237 player[i].protectionlow=1.0;
5238 player[i].armorhead=1.0;
5239 player[i].armorhigh=1.0;
5240 player[i].armorlow=1.0;
5246 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5248 float closestdist=-1;
5251 for(i=1;i<numplayers;i++){
5252 distance=findDistancefast(&player[i].coords,&player[0].coords);
5253 if(closestdist==-1||distance<closestdist){
5254 closestdist=distance;
5264 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5265 mapname[j-startpoint]=consoletext[0][j];
5267 if(consoletext[0][j]=='\0')alldone=1;
5269 mapname[j-startpoint]='\0';
5271 player[closest].protectionhead=atof(mapname);
5275 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5276 mapname[j-startpoint]=consoletext[0][j];
5278 if(consoletext[0][j]=='\0')alldone=1;
5280 mapname[j-startpoint]='\0';
5282 player[closest].protectionhigh=atof(mapname);
5286 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5287 mapname[j-startpoint]=consoletext[0][j];
5289 if(consoletext[0][j]=='\0')alldone=1;
5291 mapname[j-startpoint]='\0';
5293 player[closest].protectionlow=atof(mapname);
5298 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5300 float closestdist=-1;
5303 for(i=1;i<numplayers;i++){
5304 distance=findDistancefast(&player[i].coords,&player[0].coords);
5305 if(closestdist==-1||distance<closestdist){
5306 closestdist=distance;
5315 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5316 mapname[j-startpoint]=consoletext[0][j];
5318 if(consoletext[0][j]=='\0')alldone=1;
5320 mapname[j-startpoint]='\0';
5322 player[closest].armorhead=atof(mapname);
5326 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5327 mapname[j-startpoint]=consoletext[0][j];
5329 if(consoletext[0][j]=='\0')alldone=1;
5331 mapname[j-startpoint]='\0';
5333 player[closest].armorhigh=atof(mapname);
5337 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5338 mapname[j-startpoint]=consoletext[0][j];
5340 if(consoletext[0][j]=='\0')alldone=1;
5342 mapname[j-startpoint]='\0';
5344 player[closest].armorlow=atof(mapname);
5350 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5356 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5357 mapname[j-startpoint]=consoletext[0][j];
5359 if(consoletext[0][j]=='\0')alldone=1;
5361 mapname[j-startpoint]='\0';
5363 player[0].metalhead=atof(mapname);
5367 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5368 mapname[j-startpoint]=consoletext[0][j];
5370 if(consoletext[0][j]=='\0')alldone=1;
5372 mapname[j-startpoint]='\0';
5374 player[0].metalhigh=atof(mapname);
5378 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5379 mapname[j-startpoint]=consoletext[0][j];
5381 if(consoletext[0][j]=='\0')alldone=1;
5384 mapname[j-startpoint]='\0';
5386 player[0].metallow=atof(mapname);
5391 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5393 float closestdist=-1;
5396 for(i=1;i<numplayers;i++){
5397 distance=findDistancefast(&player[i].coords,&player[0].coords);
5398 if(closestdist==-1||distance<closestdist){
5399 closestdist=distance;
5403 player[closest].numclothes=0;
5404 if(player[closest].whichskin==0){
5405 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5407 else if(player[closest].whichskin==1){
5408 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5410 else if(player[closest].whichskin==2){
5411 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5413 else if(player[closest].whichskin==3){
5414 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5416 else if(player[closest].whichskin==4){
5417 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5419 else if(player[closest].whichskin==5){
5420 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5422 else if(player[closest].whichskin==6){
5423 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5425 else if(player[closest].whichskin==7){
5426 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5428 else if(player[closest].whichskin==8){
5429 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5431 else if(player[closest].whichskin==9){
5432 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5438 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5441 player[closest].numclothes=0;
5442 if(player[closest].whichskin==0){
5443 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5445 else if(player[closest].whichskin==1){
5446 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5448 else if(player[closest].whichskin==2){
5449 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5451 else if(player[closest].whichskin==3){
5452 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5454 else if(player[closest].whichskin==4){
5455 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5457 else if(player[closest].whichskin==5){
5458 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5460 else if(player[closest].whichskin==6){
5461 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5463 else if(player[closest].whichskin==7){
5464 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5466 else if(player[closest].whichskin==8){
5467 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5469 else if(player[closest].whichskin==9){
5470 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5476 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5492 for(j=8;j<consolechars[0];j++){
5493 mapname[j-8+15]=consoletext[0][j];
5495 mapname[consolechars[0]-8+15]='.';
5496 mapname[consolechars[0]-8+16]='p';
5497 mapname[consolechars[0]-8+17]='n';
5498 mapname[consolechars[0]-8+18]='g';
5499 mapname[consolechars[0]-8+19]='\0';
5501 //:Data:Textures:Pants.png
5503 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5504 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5505 strcpy(player[0].clothes[player[0].numclothes],mapname);
5506 player[0].clothestintr[player[0].numclothes]=tintr;
5507 player[0].clothestintg[player[0].numclothes]=tintg;
5508 player[0].clothestintb[player[0].numclothes]=tintb;
5509 player[0].numclothes++;
5515 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5516 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5521 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5522 cellophane=1-cellophane;
5525 for(i=0;i<numplayers;i++){
5526 player[i].proportionhead.z=0;
5527 player[i].proportionbody.z=0;
5528 player[i].proportionarms.z=0;
5529 player[i].proportionlegs.z=0;
5534 for(i=0;i<numplayers;i++){
5535 player[i].proportionhead.z=player[i].proportionhead.x;
5536 player[i].proportionbody.z=player[i].proportionbody.x;
5537 player[i].proportionarms.z=player[i].proportionarms.x;
5538 player[i].proportionlegs.z=player[i].proportionlegs.x;
5545 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5561 for(j=12;j<consolechars[0];j++){
5562 mapname[j-12+15]=consoletext[0][j];
5564 mapname[consolechars[0]-12+15]='.';
5565 mapname[consolechars[0]-12+16]='p';
5566 mapname[consolechars[0]-12+17]='n';
5567 mapname[consolechars[0]-12+18]='g';
5568 mapname[consolechars[0]-12+19]='\0';
5570 //:Data:Textures:Pants.png
5572 float closestdist=-1;
5575 for(i=1;i<numplayers;i++){
5576 distance=findDistancefast(&player[i].coords,&player[0].coords);
5577 if(closestdist==-1||distance<closestdist){
5578 closestdist=distance;
5583 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5584 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5585 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5586 player[closest].clothestintr[player[closest].numclothes]=tintr;
5587 player[closest].clothestintg[player[closest].numclothes]=tintg;
5588 player[closest].clothestintb[player[closest].numclothes]=tintb;
5589 player[closest].numclothes++;
5595 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5596 player[0].skeleton.id=0;
5597 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);
5598 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5599 player[0].creature=rabbittype;
5602 player[0].proportionhead=1.2;
5603 player[0].proportionbody=1.05;
5604 player[0].proportionarms=1.00;
5605 player[0].proportionlegs=1.1;
5606 player[0].proportionlegs.y=1.05;
5607 player[0].headless=0;
5609 player[0].damagetolerance=200;
5613 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5614 player[0].skeleton.id=0;
5615 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);
5616 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5617 player[0].creature=wolftype;
5619 player[0].proportionhead=1.1;
5620 player[0].proportionbody=1.1;
5621 player[0].proportionarms=1.1;
5622 player[0].proportionlegs=1.1;
5623 player[0].proportionlegs.y=1.1;
5624 player[0].scale=.23;
5626 player[0].damagetolerance=300;
5630 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5631 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5634 if(Compare(consoletext[0],"rambo ",0,5)){
5635 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5638 if(Compare(consoletext[0],"david ",0,5)){
5639 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5642 if(Compare(consoletext[0],"wolf ",0,4)){
5643 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5646 if(Compare(consoletext[0],"darkwolf ",0,8)){
5647 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5650 if(Compare(consoletext[0],"snowwolf ",0,8)){
5651 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5654 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5655 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5658 if(Compare(consoletext[0],"white ",0,5)){
5659 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5662 if(Compare(consoletext[0],"brown ",0,5)){
5663 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5666 if(Compare(consoletext[0],"black ",0,5)){
5667 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5670 if(consolechars[0]>0){
5673 consoletext[k][j]=consoletext[k-1][j];
5675 consolechars[k]=consolechars[k-1];
5678 consoletext[0][j]=' ';
5684 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5685 FSOUND_SetVolume(channels[consolefailsound], 256);
5686 FSOUND_SetPaused(channels[consolefailsound], false);
5695 togglekeydelay[i]=0;
5699 consoleblinkdelay-=multiplier;
5700 if(consoleblinkdelay<=0){
5701 consoleblinkdelay=.3;
5702 consoleblink=1-consoleblink;
5706 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5709 if(newdetail>2)newdetail=detail;
5710 if(newdetail<0)newdetail=detail;
5711 #if !USE_SDL // we'll take anything that works.
5712 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5713 if(newscreenheight>3000)newscreenheight=screenheight;
5715 if(newscreenwidth<0)newscreenwidth=screenwidth;
5716 if(newscreenheight<0)newscreenheight=screenheight;
5718 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5719 opstream << "Screenwidth:\n";
5720 opstream << newscreenwidth;
5721 opstream << "\nScreenheight:\n";
5722 opstream << newscreenheight;
5723 opstream << "\nMouse sensitivity:\n";
5724 opstream << usermousesensitivity;
5725 opstream << "\nBlur(0,1):\n";
5726 opstream << ismotionblur;
5727 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5728 opstream << newdetail;
5729 opstream << "\nFloating jump:\n";
5730 opstream << floatjump;
5731 opstream << "\nMouse jump:\n";
5732 opstream << mousejump;
5733 opstream << "\nAmbient sound:\n";
5734 opstream << ambientsound;
5735 opstream << "\nBlood (0,1,2):\n";
5736 opstream << bloodtoggle;
5737 opstream << "\nAuto slomo:\n";
5738 opstream << autoslomo;
5739 opstream << "\nFoliage:\n";
5740 opstream << foliage;
5741 opstream << "\nMusic:\n";
5742 opstream << musictoggle;
5743 opstream << "\nTrilinear:\n";
5744 opstream << trilinear;
5745 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5747 opstream << "\nInvert mouse:\n";
5748 opstream << invertmouse;
5749 opstream << "\nGamespeed:\n";
5750 if(oldgamespeed==0)oldgamespeed=1;
5751 opstream << oldgamespeed;
5752 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5753 opstream << difficulty;
5754 opstream << "\nDamage effects(blackout, doublevision):\n";
5755 opstream << damageeffects;
5756 opstream << "\nText:\n";
5757 opstream << texttoggle;
5758 opstream << "\nDebug:\n";
5759 opstream << debugmode;
5760 opstream << "\nVBL Sync:\n";
5761 opstream << vblsync;
5762 opstream << "\nShow Points:\n";
5763 opstream << showpoints;
5764 opstream << "\nAlways Blur:\n";
5765 opstream << alwaysblur;
5766 opstream << "\nImmediate mode (turn on on G5):\n";
5767 opstream << immediate;
5768 opstream << "\nVelocity blur:\n";
5769 opstream << velocityblur;
5770 opstream << "\nVolume:\n";
5772 opstream << "\nForward key:\n";
5773 opstream << KeyToChar(forwardkey);
5774 opstream << "\nBack key:\n";
5775 opstream << KeyToChar(backkey);
5776 opstream << "\nLeft key:\n";
5777 opstream << KeyToChar(leftkey);
5778 opstream << "\nRight key:\n";
5779 opstream << KeyToChar(rightkey);
5780 opstream << "\nJump key:\n";
5781 opstream << KeyToChar(jumpkey);
5782 opstream << "\nCrouch key:\n";
5783 opstream << KeyToChar(crouchkey);
5784 opstream << "\nDraw key:\n";
5785 opstream << KeyToChar(drawkey);
5786 opstream << "\nThrow key:\n";
5787 opstream << KeyToChar(throwkey);
5788 opstream << "\nAttack key:\n";
5789 opstream << KeyToChar(attackkey);
5790 opstream << "\nChat key:\n";
5791 opstream << KeyToChar(chatkey);
5796 static int oldwinfreeze;
5797 if(winfreeze&&!oldwinfreeze){
5798 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
5799 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5800 FSOUND_SetVolume(channels[consolesuccesssound], 256);
5801 FSOUND_SetPaused(channels[consolesuccesssound], false);
5803 if(winfreeze==0)oldwinfreeze=winfreeze;
5804 else oldwinfreeze++;
5806 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5807 if(winfreeze)winfreeze=0;
5810 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5816 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5819 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5821 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5823 static bool oldbuttondialogue;
5825 if(indialogue!=-1)talkdelay=1;
5826 talkdelay-=multiplier;
5829 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5830 for(i=0;i<numdialogues;i++){
5831 int realdialoguetype;
5833 if(dialoguetype[i]>49){
5834 realdialoguetype=dialoguetype[i]-50;
5837 else if(dialoguetype[i]>39){
5838 realdialoguetype=dialoguetype[i]-40;
5841 else if(dialoguetype[i]>29){
5842 realdialoguetype=dialoguetype[i]-30;
5845 else if(dialoguetype[i]>19){
5846 realdialoguetype=dialoguetype[i]-20;
5849 else if(dialoguetype[i]>9){
5850 realdialoguetype=dialoguetype[i]-10;
5854 realdialoguetype=dialoguetype[i];
5857 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5858 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5860 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5861 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5862 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5863 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5864 player[participantfocus[whichdialogue][j]].velocity=0;
5865 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5866 player[participantfocus[whichdialogue][j]].targetframe=0;
5871 dialoguegonethrough[i]++;
5872 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5873 static float gLoc[3];
5874 static float vel[3];
5876 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5877 temppos=temppos-viewer;
5878 Normalise(&temppos);
5883 gLoc[2]=temppos.z;vel[0]=0;
5887 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5888 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5889 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5890 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5891 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5892 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5893 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5894 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5895 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5896 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5897 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5898 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5899 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5900 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5901 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5902 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5903 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5904 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5905 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5906 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5907 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5908 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5909 FSOUND_SetVolume(channels[whichsoundplay], 256);
5910 FSOUND_SetPaused(channels[whichsoundplay], false);
5912 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5917 windvar+=multiplier;
5918 smoketex+=multiplier;
5919 tutorialstagetime+=multiplier;
5921 static float hotspotvisual[40];
5925 for(i=0;i<numhotspots;i++)
5926 hotspotvisual[i]-=multiplier/320;
5928 for(i=0;i<numhotspots;i++){
5929 //if(hotspottype[i]<=10)
5930 while(hotspotvisual[i]<0){
5932 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5933 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5934 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5935 hotspotsprite+=hotspot[i];
5936 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5937 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5941 for(i=0;i<numhotspots;i++){
5942 if(hotspottype[i]<=10&&hotspottype[i]>0){
5943 hotspot[i]=player[hotspottype[i]].coords;
5949 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5952 if(tutorialstage<=1){
5957 if(tutorialstage==1){
5960 if(tutorialstage==2){
5963 if(tutorialstage==3){
5964 tutorialmaxtime=600;
5966 if(tutorialstage==4){
5967 tutorialmaxtime=1000;
5969 if(tutorialstage==5){
5970 tutorialmaxtime=600;
5972 if(tutorialstage==6){
5973 tutorialmaxtime=600;
5975 if(tutorialstage==7){
5976 tutorialmaxtime=600;
5978 if(tutorialstage==8){
5979 tutorialmaxtime=600;
5981 if(tutorialstage==9){
5982 tutorialmaxtime=600;
5984 if(tutorialstage==10){
5987 if(tutorialstage==11){
5988 tutorialmaxtime=1000;
5990 if(tutorialstage==12){
5991 tutorialmaxtime=1000;
5993 if(tutorialstage==13){
5996 if(tutorialstage==14){
6008 player[1].coords=(temp+temp2)/2;
6012 gLoc[0]=player[1].coords.x;
6013 gLoc[1]=player[1].coords.y;
6014 gLoc[2]=player[1].coords.z;
6018 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6019 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6020 FSOUND_SetVolume(channels[fireendsound], 256);
6021 FSOUND_SetPaused(channels[fireendsound], false);
6023 for(i=0;i<player[1].skeleton.num_joints;i++){
6025 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6026 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6027 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;
6028 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6029 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6034 if(tutorialstage==15){
6035 tutorialmaxtime=500;
6037 if(tutorialstage==16){
6038 tutorialmaxtime=500;
6040 if(tutorialstage==17){
6041 tutorialmaxtime=500;
6043 if(tutorialstage==18){
6044 tutorialmaxtime=500;
6046 if(tutorialstage==19){
6048 //tutorialmaxtime=500;
6050 if(tutorialstage==20){
6051 tutorialmaxtime=500;
6053 if(tutorialstage==21){
6054 tutorialmaxtime=500;
6061 if(tutorialstage==22){
6062 tutorialmaxtime=500;
6064 if(tutorialstage==23){
6065 tutorialmaxtime=500;
6067 if(tutorialstage==24){
6068 tutorialmaxtime=500;
6070 if(tutorialstage==25){
6071 tutorialmaxtime=500;
6073 if(tutorialstage==26){
6076 if(tutorialstage==27){
6080 player[1].aitype=attacktypecutoff;
6082 if(tutorialstage==28){
6083 tutorialmaxtime=400;
6085 if(tutorialstage==29){
6086 tutorialmaxtime=400;
6087 player[0].escapednum=0;
6089 if(tutorialstage==30){
6093 player[1].aitype=passivetype;
6095 if(tutorialstage==31){
6098 if(tutorialstage==32){
6101 if(tutorialstage==33){
6102 tutorialmaxtime=400;
6105 player[1].aitype=attacktypecutoff;
6107 if(tutorialstage==34){
6108 tutorialmaxtime=400;
6110 if(tutorialstage==35){
6111 tutorialmaxtime=400;
6113 if(tutorialstage==36){
6117 player[1].aitype=passivetype;
6119 if(tutorialstage==37){
6125 player[1].aitype=attacktypecutoff;
6127 if(tutorialstage==38){
6131 player[1].aitype=passivetype;
6133 if(tutorialstage==39){
6144 weapons.owner[weapons.numweapons]=-1;
6145 weapons.type[weapons.numweapons]=knife;
6146 weapons.damage[weapons.numweapons]=0;
6147 weapons.mass[weapons.numweapons]=1;
6148 weapons.tipmass[weapons.numweapons]=1.2;
6149 weapons.length[weapons.numweapons]=.25;
6150 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6151 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6153 weapons.velocity[weapons.numweapons]=0.1;
6154 weapons.tipvelocity[weapons.numweapons]=0.1;
6155 weapons.missed[weapons.numweapons]=1;
6156 weapons.hitsomething[weapons.numweapons]=0;
6157 weapons.freetime[weapons.numweapons]=0;
6158 weapons.firstfree[weapons.numweapons]=1;
6159 weapons.physics[weapons.numweapons]=1;
6161 weapons.numweapons++;
6163 if(tutorialstage==40){
6164 tutorialmaxtime=300;
6166 if(tutorialstage==41){
6167 tutorialmaxtime=300;
6169 if(tutorialstage==42){
6172 if(tutorialstage==43){
6173 tutorialmaxtime=300;
6175 if(tutorialstage==44){
6177 player[0].weaponactive=-1;
6178 player[0].num_weapons=0;
6179 player[1].weaponactive=0;
6180 player[1].num_weapons=1;
6181 player[1].weaponids[0]=0;
6185 player[1].aitype=attacktypecutoff;
6187 tutorialmaxtime=300;
6189 if(tutorialstage==45){
6191 player[0].weaponactive=-1;
6192 player[0].num_weapons=0;
6193 player[1].weaponactive=0;
6194 player[1].num_weapons=1;
6195 player[1].weaponids[0]=0;
6197 tutorialmaxtime=300;
6199 if(tutorialstage==46){
6201 player[0].weaponactive=-1;
6202 player[0].num_weapons=0;
6203 player[1].weaponactive=0;
6204 player[1].num_weapons=1;
6205 player[1].weaponids[0]=0;
6207 weapons.type[0]=sword;
6209 tutorialmaxtime=300;
6212 if(tutorialstage==47){
6224 weapons.owner[weapons.numweapons]=-1;
6225 weapons.type[weapons.numweapons]=sword;
6226 weapons.damage[weapons.numweapons]=0;
6227 weapons.mass[weapons.numweapons]=1;
6228 weapons.tipmass[weapons.numweapons]=1.2;
6229 weapons.length[weapons.numweapons]=.25;
6230 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6231 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6233 weapons.velocity[weapons.numweapons]=0.1;
6234 weapons.tipvelocity[weapons.numweapons]=0.1;
6235 weapons.missed[weapons.numweapons]=1;
6236 weapons.hitsomething[weapons.numweapons]=0;
6237 weapons.freetime[weapons.numweapons]=0;
6238 weapons.firstfree[weapons.numweapons]=1;
6239 weapons.physics[weapons.numweapons]=1;
6243 player[0].weaponactive=0;
6244 player[0].num_weapons=1;
6245 player[0].weaponids[0]=1;
6246 player[1].weaponactive=0;
6247 player[1].num_weapons=1;
6248 player[1].weaponids[0]=0;
6250 weapons.numweapons++;
6252 if(tutorialstage==48){
6255 player[1].aitype=passivetype;
6261 player[0].weaponactive=0;
6262 player[0].num_weapons=1;
6263 player[0].weaponids[0]=1;
6264 player[1].weaponactive=0;
6265 player[1].num_weapons=1;
6266 player[1].weaponids[0]=0;
6268 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6269 else weapons.type[0]=staff;
6271 weapons.numweapons++;
6273 if(tutorialstage==49){
6276 player[1].aitype=passivetype;
6278 tutorialmaxtime=200;
6280 weapons.position[1]=1000;
6281 weapons.tippoint[1]=1000;
6283 weapons.numweapons=1;
6285 player[1].weaponactive=-1;
6286 player[1].num_weapons=0;
6287 player[0].weaponactive=0;
6288 player[0].num_weapons=1;
6289 player[0].weaponids[0]=0;
6291 weapons.type[0]=knife;
6293 weapons.numweapons++;
6295 if(tutorialstage==50){
6301 gLoc[0]=player[1].coords.x;
6302 gLoc[1]=player[1].coords.y;
6303 gLoc[2]=player[1].coords.z;
6307 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6308 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6309 FSOUND_SetVolume(channels[fireendsound], 256);
6310 FSOUND_SetPaused(channels[fireendsound], false);
6312 for(i=0;i<player[1].skeleton.num_joints;i++){
6314 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6315 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6316 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;
6317 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6318 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6322 player[1].num_weapons=0;
6323 player[1].weaponstuck=-1;
6324 player[1].weaponactive=-1;
6326 weapons.numweapons=0;
6328 weapons.owner[0]=-1;
6329 weapons.velocity[0]=0.1;
6330 weapons.tipvelocity[0]=-0.1;
6331 weapons.missed[0]=1;
6332 weapons.hitsomething[0]=0;
6333 weapons.freetime[0]=0;
6334 weapons.firstfree[0]=1;
6335 weapons.physics[0]=1;
6337 if(tutorialstage==51){
6338 tutorialmaxtime=80000;
6340 if(tutorialstage<=51)tutorialstagetime=0;
6344 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6345 if(tutorialstage==3){
6346 if(deltah||deltav)tutorialsuccess+=multiplier;
6348 if(tutorialstage==4){
6349 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6351 if(tutorialstage==5){
6352 if(player[0].jumpkeydown)tutorialsuccess=1;
6354 if(tutorialstage==6){
6355 if(player[0].isCrouch())tutorialsuccess=1;
6357 if(tutorialstage==7){
6358 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6360 if(tutorialstage==8){
6361 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6363 if(tutorialstage==9){
6364 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6366 if(tutorialstage==11){
6367 if(player[0].isWallJump())tutorialsuccess=1;
6369 if(tutorialstage==12){
6370 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6372 if(tutorialstage==15){
6373 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6375 if(tutorialstage==16){
6376 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6378 if(tutorialstage==17){
6379 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6381 if(tutorialstage==18){
6382 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6384 if(tutorialstage==19){
6385 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6387 if(tutorialstage==20){
6388 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6390 if(tutorialstage==21){
6391 if(bonus==cannon)tutorialsuccess=1;
6393 if(tutorialstage==22){
6394 if(bonus==spinecrusher)tutorialsuccess=1;
6396 if(tutorialstage==23){
6397 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6399 if(tutorialstage==24){
6400 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6402 if(tutorialstage==25){
6403 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6405 if(tutorialstage==28){
6406 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6408 if(tutorialstage==29){
6409 if(player[0].escapednum==2){
6413 player[1].aitype=passivetype;
6416 if(tutorialstage==33){
6417 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6419 if(tutorialstage==34){
6420 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6422 if(tutorialstage==35){
6423 if(animation[player[0].targetanimation].attack==reversal){
6427 player[1].aitype=passivetype;
6430 if(tutorialstage==40){
6431 if(player[0].num_weapons>0)tutorialsuccess=1;
6433 if(tutorialstage==41){
6434 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6436 if(tutorialstage==43){
6437 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6439 if(tutorialstage==44){
6440 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6442 if(tutorialstage==45){
6443 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6445 if(tutorialstage==46){
6446 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6448 if(tutorialstage==49){
6449 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6451 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6454 if(tutorialstagetime==tutorialmaxtime-3){
6455 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6456 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6457 FSOUND_SetPaused(channels[consolesuccesssound], false);
6460 if(tutorialsuccess>=1){
6461 if(tutorialstage==34||tutorialstage==35)
6462 tutorialstagetime=tutorialmaxtime-1;
6467 if(tutorialstage<14||tutorialstage>=50){
6468 player[1].coords.y=300;
6469 player[1].velocity=0;
6473 if(tutoriallevel!=1){
6474 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6475 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6476 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6477 FSOUND_SetPaused(channels[consolesuccesssound], false);
6482 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6483 FSOUND_SetVolume(channels[fireendsound], 256);
6484 FSOUND_SetPaused(channels[fireendsound], false);
6487 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6488 else bonusnum[bonus]+=0.15;
6489 if(tutoriallevel)bonusvalue=0;
6490 bonusvalue/=bonusnum[bonus];
6491 bonustotal+=bonusvalue;
6493 bonustime+=multiplier;
6495 if(environment==snowyenvironment){
6496 precipdelay-=multiplier;
6497 while(precipdelay<0){
6499 if(!detail)precipdelay+=.04;
6500 XYZ footvel,footpoint;
6503 footpoint=viewer+viewerfacing*6;
6504 footpoint.y+=((float)abs(Random()%1200))/100-6;
6505 footpoint.x+=((float)abs(Random()%1200))/100-6;
6506 footpoint.z+=((float)abs(Random()%1200))/100-6;
6507 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6510 for(k=0;k<numplayers;k++){
6511 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6512 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6514 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){
6515 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6516 else if(player[k].rotation>player[k].targetrotation){
6517 player[k].rotation-=multiplier*player[k].turnspeed;
6519 else if(player[k].rotation<player[k].targetrotation){
6520 player[k].rotation+=multiplier*player[k].turnspeed;
6525 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))){
6526 player[k].turnspeed*=2;
6527 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6528 else if(player[k].rotation>player[k].targetrotation){
6529 player[k].rotation-=multiplier*player[k].turnspeed;
6531 else if(player[k].rotation<player[k].targetrotation){
6532 player[k].rotation+=multiplier*player[k].turnspeed;
6534 player[k].turnspeed/=2;
6537 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6538 player[k].turnspeed*=4;
6539 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6540 else if(player[k].rotation>player[k].targetrotation){
6541 player[k].rotation-=multiplier*player[k].turnspeed;
6543 else if(player[k].rotation<player[k].targetrotation){
6544 player[k].rotation+=multiplier*player[k].turnspeed;
6546 player[k].turnspeed/=4;
6549 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6550 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6552 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6553 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6556 if(player[k].collide<-.3)player[k].collide=-.3;
6557 if(player[k].collide>1)player[k].collide=1;
6558 player[k].collide-=multiplier*30;
6560 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6561 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6563 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6564 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6565 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6566 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6567 lowpoint=player[k].coords;
6568 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6569 else lowpoint.y+=1.3;
6570 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){
6571 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6573 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6574 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6576 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6577 flatfacing=lowpoint-player[k].coords;
6578 player[k].coords=lowpoint;
6579 player[k].coords.y-=1.3;
6580 player[k].collide=1;
6582 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6583 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6584 tempcoords1=lowpoint;
6585 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6586 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6588 player[k].targetanimation=walljumpleftanim;
6589 player[k].targetframe=0;
6592 gLoc[0]=player[k].coords.x;
6593 gLoc[1]=player[k].coords.y;
6594 gLoc[2]=player[k].coords.z;
6598 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6599 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6600 FSOUND_SetVolume(channels[movewhooshsound], 256);
6601 FSOUND_SetPaused(channels[movewhooshsound], false);
6602 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6604 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6605 player[k].rotation=-asin(0-lowpointtarget.x);
6606 player[k].rotation*=360/6.28;
6607 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6608 player[k].targetrotation=player[k].rotation;
6609 player[k].lowrotation=player[k].rotation;
6610 if(k==0)numwallflipped++;
6614 lowpoint=tempcoords1;
6615 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6616 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6617 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6619 player[k].targetanimation=walljumprightanim;
6620 player[k].targetframe=0;
6623 gLoc[0]=player[k].coords.x;
6624 gLoc[1]=player[k].coords.y;
6625 gLoc[2]=player[k].coords.z;
6629 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6630 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6631 FSOUND_SetVolume(channels[movewhooshsound], 256);
6632 FSOUND_SetPaused(channels[movewhooshsound], false);
6633 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6635 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6636 player[k].rotation=-asin(0-lowpointtarget.x);
6637 player[k].rotation*=360/6.28;
6638 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6639 player[k].targetrotation=player[k].rotation;
6640 player[k].lowrotation=player[k].rotation;
6641 if(k==0)numwallflipped++;
6645 lowpoint=tempcoords1;
6646 lowpointtarget=lowpoint+player[k].facing*2;
6647 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6648 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6650 player[k].targetanimation=walljumpbackanim;
6651 player[k].targetframe=0;
6654 gLoc[0]=player[k].coords.x;
6655 gLoc[1]=player[k].coords.y;
6656 gLoc[2]=player[k].coords.z;
6660 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6661 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6662 FSOUND_SetVolume(channels[movewhooshsound], 256);
6663 FSOUND_SetPaused(channels[movewhooshsound], false);
6664 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6666 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6667 player[k].rotation=-asin(0-lowpointtarget.x);
6668 player[k].rotation*=360/6.28;
6669 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6670 player[k].targetrotation=player[k].rotation;
6671 player[k].lowrotation=player[k].rotation;
6672 if(k==0)numwallflipped++;
6676 lowpoint=tempcoords1;
6677 lowpointtarget=lowpoint-player[k].facing*2;
6678 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6679 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6681 player[k].targetanimation=walljumpfrontanim;
6682 player[k].targetframe=0;
6685 gLoc[0]=player[k].coords.x;
6686 gLoc[1]=player[k].coords.y;
6687 gLoc[2]=player[k].coords.z;
6691 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6692 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6693 FSOUND_SetVolume(channels[movewhooshsound], 256);
6694 FSOUND_SetPaused(channels[movewhooshsound], false);
6695 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6697 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6698 player[k].rotation=-asin(0-lowpointtarget.x);
6699 player[k].rotation*=360/6.28;
6700 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6701 player[k].rotation+=180;
6702 player[k].targetrotation=player[k].rotation;
6703 player[k].lowrotation=player[k].rotation;
6704 if(k==0)numwallflipped++;
6712 else if(objects.type[i]==rocktype){
6713 lowpoint2=player[k].coords;
6714 lowpoint=player[k].coords;
6716 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6717 player[k].coords=colpoint;
6718 player[k].collide=1;
6721 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6722 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6724 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6726 player[k].targetframe=0;
6727 player[k].onterrain=1;
6729 if(player[k].id==0){
6730 FSOUND_SetPaused(channels[whooshsound], true);
6731 FSOUND_SetVolume(channels[whooshsound], 0);
6734 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6735 if(player[k].isFlip())player[k].jumppower=-4;
6736 player[k].targetanimation=player[k].getLanding();
6739 gLoc[0]=player[k].coords.x;
6740 gLoc[1]=player[k].coords.y;
6741 gLoc[2]=player[k].coords.z;
6742 vel[0]=player[k].velocity.x;
6743 vel[1]=player[k].velocity.y;
6744 vel[2]=player[k].velocity.z;
6745 PlaySoundEx( landsound, samp[landsound], NULL, true);
6746 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6747 FSOUND_SetVolume(channels[landsound], 128);
6748 FSOUND_SetPaused(channels[landsound], false);
6750 envsound[numenvsounds]=player[k].coords;
6751 envsoundvol[numenvsounds]=16;
6752 envsoundlife[numenvsounds]=.4;
6761 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6762 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6763 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6764 lowpoint=player[k].coords;
6766 if(objects.type[i]!=rocktype)
6767 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6768 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6769 player[k].coords=lowpoint;
6770 player[k].coords.y-=1.35;
6771 player[k].collide=1;
6773 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)){
6774 lowpoint=player[k].coords;
6775 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6776 lowpoint=player[k].coords;
6780 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6781 lowpointtarget=lowpoint+facing*1.4;
6782 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6784 lowpoint=player[k].coords;
6786 lowpointtarget=lowpoint+facing*1.4;
6788 lowpointtarget2=lowpointtarget;
6790 lowpointtarget3=lowpointtarget;
6792 lowpointtarget4=lowpointtarget;
6794 lowpointtarget5=lowpointtarget;
6796 lowpointtarget6=lowpointtarget;
6798 lowpointtarget7=lowpoint;
6800 lowpointtarget2.x+=.1;
6802 lowpointtarget3.z+=.1;
6804 lowpointtarget4.x-=.1;
6806 lowpointtarget5.z-=.1;
6808 lowpointtarget6.y+=45/13;
6809 lowpointtarget6+=facing*.6;
6810 lowpointtarget7.y+=90/13;
6811 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6812 if(objects.friction[i]>.5)
6815 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6816 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6817 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6818 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)
6820 lowpoint=player[k].coords;
6821 lowpoint.y+=(float)j/13;
6822 lowpointtarget=lowpoint+facing*1.4;
6823 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6827 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6830 if(j<=25&&player[k].targetanimation==jumpdownanim){
6833 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6834 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6835 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)*/){
6836 lowpoint=player[k].coords;
6837 lowpoint.y+=(float)j/13;
6838 lowpointtarget=lowpoint+facing*1.3;
6839 flatfacing=player[k].coords;
6840 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6841 player[k].coords.y=lowpointtarget.y-.07;
6842 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6844 if(j>10||!player[k].isRun()){
6845 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6846 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6850 gLoc[0]=player[k].coords.x;
6851 gLoc[1]=player[k].coords.y;
6852 gLoc[2]=player[k].coords.z;
6853 vel[0]=player[k].velocity.x;
6854 vel[1]=player[k].velocity.y;
6855 vel[2]=player[k].velocity.z;
6856 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6857 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6858 FSOUND_SetVolume(channels[jumpsound], 128);
6859 FSOUND_SetPaused(channels[jumpsound], false);
6861 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6862 player[k].rotation=-asin(0-lowpointtarget.x);
6863 player[k].rotation*=360/6.28;
6864 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6865 player[k].targetrotation=player[k].rotation;
6866 player[k].lowrotation=player[k].rotation;
6868 //player[k].velocity=lowpointtarget*.03;
6869 player[k].velocity=0;
6871 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6872 //player[k].currentanimation=climbanim;
6873 player[k].targetanimation=climbanim;
6874 player[k].jumppower=0;
6875 player[k].jumpclimb=1;
6877 player[k].transspeed=6;
6880 //player[k].currentframe=1;
6881 player[k].targetframe=1;
6883 //player[k].currentframe=0;
6884 player[k].targetframe=0;
6885 //player[k].currentanimation=hanganim;
6886 player[k].targetanimation=hanganim;
6887 player[k].jumppower=0;
6901 if(player[k].collide<=0){
6902 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()){
6903 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)){
6904 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6905 player[k].targetanimation=jumpdownanim;
6906 player[k].targetframe=0;
6911 gLoc[0]=player[k].coords.x;
6912 gLoc[1]=player[k].coords.y;
6913 gLoc[2]=player[k].coords.z;
6914 vel[0]=player[k].velocity.x;
6915 vel[1]=player[k].velocity.y;
6916 vel[2]=player[k].velocity.z;
6918 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6919 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6920 FSOUND_SetVolume(channels[whooshsound], 128);
6921 FSOUND_SetPaused(channels[whooshsound], false);
6924 player[k].velocity.y+=gravity;
6929 player[k].realoldcoords=player[k].coords;
6932 static XYZ oldviewer;
6935 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6936 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6937 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6938 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6939 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6940 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6941 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6942 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6946 player[0].forwardkeydown=0;
6947 player[0].leftkeydown=0;
6948 player[0].backkeydown=0;
6949 player[0].rightkeydown=0;
6950 player[0].jumpkeydown=0;
6951 player[0].crouchkeydown=0;
6952 player[0].drawkeydown=0;
6953 player[0].throwkeydown=0;
6956 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6959 static bool endkeydown;
6966 facing=DoRotation(facing,-rotation2,0,0);
6967 facing=DoRotation(facing,0,0-rotation,0);
6972 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6974 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6975 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6976 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6977 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6978 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6979 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6980 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)
6981 ||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)
6982 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6984 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6985 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6986 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6987 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6988 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6989 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6990 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6991 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6992 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6993 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6994 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6996 participantfocus[whichdialogue][indialogue]=whichend;
6997 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6998 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
7001 participantfocus[whichdialogue][indialogue]=-1;
7003 if(player[participantfocus[whichdialogue][indialogue]].dead){
7008 dialoguecamera[whichdialogue][indialogue]=viewer;
7009 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
7010 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
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 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
7049 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7050 FSOUND_SetVolume(channels[whichsoundplay], 256);
7051 FSOUND_SetPaused(channels[whichsoundplay], false);
7055 for(j=0;j<numplayers;j++){
7056 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
7061 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)
7062 ||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)
7065 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
7066 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
7067 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
7068 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
7069 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
7070 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
7071 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
7072 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
7073 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
7074 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
7075 participantfacing[whichdialogue][indialogue][whichend]=facing;
7077 if(!IsKeyDown(theKeyMap, MAC_1_KEY)&&!IsKeyDown(theKeyMap, MAC_2_KEY)&&!IsKeyDown(theKeyMap, MAC_3_KEY)&&!IsKeyDown(theKeyMap, MAC_4_KEY)&&!IsKeyDown(theKeyMap, MAC_5_KEY)
7078 &&!IsKeyDown(theKeyMap, MAC_6_KEY)&&!IsKeyDown(theKeyMap, MAC_7_KEY)&&!IsKeyDown(theKeyMap, MAC_8_KEY)&&!IsKeyDown(theKeyMap, MAC_9_KEY)&&!IsKeyDown(theKeyMap, MAC_0_KEY)
7079 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7082 if(indialogue>=numdialogueboxes[whichdialogue]){
7089 FSOUND_SetPaused(channels[whooshsound], true);
7090 viewer=dialoguecamera[whichdialogue][indialogue];
7091 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7092 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7094 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7095 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7096 if(dialoguetime>0.5)
7097 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)
7098 ||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)
7099 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7102 if(indialogue<numdialogueboxes[whichdialogue]){
7103 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7104 static float gLoc[3];
7105 static float vel[3];
7107 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7108 temppos=temppos-viewer;
7109 Normalise(&temppos);
7114 gLoc[2]=temppos.z;vel[0]=0;
7118 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7119 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7120 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7121 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7122 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7123 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7124 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7125 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7126 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7127 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7128 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7129 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7130 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7131 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7132 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7133 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7134 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7135 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7136 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7137 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7138 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7139 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7140 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
7141 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7142 FSOUND_SetVolume(channels[whichsoundplay], 256);
7143 FSOUND_SetPaused(channels[whichsoundplay], false);
7145 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7146 hotspot[numhotspots]=player[0].coords;
7147 hotspotsize[numhotspots]=10;
7148 hotspottype[numhotspots]=-1;
7152 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7156 if(player[participantfocus[whichdialogue][indialogue]].dead){
7164 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)
7165 &&!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)
7166 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7169 if(indialogue>=numdialogueboxes[whichdialogue]){
7173 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7176 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7179 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7181 for(i=1;i<numplayers;i++){
7182 player[i].aitype = attacktypecutoff;
7189 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7190 else oldbuttondialogue=1;
7192 static float keyrefreshdelay=0,bigrefreshdelay=0;
7196 /*keyrefreshdelay-=multiplier;
7197 bigrefreshdelay-=multiplier;
7199 if(keyrefreshdelay<=0){
7200 static int concat[4];
7202 concat[0]=player[0].forwardkeydown;
7203 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7204 concat[0]=concat[0]*2+player[0].rightkeydown;
7205 concat[0]=concat[0]*2+player[0].leftkeydown;
7206 concat[0]=concat[0]*2+player[0].backkeydown;
7207 concat[0]=concat[0]*2+player[0].jumpkeydown;
7208 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7209 concat[0]=concat[0]*2+player[0].crouchkeydown;
7211 concat[1]=player[0].crouchtogglekeydown;
7212 concat[1]=concat[1]*2+player[0].drawkeydown;
7213 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7214 concat[1]=concat[1]*2+player[0].throwkeydown;
7215 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7216 concat[1]=concat[1]*2+player[0].attackkeydown;
7218 //concat[2]=(char)((int)(rotation/2)%180);
7220 //concat[3]=(char)((int)(rotation2/2)%180);
7222 chatname[0]=concat[0]-128;
7223 chatname[1]=concat[1]-128;
7224 //chatname[2]=concat[2]-128;
7225 //chatname[3]=concat[3]-128;
7227 memcpy(chatname+temppoint,&rotation,sizeof(float));
7228 temppoint+=sizeof(float);
7229 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7230 temppoint+=sizeof(float);
7232 chatname[temppoint]='\0';
7234 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7235 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7236 //keyrefreshdelay=.01;
7237 keyrefreshdelay=.03;
7240 if(bigrefreshdelay<=0){
7243 memcpy(chatname+temppoint,&i,sizeof(int));
7244 temppoint+=sizeof(int);
7245 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7246 temppoint+=sizeof(float);
7247 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7248 temppoint+=sizeof(float);
7249 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7250 temppoint+=sizeof(float);
7251 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7252 temppoint+=sizeof(float);
7253 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7254 temppoint+=sizeof(float);
7255 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7256 temppoint+=sizeof(int);
7257 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7258 temppoint+=sizeof(int);
7259 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7260 temppoint+=sizeof(float);
7261 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7262 temppoint+=sizeof(float);
7263 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7264 temppoint+=sizeof(float);
7265 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7266 temppoint+=sizeof(int);
7267 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7268 temppoint+=sizeof(int);
7269 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7270 temppoint+=sizeof(float);
7271 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7272 temppoint+=sizeof(float);
7273 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7274 temppoint+=sizeof(float);
7275 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7276 temppoint+=sizeof(int);
7277 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7278 temppoint+=sizeof(int);
7279 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7280 temppoint+=sizeof(int);
7281 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7282 temppoint+=sizeof(int);
7283 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7284 temppoint+=sizeof(int);
7285 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7286 temppoint+=sizeof(int);
7287 chatname[temppoint]='\0';
7289 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);
7290 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7291 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7293 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);
7295 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7296 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7298 //bigrefreshdelay=.02;
7303 if(!player[0].jumpkeydown){
7304 player[0].jumptogglekeydown=0;
7306 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7309 dialoguetime+=multiplier;
7310 skybox.cloudmove+=multiplier;
7311 hawkrotation+=multiplier*25;
7313 realhawkcoords.x=25;
7314 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7315 hawkcalldelay-=multiplier/2;
7317 if(hawkcalldelay<=0)
7319 static float gLoc[3];
7320 static float vel[3];
7321 gLoc[0]=realhawkcoords.x;
7322 gLoc[1]=realhawkcoords.y;
7323 gLoc[2]=realhawkcoords.z;
7327 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
7328 FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
7329 FSOUND_SetVolume(channels[hawksound], 128);
7330 FSOUND_SetPaused(channels[hawksound], false);
7332 hawkcalldelay=16+abs(Random()%8);
7334 static float temptexdetail;
7337 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7338 player[0].damagetolerance=200000;
7341 player[0].permanentdamage=0;
7342 player[0].superpermanentdamage=0;
7345 whichchar = abs(Random()%7);
7346 registrationname[whichchar]+=1;
7350 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7352 if(environment>2)environment=0;
7353 Setenvironment(environment);
7359 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7363 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7364 cameramode=1-cameramode;
7365 cameratogglekeydown=1;
7368 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7369 cameratogglekeydown=0;
7372 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7373 if(player[0].num_weapons>0){
7374 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7375 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7376 else weapons.type[player[0].weaponids[0]]=sword;
7377 if(weapons.type[player[0].weaponids[0]]==sword){
7378 weapons.mass[player[0].weaponids[0]]=1.5;
7379 weapons.tipmass[player[0].weaponids[0]]=1;
7380 weapons.length[player[0].weaponids[0]]=.8;
7382 if(weapons.type[player[0].weaponids[0]]==staff){
7383 weapons.mass[player[0].weaponids[0]]=2;
7384 weapons.tipmass[player[0].weaponids[0]]=1;
7385 weapons.length[player[0].weaponids[0]]=1.5;
7388 if(weapons.type[player[0].weaponids[0]]==knife){
7389 weapons.mass[player[0].weaponids[0]]=1;
7390 weapons.tipmass[player[0].weaponids[0]]=1.2;
7391 weapons.length[player[0].weaponids[0]]=.25;
7395 /*for(i=0;i<objects.numobjects;i++){
7396 if(objects.type[i]==treeleavestype){
7397 for(j=0;j<objects.numobjects;j++){
7398 if(objects.type[j]==treetrunktype)
7399 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7400 objects.scale[i]=objects.scale[j];
7404 detailtogglekeydown=1;
7407 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7409 float closestdist=-1;
7412 for(i=1;i<numplayers;i++){
7413 distance=findDistancefast(&player[i].coords,&player[0].coords);
7414 if(closestdist==-1||distance<closestdist){
7415 closestdist=distance;
7420 if(player[closest].num_weapons)
7422 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7423 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7424 else weapons.type[player[closest].weaponids[0]]=sword;
7425 if(weapons.type[player[closest].weaponids[0]]==sword){
7426 weapons.mass[player[closest].weaponids[0]]=1.5;
7427 weapons.tipmass[player[closest].weaponids[0]]=1;
7428 weapons.length[player[closest].weaponids[0]]=.8;
7430 if(weapons.type[player[0].weaponids[0]]==staff){
7431 weapons.mass[player[0].weaponids[0]]=2;
7432 weapons.tipmass[player[0].weaponids[0]]=1;
7433 weapons.length[player[0].weaponids[0]]=1.5;
7435 if(weapons.type[player[closest].weaponids[0]]==knife){
7436 weapons.mass[player[closest].weaponids[0]]=1;
7437 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7438 weapons.length[player[closest].weaponids[0]]=.25;
7441 if(!player[closest].num_weapons)
7443 player[closest].weaponids[0]=weapons.numweapons;
7444 weapons.owner[weapons.numweapons]=closest;
7445 weapons.type[weapons.numweapons]=knife;
7446 weapons.damage[weapons.numweapons]=0;
7447 weapons.numweapons++;
7448 player[closest].num_weapons=1;
7449 if(weapons.type[player[closest].weaponids[0]]==sword){
7450 weapons.mass[player[closest].weaponids[0]]=1.5;
7451 weapons.tipmass[player[closest].weaponids[0]]=1;
7452 weapons.length[player[closest].weaponids[0]]=.8;
7454 if(weapons.type[player[closest].weaponids[0]]==knife){
7455 weapons.mass[player[closest].weaponids[0]]=1;
7456 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7457 weapons.length[player[closest].weaponids[0]]=.25;
7461 detailtogglekeydown=1;
7464 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7466 float closestdist=-1;
7469 for(i=1;i<numplayers;i++){
7470 distance=findDistancefast(&player[i].coords,&player[0].coords);
7471 if(closestdist==-1||distance<closestdist){
7472 closestdist=distance;
7477 player[closest].rotation+=multiplier*50;
7478 player[closest].targetrotation=player[closest].rotation;
7482 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7484 float closestdist=-1;
7487 for(i=1;i<numplayers;i++){
7488 distance=findDistancefast(&player[i].coords,&player[0].coords);
7489 if(closestdist==-1||distance<closestdist){
7490 closestdist=distance;
7494 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7497 player[closest].whichskin++;
7498 if(player[closest].whichskin>9)player[closest].whichskin=0;
7499 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7501 if(player[closest].creature==rabbittype){
7502 if(player[closest].whichskin==0){
7503 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7505 else if(player[closest].whichskin==1){
7506 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7508 else if(player[closest].whichskin==2){
7509 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7511 else if(player[closest].whichskin==3){
7512 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7514 else if(player[closest].whichskin==4){
7515 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7517 else if(player[closest].whichskin==5){
7518 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7520 else if(player[closest].whichskin==6){
7521 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7523 else if(player[closest].whichskin==7){
7524 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7526 else if(player[closest].whichskin==8){
7527 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7529 else if(player[closest].whichskin==9){
7530 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7533 if(player[closest].creature==wolftype){
7535 if(player[closest].whichskin==0){
7536 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7538 else if(player[closest].whichskin==1){
7539 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7541 else if(player[closest].whichskin==2){
7542 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7547 if(player[closest].numclothes){
7548 for(i=0;i<player[closest].numclothes;i++){
7549 tintr=player[closest].clothestintr[i];
7550 tintg=player[closest].clothestintg[i];
7551 tintb=player[closest].clothestintb[i];
7552 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7554 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7557 detailtogglekeydown=1;
7560 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7562 float closestdist=-1;
7565 for(i=1;i<numplayers;i++){
7566 distance=findDistancefast(&player[i].coords,&player[0].coords);
7567 if(closestdist==-1||distance<closestdist){
7568 closestdist=distance;
7573 if(player[closest].creature==wolftype){
7574 headprop=player[closest].proportionhead.x/1.1;
7575 bodyprop=player[closest].proportionbody.x/1.1;
7576 armprop=player[closest].proportionarms.x/1.1;
7577 legprop=player[closest].proportionlegs.x/1.1;
7580 if(player[closest].creature==rabbittype){
7581 headprop=player[closest].proportionhead.x/1.2;
7582 bodyprop=player[closest].proportionbody.x/1.05;
7583 armprop=player[closest].proportionarms.x/1.00;
7584 legprop=player[closest].proportionlegs.x/1.1;
7588 if(player[closest].creature==rabbittype){
7589 player[closest].skeleton.id=closest;
7590 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);
7591 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7592 player[closest].whichskin=0;
7593 player[closest].creature=wolftype;
7595 player[closest].proportionhead=1.1;
7596 player[closest].proportionbody=1.1;
7597 player[closest].proportionarms=1.1;
7598 player[closest].proportionlegs=1.1;
7599 player[closest].proportionlegs.y=1.1;
7600 player[closest].scale=.23*5*player[0].scale;
7602 player[closest].damagetolerance=300;
7606 player[closest].skeleton.id=closest;
7607 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);
7608 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7609 player[closest].whichskin=0;
7610 player[closest].creature=rabbittype;
7612 player[closest].proportionhead=1.2;
7613 player[closest].proportionbody=1.05;
7614 player[closest].proportionarms=1.00;
7615 player[closest].proportionlegs=1.1;
7616 player[closest].proportionlegs.y=1.05;
7617 player[closest].scale=.2*5*player[0].scale;
7619 player[closest].damagetolerance=200;
7622 if(player[closest].creature==wolftype){
7623 player[closest].proportionhead=1.1*headprop;
7624 player[closest].proportionbody=1.1*bodyprop;
7625 player[closest].proportionarms=1.1*armprop;
7626 player[closest].proportionlegs=1.1*legprop;
7629 if(player[closest].creature==rabbittype){
7630 player[closest].proportionhead=1.2*headprop;
7631 player[closest].proportionbody=1.05*bodyprop;
7632 player[closest].proportionarms=1.00*armprop;
7633 player[closest].proportionlegs=1.1*legprop;
7634 player[closest].proportionlegs.y=1.05*legprop;
7638 detailtogglekeydown=1;
7641 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7642 detailtogglekeydown=0;
7645 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7648 slomotogglekeydown=1;
7652 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7654 float closestdist=-1;
7656 XYZ flatfacing2,flatvelocity2;
7659 for(i=1;i<numplayers;i++){
7660 distance=findDistancefast(&player[i].coords,&player[0].coords);
7661 if(distance<144&&!player[i].headless)
7662 if(closestdist==-1||distance<closestdist){
7663 closestdist=distance;
7665 blah = player[i].coords;
7670 XYZ headspurtdirection;
7671 int i = player[closest].skeleton.jointlabels[head];
7672 for(k=0;k<player[closest].skeleton.num_joints; k++){
7673 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7674 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7675 if(!player[closest].skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords;
7676 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7677 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7678 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7679 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7680 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7681 Normalise(&headspurtdirection);
7682 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7683 flatvelocity2+=headspurtdirection*8;
7684 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7686 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7696 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7697 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7698 FSOUND_SetVolume(channels[splattersound], 256);
7699 FSOUND_SetPaused(channels[splattersound], false);
7701 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7702 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7703 FSOUND_SetVolume(channels[breaksound2], 100);
7704 FSOUND_SetPaused(channels[breaksound2], false);
7706 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7707 player[closest].RagDoll(0);
7708 player[closest].dead=2;
7709 player[closest].headless=1;
7710 player[closest].DoBloodBig(3,165);
7715 explodetogglekeydown=1;
7718 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7720 float closestdist=-1;
7722 XYZ flatfacing2,flatvelocity2;
7725 for(i=1;i<numplayers;i++){
7726 distance=findDistancefast(&player[i].coords,&player[0].coords);
7728 if(closestdist==-1||distance<closestdist){
7729 closestdist=distance;
7731 blah=player[i].coords;
7745 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7746 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7747 FSOUND_SetVolume(channels[splattersound], 256);
7748 FSOUND_SetPaused(channels[splattersound], false);
7750 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7751 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7752 FSOUND_SetVolume(channels[breaksound2], 600);
7753 FSOUND_SetPaused(channels[breaksound2], false);
7755 for(i=0;i<player[closest].skeleton.num_joints; i++){
7756 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7757 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7758 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;
7759 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7760 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7761 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7762 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7763 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7764 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7765 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7768 for(i=0;i<player[closest].skeleton.num_joints; i++){
7769 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7770 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7771 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;
7772 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7773 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7774 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7775 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7776 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7777 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7780 for(i=0;i<player[closest].skeleton.num_joints; i++){
7781 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7782 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7783 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;
7784 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7785 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7786 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7787 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7788 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7789 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7792 for(i=0;i<player[closest].skeleton.num_joints; i++){
7793 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7794 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7795 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;
7796 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7797 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7798 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7799 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7800 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7801 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7805 for(j=0;j<numplayers; j++){
7807 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7808 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7809 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7810 player[j].skeleton.longdead=0;
7811 player[j].RagDoll(0);
7812 for(i=0;i<player[j].skeleton.num_joints; i++){
7813 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7814 if(findDistancefast(&temppos,&player[closest].coords)<25){
7815 flatvelocity2=temppos-player[closest].coords;
7816 Normalise(&flatvelocity2);
7817 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7824 player[closest].DoDamage(10000);
7825 player[closest].RagDoll(0);
7826 player[closest].dead=2;
7827 player[closest].coords=20;
7828 player[closest].skeleton.free=2;
7834 explodetogglekeydown=1;
7837 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7838 explodetogglekeydown=0;
7842 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7844 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7845 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7846 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7847 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7848 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7849 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7850 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7852 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7853 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7854 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7855 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7856 for(j=0;j<player[0].num_weapons;j++){
7857 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7859 fwrite( &environment, 1, sizeof(int), tfile );
7861 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7862 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7863 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7864 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7865 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7867 fwrite( &numplayers, 1, sizeof(int), tfile );
7868 if(numplayers>1&&numplayers<maxplayers)
7869 for(i=1;i<numplayers;i++){
7870 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7871 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7872 for(j=0;j<player[i].num_weapons;j++){
7873 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7875 if(player[i].numwaypoints<30){
7876 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7877 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7878 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7879 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7882 player[i].numwaypoints=0;
7883 player[i].waypoint=0;
7884 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7885 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7886 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7892 slomotogglekeydown=1;
7895 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7896 slomotogglekeydown=0;
7900 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7901 player[0].onfire=1-player[0].onfire;
7902 if(player[0].onfire){
7903 player[0].CatchFire();
7905 if(!player[0].onfire){
7908 gLoc[0]=player[0].coords.x;
7909 gLoc[1]=player[0].coords.y;
7910 gLoc[2]=player[0].coords.z;
7914 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7915 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7916 FSOUND_SetVolume(channels[fireendsound], 256);
7917 FSOUND_SetPaused(channels[fireendsound], false);
7918 FSOUND_SetPaused(channels[stream_firesound], true);
7920 slomotogglekeydown=1;
7923 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7924 if(player[0].bleeding<=0)
7925 player[0].DoBlood(1,255);
7929 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7931 float closestdist=-1;
7934 for(i=1;i<numplayers;i++){
7935 distance=findDistancefast(&player[i].coords,&player[0].coords);
7936 if(closestdist==-1||distance<closestdist){
7937 closestdist=distance;
7941 if(closestdist>0&&closest>=0){
7942 //player[closest]=player[numplayers-1];
7943 //player[closest].skeleton=player[numplayers-1].skeleton;
7946 drawmodetogglekeydown=1;
7949 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7951 float closestdist=-1;
7954 for(i=1;i<max_objects;i++){
7955 distance=findDistancefast(&objects.position[i],&player[0].coords);
7956 if(closestdist==-1||distance<closestdist){
7957 closestdist=distance;
7961 if(closestdist>0&&closest>=0){
7962 objects.position[closest].y-=500;
7964 drawmodetogglekeydown=1;
7967 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7969 //if(drawmode>2)drawmode=0;
7970 if(objects.numobjects<max_objects-1){
7972 boxcoords.x=player[0].coords.x;
7973 boxcoords.z=player[0].coords.z;
7974 boxcoords.y=player[0].coords.y-3;
7975 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7976 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7977 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7978 float temprotat,temprotat2;
7979 temprotat=editorrotation;
7980 temprotat2=editorrotation2;
7981 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7982 if(temprotat2<0)temprotat2=Random()%360;
7984 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7985 if(editortype==treetrunktype)
7986 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7989 drawmodetogglekeydown=1;
7992 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7993 if(numplayers<maxplayers-1){
7994 player[numplayers].scale=.2*5*player[0].scale;
7995 player[numplayers].creature=rabbittype;
7996 player[numplayers].howactive=editoractive;
7997 player[numplayers].skeleton.id=numplayers;
7998 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);
8000 //texsize=512*512*3/texdetail/texdetail;
8001 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
8002 //player[numplayers].skeleton.skinText.resize(texsize);
8004 k=abs(Random()%2)+1;
8006 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8007 player[numplayers].whichskin=0;
8010 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8011 player[numplayers].whichskin=1;
8014 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8015 player[numplayers].whichskin=2;
8018 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
8019 player[numplayers].power=1;
8020 player[numplayers].speedmult=1;
8021 player[numplayers].currentanimation=bounceidleanim;
8022 player[numplayers].targetanimation=bounceidleanim;
8023 player[numplayers].currentframe=0;
8024 player[numplayers].targetframe=1;
8025 player[numplayers].target=0;
8026 player[numplayers].bled=0;
8027 player[numplayers].speed=1+(float)(Random()%100)/1000;
8029 player[numplayers].targetrotation=player[0].targetrotation;
8030 player[numplayers].rotation=player[0].rotation;
8032 player[numplayers].velocity=0;
8033 player[numplayers].coords=player[0].coords;
8034 player[numplayers].oldcoords=player[numplayers].coords;
8035 player[numplayers].realoldcoords=player[numplayers].coords;
8037 player[numplayers].id=numplayers;
8038 player[numplayers].skeleton.id=numplayers;
8039 player[numplayers].updatedelay=0;
8040 player[numplayers].normalsupdatedelay=0;
8042 player[numplayers].aitype=passivetype;
8043 player[numplayers].aitarget=0;
8045 if(player[0].creature==wolftype){
8046 headprop=player[0].proportionhead.x/1.1;
8047 bodyprop=player[0].proportionbody.x/1.1;
8048 armprop=player[0].proportionarms.x/1.1;
8049 legprop=player[0].proportionlegs.x/1.1;
8052 if(player[0].creature==rabbittype){
8053 headprop=player[0].proportionhead.x/1.2;
8054 bodyprop=player[0].proportionbody.x/1.05;
8055 armprop=player[0].proportionarms.x/1.00;
8056 legprop=player[0].proportionlegs.x/1.1;
8059 if(player[numplayers].creature==wolftype){
8060 player[numplayers].proportionhead=1.1*headprop;
8061 player[numplayers].proportionbody=1.1*bodyprop;
8062 player[numplayers].proportionarms=1.1*armprop;
8063 player[numplayers].proportionlegs=1.1*legprop;
8066 if(player[numplayers].creature==rabbittype){
8067 player[numplayers].proportionhead=1.2*headprop;
8068 player[numplayers].proportionbody=1.05*bodyprop;
8069 player[numplayers].proportionarms=1.00*armprop;
8070 player[numplayers].proportionlegs=1.1*legprop;
8071 player[numplayers].proportionlegs.y=1.05*legprop;
8074 player[numplayers].headless=0;
8075 player[numplayers].onfire=0;
8078 player[numplayers].proportionhead.z=0;
8079 player[numplayers].proportionbody.z=0;
8080 player[numplayers].proportionarms.z=0;
8081 player[numplayers].proportionlegs.z=0;
8084 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
8086 player[numplayers].damagetolerance=200;
8088 player[numplayers].protectionhead=player[0].protectionhead;
8089 player[numplayers].protectionhigh=player[0].protectionhigh;
8090 player[numplayers].protectionlow=player[0].protectionlow;
8091 player[numplayers].armorhead=player[0].armorhead;
8092 player[numplayers].armorhigh=player[0].armorhigh;
8093 player[numplayers].armorlow=player[0].armorlow;
8094 player[numplayers].metalhead=player[0].metalhead;
8095 player[numplayers].metalhigh=player[0].metalhigh;
8096 player[numplayers].metallow=player[0].metallow;
8098 player[numplayers].immobile=player[0].immobile;
8100 player[numplayers].numclothes=player[0].numclothes;
8101 if(player[numplayers].numclothes)
8102 for(i=0;i<player[numplayers].numclothes;i++){
8103 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8104 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8105 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8106 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8107 tintr=player[numplayers].clothestintr[i];
8108 tintg=player[numplayers].clothestintg[i];
8109 tintb=player[numplayers].clothestintb[i];
8110 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8112 if(player[numplayers].numclothes){
8113 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8116 player[numplayers].power=player[0].power;
8117 player[numplayers].speedmult=player[0].speedmult;
8119 player[numplayers].damage=0;
8120 player[numplayers].permanentdamage=0;
8121 player[numplayers].superpermanentdamage=0;
8122 player[numplayers].deathbleeding=0;
8123 player[numplayers].bleeding=0;
8124 player[numplayers].numwaypoints=0;
8125 player[numplayers].waypoint=0;
8126 player[numplayers].jumppath=0;
8127 player[numplayers].weaponstuck=-1;
8128 player[numplayers].weaponactive=-1;
8129 player[numplayers].num_weapons=0;
8130 player[numplayers].bloodloss=0;
8131 player[numplayers].dead=0;
8133 player[numplayers].loaded=1;
8137 drawmodetogglekeydown=1;
8140 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8141 if(player[numplayers-1].numwaypoints<90){
8142 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8143 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8144 player[numplayers-1].numwaypoints++;
8146 drawmodetogglekeydown=1;
8149 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8150 if(numpathpoints<30){
8151 bool connected,alreadyconnected;
8154 for(i=0;i<numpathpoints;i++){
8155 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8157 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8158 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8160 if(!alreadyconnected){
8161 numpathpointconnect[pathpointselected]++;
8163 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8169 pathpoint[numpathpoints-1]=player[0].coords;
8170 numpathpointconnect[numpathpoints-1]=0;
8171 if(numpathpoints>1&&pathpointselected!=-1){
8172 numpathpointconnect[pathpointselected]++;
8173 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8175 pathpointselected=numpathpoints-1;
8178 drawmodetogglekeydown=1;
8181 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8182 pathpointselected++;
8183 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8184 drawmodetogglekeydown=1;
8186 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8187 pathpointselected--;
8188 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8189 drawmodetogglekeydown=1;
8191 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8192 if(pathpointselected!=-1){
8194 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8195 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8196 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8197 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8199 for(i=0;i<numpathpoints;i++){
8200 for(j=0;j<numpathpointconnect[i];j++){
8201 if(pathpointconnect[i][j]==pathpointselected){
8202 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8203 numpathpointconnect[i]--;
8205 if(pathpointconnect[i][j]==numpathpoints){
8206 pathpointconnect[i][j]=pathpointselected;
8210 pathpointselected=numpathpoints-1;
8212 drawmodetogglekeydown=1;
8215 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8216 editorenabled=1-editorenabled;
8218 player[0].damagetolerance=100000;
8220 player[0].superpermanentdamage=0;
8221 player[0].bloodloss=0;
8222 player[0].deathbleeding=0;
8225 player[0].damagetolerance=200;
8227 player[0].permanentdamage=0;
8228 player[0].superpermanentdamage=0;
8229 player[0].bloodloss=0;
8230 player[0].deathbleeding=0;
8232 drawmodetogglekeydown=1;
8235 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8237 if(editortype==treeleavestype||editortype==10)editortype--;
8238 if(editortype<0)editortype=firetype;
8239 drawmodetogglekeydown=1;
8242 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8244 if(editortype==treeleavestype||editortype==10)editortype++;
8245 if(editortype>firetype)editortype=0;
8246 drawmodetogglekeydown=1;
8249 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8250 editorrotation-=multiplier*100;
8251 if(editorrotation<-.01)editorrotation=-.01;
8252 drawmodetogglekeydown=1;
8255 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8256 editorrotation+=multiplier*100;
8257 drawmodetogglekeydown=1;
8260 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8261 editorsize+=multiplier;
8262 drawmodetogglekeydown=1;
8265 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8266 editorsize-=multiplier;
8267 if(editorsize<.1)editorsize=.1;
8268 drawmodetogglekeydown=1;
8272 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8273 mapradius-=multiplier*10;
8276 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8277 mapradius+=multiplier*10;
8280 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8281 mapcenter.x+=multiplier*20;
8284 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8285 mapcenter.x-=multiplier*20;
8288 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8289 mapcenter.z+=multiplier*20;
8292 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8293 mapcenter.z-=multiplier*20;
8296 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8297 editorrotation2+=multiplier*100;
8300 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8301 editorrotation2-=multiplier*100;
8302 if(editorrotation2<-.01)editorrotation2=-.01;
8304 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8306 float closestdist=-1;
8308 for(i=0;i<objects.numobjects;i++){
8309 distance=findDistancefast(&objects.position[i],&player[0].coords);
8310 if(closestdist==-1||distance<closestdist){
8311 closestdist=distance;
8315 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8316 drawmodetogglekeydown=1;
8320 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)){
8321 drawmodetogglekeydown=0;
8324 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8325 //if(!player[0].skeleton.free)player[0].damage+=500;
8326 player[0].RagDoll(0);
8327 //player[0].spurt=1;
8328 //player[0].DoDamage(1000);
8332 gLoc[0]=player[0].coords.x;
8333 gLoc[1]=player[0].coords.y;
8334 gLoc[2]=player[0].coords.z;
8335 vel[0]=player[0].velocity.x;
8336 vel[1]=player[0].velocity.y;
8337 vel[2]=player[0].velocity.z;
8338 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
8339 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8340 FSOUND_SetVolume(channels[whooshsound], 128);
8341 FSOUND_SetPaused(channels[whooshsound], false);
8342 //FSOUND_SetPaused(channels[whooshsound], true);
8344 texturesizetogglekeydown=1;
8347 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8350 float closestdist=-1;
8352 for(i=0;i<objects.numobjects;i++){
8353 if(objects.type[i]==treeleavestype){
8354 objects.scale[i]*=.9;
8357 texturesizetogglekeydown=1;
8360 static XYZ relative;
8361 static int randattack;
8363 static bool playerrealattackkeydown=0;
8365 if(!buttons[0])oldbutton=0;
8366 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8367 if(oldattackkey)player[0].attackkeydown=0;
8368 if(oldattackkey)playerrealattackkeydown=0;
8369 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8370 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);
8371 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8372 for(k=0;k<numplayers;k++){
8373 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8374 player[k].Reverse();
8378 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8380 for(k=0;k<numplayers;k++){
8381 if(indialogue!=-1)player[k].attackkeydown=0;
8382 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8383 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8384 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)){
8385 player[k].jumppower-=2;
8387 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)){
8388 for(i=0;i<numplayers;i++){
8390 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8391 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8392 player[k].targetanimation=dodgebackanim;
8394 player[k].targetframe=0;
8395 rotatetarget=player[i].coords-player[k].coords;
8396 Normalise(&rotatetarget);
8397 player[k].targetrotation=-asin(0-rotatetarget.x);
8398 player[k].targetrotation*=360/6.28;
8399 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8401 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8404 if(player[k].targetanimation!=dodgebackanim){
8405 if(k==0)numflipped++;
8406 player[k].targetanimation=backhandspringanim;
8408 player[k].targetframe=0;
8409 player[k].targetrotation=-rotation+180;
8410 if(player[k].leftkeydown)player[k].targetrotation-=45;
8411 if(player[k].rightkeydown)player[k].targetrotation+=45;
8412 player[k].rotation=player[k].targetrotation;
8413 player[k].jumppower-=2;
8416 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())){
8417 player[k].hasvictim=0;
8419 for(i=0;i<numplayers;i++){
8421 if(!player[k].hasvictim)
8422 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8423 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){
8424 player[k].victim=&player[i];
8425 player[k].hasvictim=1;
8426 if(player[k].aitype==playercontrolled){
8427 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;
8428 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;
8429 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8430 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;
8431 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;
8432 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;
8433 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;
8434 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;
8435 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8436 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height==lowheight&&animation[player[k].targetanimation].attack!=normalattack)player[k].targetanimation=lowkickanim;
8439 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8440 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8441 else randattack=abs(Random()%5);
8442 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8443 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8444 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8445 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8446 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8448 if(player[k].weaponactive!=-1){
8449 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;
8450 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;
8451 //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;
8452 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;
8453 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;
8454 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;
8455 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;
8456 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;
8460 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8462 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)){
8463 if(player[k].weaponactive==-1){
8464 player[i].targetanimation=sneakattackedanim;
8465 player[i].currentanimation=sneakattackedanim;
8466 player[k].currentanimation=sneakattackanim;
8467 player[k].targetanimation=sneakattackanim;
8468 player[k].oldcoords=player[k].coords;
8469 player[k].coords=player[i].coords;
8471 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8472 player[i].targetanimation=knifesneakattackedanim;
8473 player[i].currentanimation=knifesneakattackedanim;
8474 player[k].currentanimation=knifesneakattackanim;
8475 player[k].targetanimation=knifesneakattackanim;
8476 player[i].oldcoords=player[i].coords;
8477 player[i].coords=player[k].coords;
8479 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8480 player[i].targetanimation=swordsneakattackedanim;
8481 player[i].currentanimation=swordsneakattackedanim;
8482 player[k].currentanimation=swordsneakattackanim;
8483 player[k].targetanimation=swordsneakattackanim;
8484 player[i].oldcoords=player[i].coords;
8485 player[i].coords=player[k].coords;
8487 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8488 player[k].victim=&player[i];
8489 player[k].hasvictim=1;
8490 player[i].targettilt2=0;
8491 player[i].targetframe=1;
8492 player[i].currentframe=0;
8494 player[i].velocity=0;
8495 player[k].targettilt2=player[i].targettilt2;
8496 player[k].currentframe=player[i].currentframe;
8497 player[k].targetframe=player[i].targetframe;
8498 player[k].target=player[i].target;
8499 player[k].velocity=0;
8500 player[k].targetrotation=player[i].rotation;
8501 player[k].rotation=player[i].rotation;
8502 player[i].targetrotation=player[i].rotation;
8505 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8507 player[k].targetframe=0;
8509 //player[k].velocity=0;
8511 rotatetarget=player[i].coords-player[k].coords;
8512 Normalise(&rotatetarget);
8513 player[k].targetrotation=-asin(0-rotatetarget.x);
8514 player[k].targetrotation*=360/6.28;
8515 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8517 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8519 player[k].lastattack3=player[k].lastattack2;
8520 player[k].lastattack2=player[k].lastattack;
8521 player[k].lastattack=player[k].targetanimation;
8522 //player[k].targettilt2=0;
8526 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8527 rotatetarget=player[i].coords-player[k].coords;
8528 Normalise(&rotatetarget);
8529 player[k].targetrotation=-asin(0-rotatetarget.x);
8530 player[k].targetrotation*=360/6.28;
8531 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8532 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8534 player[k].victim=&player[i];
8535 player[k].hasvictim=1;
8536 player[i].targetanimation=knifefollowedanim;
8537 player[i].currentanimation=knifefollowedanim;
8538 player[i].targettilt2=0;
8539 player[i].targettilt2=player[k].targettilt2;
8540 player[i].targetframe=1;
8541 player[i].currentframe=0;
8543 player[i].velocity=0;
8544 player[k].currentanimation=knifefollowanim;
8545 player[k].targetanimation=knifefollowanim;
8546 player[k].targettilt2=player[i].targettilt2;
8547 player[k].currentframe=player[i].currentframe;
8548 player[k].targetframe=player[i].targetframe;
8549 player[k].target=player[i].target;
8550 player[k].velocity=0;
8551 player[k].oldcoords=player[k].coords;
8552 player[i].coords=player[k].coords;
8553 player[i].targetrotation=player[k].targetrotation;
8554 player[i].rotation=player[k].targetrotation;
8555 player[k].rotation=player[k].targetrotation;
8556 player[i].rotation=player[k].targetrotation;
8561 if(player[k].weaponactive!=-1){
8562 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8565 for(i=0;i<numplayers;i++){
8567 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8568 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8569 if(player[i].skeleton.free)
8570 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)))){
8571 player[k].victim=&player[i];
8572 player[k].hasvictim=1;
8573 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8574 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;
8575 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;
8576 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;
8578 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){
8579 player[k].targetanimation=killanim;
8580 for(j=0;j<terrain.numdecals;j++){
8581 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8582 terrain.DeleteDecal(j);
8585 for(l=0;l<objects.numobjects;l++){
8586 if(objects.model[l].type==decalstype)
8587 for(j=0;j<objects.model[l].numdecals;j++){
8588 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8589 objects.model[l].DeleteDecal(j);
8594 if(!player[i].dead||musictype!=2)
8595 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)){
8596 player[k].targetanimation=dropkickanim;
8597 for(j=0;j<terrain.numdecals;j++){
8598 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8599 terrain.DeleteDecal(j);
8602 for(l=0;l<objects.numobjects;l++){
8603 if(objects.model[l].type==decalstype)
8604 for(j=0;j<objects.model[l].numdecals;j++){
8605 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8606 objects.model[l].DeleteDecal(j);
8612 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)){
8614 player[k].targetframe=0;
8616 //player[k].velocity=0;
8618 rotatetarget=player[i].coords-player[k].coords;
8619 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8620 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;
8622 Normalise(&rotatetarget);
8623 player[k].targetrotation=-asin(0-rotatetarget.x);
8624 player[k].targetrotation*=360/6.28;
8625 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8627 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8628 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8631 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8632 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8634 player[k].lastattack3=player[k].lastattack2;
8635 player[k].lastattack2=player[k].lastattack;
8636 player[k].lastattack=player[k].targetanimation;
8638 if(player[k].targetanimation==swordgroundstabanim){
8639 player[k].targetrotation+=30;
8641 //player[k].targettilt2=0;
8647 if(!player[k].hasvictim){
8648 for(i=0;i<numplayers;i++){
8649 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8650 player[k].victim=&player[i];
8651 player[k].hasvictim=1;
8653 if(player[k].hasvictim&&!player[i].skeleton.free)
8654 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8655 player[k].victim=&player[i];
8659 if(player[k].aitype==playercontrolled)
8660 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)){
8662 player[k].targetanimation=rabbitkickanim;
8663 player[k].targetframe=0;
8666 if(animation[player[k].targetanimation].attack&&k==0){
8669 if(player[k].weaponactive!=-1){
8670 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8673 if(player[k].weaponactive!=-1){
8674 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8677 if(player[k].weaponactive!=-1){
8678 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8680 if(armedstaff)numstaffattack++;
8681 else if(armedsword)numswordattack++;
8682 else if(armedknife)numknifeattack++;
8683 else numunarmedattack++;
8690 static float collisionradius;
8692 for(k=0;k<numplayers;k++){
8693 for(i=k;i<numplayers;i++){
8696 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))
8697 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))
8698 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8699 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8700 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)
8701 if(player[i].coords.y>player[k].coords.y-3)
8702 if(player[i].coords.y<player[k].coords.y+3)
8703 if(player[i].coords.x>player[k].coords.x-3)
8704 if(player[i].coords.x<player[k].coords.x+3)
8705 if(player[i].coords.z>player[k].coords.z-3)
8706 if(player[i].coords.z<player[k].coords.z+3){
8707 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)){
8708 if(player[i].onfire||player[k].onfire){
8709 if(!player[i].onfire)player[i].CatchFire();
8710 if(!player[k].onfire)player[k].CatchFire();
8714 tempcoords1=player[i].coords;
8715 tempcoords2=player[k].coords;
8716 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8717 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8718 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8719 if(player[0].hasvictim)
8720 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8721 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8723 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)){
8724 player[k].coords.y=player[i].coords.y;
8725 player[i].velocity=player[k].velocity;
8726 player[i].skeleton.free=0;
8727 player[i].rotation=0;
8728 player[i].RagDoll(0);
8729 player[i].DoDamage(20);
8730 if(k==0)camerashake+=.3;
8731 player[i].skeleton.longdead=0;
8732 player[k].lastcollide=1;
8735 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)){
8736 player[i].coords.y=player[k].coords.y;
8737 player[k].velocity=player[i].velocity;
8738 player[k].skeleton.free=0;
8739 player[k].rotation=0;
8740 player[k].RagDoll(0);
8741 player[k].DoDamage(20);
8742 if(i==0)camerashake+=.3;
8743 player[k].skeleton.longdead=0;
8744 player[i].lastcollide=1;
8747 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)){
8748 rotatetarget=player[k].velocity-player[i].velocity;
8749 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))
8750 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))){
8752 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)){
8753 static float gLoc[3];
8754 static float vel[3];
8755 gLoc[0]=player[i].coords.x;
8756 gLoc[1]=player[i].coords.y;
8757 gLoc[2]=player[i].coords.z;
8758 vel[0]=player[i].velocity.x;
8759 vel[1]=player[i].velocity.y;
8760 vel[2]=player[i].velocity.z;
8761 if(tutoriallevel!=1){
8762 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8763 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8764 FSOUND_SetVolume(channels[heavyimpactsound], 256);
8765 FSOUND_SetPaused(channels[heavyimpactsound], false);
8767 //player[i].velocity=player[k].velocity;
8768 //player[k].velocity=player[i].velocity;
8770 player[i].RagDoll(0);
8771 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8776 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8777 player[k].RagDoll(0);
8778 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8783 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8785 //if(player[i].skeleton.oldfree){
8786 for(j=0;j<player[i].skeleton.num_joints;j++){
8787 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8790 //if(player[k].skeleton.oldfree){
8791 for(j=0;j<player[k].skeleton.num_joints;j++){
8792 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8798 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)){
8800 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8801 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)){
8802 rotatetarget=player[k].coords-player[i].coords;
8803 Normalise(&rotatetarget);
8804 player[k].coords=(player[k].coords+player[i].coords)/2;
8805 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);
8806 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8807 if(player[k].howactive==typeactive||hostile)
8808 if(player[k].isIdle()){
8809 if(player[k].howactive<typesleeping){
8810 player[k].targetanimation=player[k].getStop();
8811 player[k].targetframe=0;
8814 else if(player[k].howactive==typesleeping)
8816 player[k].targetanimation=getupfromfrontanim;
8817 player[k].targetframe=0;
8820 if(!editorenabled)player[k].howactive=typeactive;
8822 if(player[i].howactive==typeactive||hostile)
8823 if(player[i].isIdle()){
8824 if(player[i].howactive<typesleeping){
8825 player[i].targetanimation=player[i].getStop();
8826 player[i].targetframe=0;
8831 player[i].targetanimation=getupfromfrontanim;
8832 player[i].targetframe=0;
8835 if(!editorenabled)player[i].howactive=typeactive;
8839 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){
8840 player[i].velocity=player[k].velocity;
8841 player[k].velocity=player[k].velocity*-.5;
8842 //player[i].velocity.y-=10;
8843 player[k].velocity.y=player[i].velocity.y;
8844 player[i].DoDamage(20);
8845 player[i].RagDoll(0);
8846 player[k].lastcollide=1;
8853 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){
8854 player[k].velocity=player[i].velocity;
8855 player[i].velocity=player[i].velocity*-.3;
8856 //player[k].velocity.y-=10;
8857 player[i].velocity.y=player[k].velocity.y;
8858 player[k].DoDamage(20);
8859 player[k].RagDoll(0);
8860 player[i].lastcollide=1;
8871 player[i].CheckKick();
8872 player[k].CheckKick();
8878 for(k=0;k<numplayers;k++){
8879 for(i=k;i<numplayers;i++){
8881 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))){
8882 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)){
8883 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)){
8884 player[i].victim=&player[k];
8885 player[i].targetanimation=jumpreversedanim;
8886 player[i].currentanimation=jumpreversedanim;
8887 player[k].currentanimation=jumpreversalanim;
8888 player[k].targetanimation=jumpreversalanim;
8889 player[i].targettilt2=0;
8890 player[i].currentframe=0;
8891 player[i].targetframe=1;
8892 player[k].currentframe=0;
8893 player[k].targetframe=1;
8894 if(player[i].coords.y<player[k].coords.y+1){
8895 player[i].targetanimation=rabbitkickreversedanim;
8896 player[i].currentanimation=rabbitkickreversedanim;
8897 player[k].currentanimation=rabbitkickreversalanim;
8898 player[k].targetanimation=rabbitkickreversalanim;
8899 player[k].currentframe=1;
8900 player[k].targetframe=2;
8901 player[i].currentframe=1;
8902 player[i].targetframe=2;
8904 player[k].targettilt2=0;
8906 player[i].velocity=0;
8907 player[k].velocity=0;
8908 player[k].oldcoords=player[k].coords;
8909 player[i].coords=player[k].coords;
8910 player[k].targetrotation=player[i].targetrotation;
8911 player[k].rotation=player[i].targetrotation;
8912 player[k].victim=&player[i];
8913 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8915 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)){
8916 player[k].victim=&player[i];
8917 player[k].targetanimation=jumpreversedanim;
8918 player[k].currentanimation=jumpreversedanim;
8919 player[i].currentanimation=jumpreversalanim;
8920 player[i].targetanimation=jumpreversalanim;
8921 player[k].targettilt2=0;
8922 player[i].targettilt2=0;
8923 player[k].currentframe=0;
8924 player[k].targetframe=1;
8925 player[i].currentframe=0;
8926 player[i].targetframe=1;
8927 if(player[k].coords.y<player[i].coords.y+1){
8928 player[k].targetanimation=rabbitkickreversedanim;
8929 player[k].currentanimation=rabbitkickreversedanim;
8930 player[i].currentanimation=rabbitkickreversalanim;
8931 player[i].targetanimation=rabbitkickreversalanim;
8932 player[k].currentframe=1;
8933 player[k].targetframe=2;
8934 player[i].currentframe=1;
8935 player[i].targetframe=2;
8938 player[k].velocity=0;
8939 player[i].velocity=0;
8940 player[i].oldcoords=player[i].coords;
8941 player[k].coords=player[i].coords;
8942 player[i].targetrotation=player[k].targetrotation;
8943 player[i].rotation=player[k].targetrotation;
8944 player[i].victim=&player[k];
8945 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8952 for(k=0;k<numplayers;k++)
8953 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8962 static float checkdelay;
8963 checkdelay-=multiplier;
8965 static bool checkedcoll[maxplayers][maxplayers];
8966 static bool above[maxplayers];
8968 for(i=0;i<maxplayers;i++){
8969 for(j=0;j<maxplayers;j++){
8970 checkedcoll[i][j]=0;
8974 if(numplayers>1&&checkdelay<=0){
8976 for(k=0;k<numplayers;k++){
8977 if(player[k].skeleton.free!=2)above[k]=-1;
8979 for(i=k;i<numplayers;i++){
8982 if(!checkedcoll[i][k]){
8983 checkedcoll[i][k]=1;
8984 checkedcoll[k][i]=1;
8985 if(player[i].skeleton.free&&player[k].skeleton.free)
8986 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8987 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8988 if(player[i].coords.y>player[k].coords.y-3)
8989 if(player[i].coords.y<player[k].coords.y+3)
8990 if(player[i].coords.x>player[k].coords.x-3)
8991 if(player[i].coords.x<player[k].coords.x+3)
8992 if(player[i].coords.z>player[k].coords.z-3)
8993 if(player[i].coords.z<player[k].coords.z+3)
8994 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)){
8996 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
9008 above[moving]=stuck;
9009 for(l=0;l<player[moving].skeleton.num_joints;l++){
9010 for(m=0;m<player[stuck].skeleton.num_joints;m++){
9011 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
9013 player[moving].skeleton.joints[l].position.y+=.003;
9014 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
9028 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
9029 texturesizetogglekeydown=0;
9032 for(k=0;k<numplayers;k++){
9033 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9034 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9035 player[k].DoDamage(1000);
9040 static bool respawnkeydown;
9041 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
9042 targetlevel=whichlevel;
9046 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
9047 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
9052 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
9054 if(targetlevel>numchallengelevels-1)targetlevel=0;
9057 slomotogglekeydown=1;
9061 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
9063 FSOUND_SetPaused(channels[whooshsound], true);
9065 for(k=0;k<numplayers;k++){
9068 player[k].permanentdamage=0;
9069 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
9070 player[k].aitype=passivetype;
9072 player[0].aitype=playercontrolled;
9076 static bool movekey;
9077 static bool connected;
9078 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
9079 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
9080 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
9081 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
9082 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
9083 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
9085 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
9087 for(int i=0;i<numplayers;i++){
9088 if(!player[i].skeleton.free){
9089 oldtargetrotation=player[i].targetrotation;
9090 if(i==0&&indialogue==-1){
9091 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){
9092 if(!cameramode)player[0].targetrotation=-rotation+180;
9093 if(cameramode)player[0].targetrotation=0;
9099 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9100 if(cameramode){facing=flatfacing;}
9102 facing=DoRotation(facing,-rotation2,0,0);
9103 facing=DoRotation(facing,0,0-rotation,0);
9106 player[0].lookrotation=-rotation;
9108 player[i].targetheadrotation=rotation;
9109 player[i].targetheadrotation2=rotation2;
9111 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9112 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){
9113 player[i].targetrotation=-player[i].lookrotation+180;
9119 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9121 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9122 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9124 player[i].targetheadrotation=player[i].lookrotation;
9125 player[i].targetheadrotation2=player[i].lookrotation2;
9128 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9129 Normalise(&rotatetarget);
9130 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9131 player[i].targetheadrotation*=360/6.28;
9132 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9134 player[i].targetheadrotation*=-1;
9135 player[i].targetheadrotation+=180;
9136 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9144 player[i].avoidsomething=0;
9146 for(j=0;j<objects.numobjects;j++){
9147 if(objects.onfire[j]){
9148 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9150 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9151 player[i].collided=0;
9152 player[i].avoidcollided=1;
9153 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9154 player[i].avoidwhere=objects.position[j];
9160 //Add avoidwhere to players
9162 for(j=0;j<numplayers;j++){
9163 if(player[j].onfire){
9164 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9166 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9167 player[i].collided=0;
9168 player[i].avoidcollided=1;
9169 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9170 player[i].avoidwhere=objects.position[j];
9176 if(player[i].collided>.8)player[i].avoidcollided=0;
9177 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9178 player[i].jumpclimb=0;
9180 if(editorenabled)player[i].stunned=1;
9183 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9184 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;
9186 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9187 player[i].forwardkeydown=0;
9188 player[i].leftkeydown=0;
9189 player[i].backkeydown=0;
9190 player[i].rightkeydown=0;
9191 player[i].crouchkeydown=0;
9192 player[i].attackkeydown=0;
9193 player[i].jumpkeydown=0;
9194 player[i].throwkeydown=0;
9197 if(player[i].aitype==pathfindtype){
9198 if(player[i].finalpathfindpoint==-1){
9199 float closestdistance;
9205 for(j=0;j<numpathpoints;j++){
9206 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9207 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9209 player[i].finaltarget=pathpoint[j];
9212 player[i].finalpathfindpoint=closest;
9213 for(j=0;j<numpathpoints;j++){
9214 if(numpathpointconnect[j])
9215 for(k=0;k<numpathpointconnect[j];k++){
9216 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9217 if(tempdist*tempdist<closestdistance){
9218 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9219 closestdistance=tempdist*tempdist;
9221 player[i].finaltarget=colpoint;
9226 player[i].finalpathfindpoint=closest;
9229 if(player[i].targetpathfindpoint==-1){
9230 float closestdistance;
9236 if(player[i].lastpathfindpoint==-1){
9237 for(j=0;j<numpathpoints;j++){
9238 if(j!=player[i].lastpathfindpoint)
9239 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9240 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9244 player[i].targetpathfindpoint=closest;
9245 for(j=0;j<numpathpoints;j++){
9246 if(j!=player[i].lastpathfindpoint)
9247 if(numpathpointconnect[j])
9248 for(k=0;k<numpathpointconnect[j];k++){
9249 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9250 if(tempdist*tempdist<closestdistance){
9251 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9252 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9253 closestdistance=tempdist*tempdist;
9260 player[i].targetpathfindpoint=closest;
9264 for(j=0;j<numpathpoints;j++){
9265 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9268 if(numpathpointconnect[j])
9269 for(k=0;k<numpathpointconnect[j];k++){
9270 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9273 if(numpathpointconnect[player[i].lastpathfindpoint])
9274 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9275 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9278 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9279 if(closest==-1||tempdist<closestdistance){
9280 closestdistance=tempdist;
9286 player[i].targetpathfindpoint=closest;
9289 player[i].losupdatedelay-=multiplier;
9291 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9292 Normalise(&rotatetarget);
9293 player[i].targetrotation=-asin(0-rotatetarget.x);
9294 player[i].targetrotation*=360/6.28;
9295 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9296 player[i].lookrotation=player[i].targetrotation;
9297 //player[i].aiupdatedelay=.05;
9299 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9300 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9301 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9302 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9303 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9304 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9305 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9306 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9307 player[i].targetpathfindpoint=-1;
9309 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){
9310 player[i].aitype=passivetype;
9313 player[i].forwardkeydown=1;
9314 player[i].leftkeydown=0;
9315 player[i].backkeydown=0;
9316 player[i].rightkeydown=0;
9317 player[i].crouchkeydown=0;
9318 player[i].attackkeydown=0;
9319 player[i].throwkeydown=0;
9321 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9323 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9324 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9326 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9327 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))
9328 player[i].aitype=attacktypecutoff;
9329 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9330 player[i].aitype=attacktypecutoff;
9332 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9333 player[i].losupdatedelay=.2;
9334 for(j=0;j<numplayers;j++){
9335 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9336 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9337 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9338 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9339 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9340 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)){
9341 player[i].aitype=searchtype;
9342 player[i].lastchecktime=12;
9343 player[i].lastseen=player[j].coords;
9344 player[i].lastseentime=12;
9350 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9351 if(player[i].creature!=wolftype){
9352 player[i].stunned=.6;
9353 player[i].surprised=.6;
9358 if(player[i].aitype!=passivetype&&leveltime>.5){
9359 player[i].howactive=typeactive;
9362 if(player[i].aitype==passivetype){
9363 player[i].aiupdatedelay-=multiplier;
9364 player[i].losupdatedelay-=multiplier;
9365 player[i].lastseentime+=multiplier;
9366 player[i].pausetime-=multiplier;
9367 if(player[i].lastseentime>1)player[i].lastseentime=1;
9369 if(player[i].aiupdatedelay<0){
9370 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9371 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9372 Normalise(&rotatetarget);
9373 player[i].targetrotation=-asin(0-rotatetarget.x);
9374 player[i].targetrotation*=360/6.28;
9375 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9376 player[i].lookrotation=player[i].targetrotation;
9377 player[i].aiupdatedelay=.05;
9379 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9380 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9381 player[i].waypoint++;
9382 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9387 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9388 else player[i].forwardkeydown=0;
9389 player[i].leftkeydown=0;
9390 player[i].backkeydown=0;
9391 player[i].rightkeydown=0;
9392 player[i].crouchkeydown=0;
9393 player[i].attackkeydown=0;
9394 player[i].throwkeydown=0;
9396 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9397 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9399 XYZ leftpos,rightpos;
9400 float leftdist,rightdist;
9401 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9402 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9403 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9404 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9405 if(leftdist<rightdist)player[i].targetrotation+=90;
9406 else player[i].targetrotation-=90;
9410 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9411 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9415 if(player[i].howactive<typesleeping)
9416 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9417 for(j=0;j<numenvsounds;j++){
9418 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9419 player[i].aitype=attacktypecutoff;
9423 if(player[i].howactive==typesleeping)
9424 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9425 for(j=0;j<numenvsounds;j++){
9426 if(envsoundvol[j]>14)
9427 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9428 player[i].aitype=attacktypecutoff;
9432 if(player[i].aitype!=passivetype){
9433 if(player[i].howactive==typesleeping){
9434 player[i].targetanimation=getupfromfrontanim;
9435 player[i].targetframe=0;
9439 player[i].howactive=typeactive;
9443 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9444 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9445 player[i].aitype=attacktypecutoff;
9446 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9447 player[i].aitype=attacktypecutoff;
9449 if(player[i].creature==wolftype){
9451 float smelldistance;
9453 for(j=0;j<numplayers;j++){
9454 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9455 if(j==0&&player[j].num_weapons>0){
9456 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9457 if(player[j].num_weapons==2)
9458 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9463 windsmell=windvector;
9464 Normalise(&windsmell);
9465 windsmell=windsmell*2+player[j].coords;
9466 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9467 player[i].aitype=attacktypecutoff;
9472 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9473 player[i].losupdatedelay=.2;
9474 for(j=0;j<numplayers;j++){
9475 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9476 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9477 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9478 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9479 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)){
9480 player[i].lastseentime-=.2;
9481 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9482 else player[i].lastseentime-=.6;
9484 if(player[i].lastseentime<=0){
9485 player[i].aitype=searchtype;
9486 player[i].lastchecktime=12;
9487 player[i].lastseen=player[j].coords;
9488 player[i].lastseentime=12;
9494 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9495 if(player[i].creature!=wolftype){
9496 player[i].stunned=.6;
9497 player[i].surprised=.6;
9499 if(player[i].creature==wolftype){
9500 player[i].stunned=.47;
9501 player[i].surprised=.47;
9507 if(player[i].aitype==searchtype){
9508 player[i].aiupdatedelay-=multiplier;
9509 player[i].losupdatedelay-=multiplier;
9510 if(!player[i].pause)player[i].lastseentime-=multiplier;
9511 player[i].lastchecktime-=multiplier;
9513 if(player[i].isRun()&&!player[i].onground){
9514 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9515 test2=player[i].coords+player[i].facing;
9517 test=player[i].coords+player[i].facing;
9519 j=checkcollide(test2,test,player[i].laststanding);
9520 if(j==-1)j=checkcollide(test2,test);
9522 player[i].velocity=0;
9523 player[i].targetanimation=player[i].getStop();
9524 player[i].targetframe=0;
9526 player[i].targetrotation+=180;
9527 player[i].stunned=.5;
9528 //player[i].aitype=passivetype;
9529 player[i].aitype=pathfindtype;
9530 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9531 player[i].finalpathfindpoint=-1;
9532 player[i].targetpathfindpoint=-1;
9533 player[i].lastpathfindpoint=-1;
9534 player[i].lastpathfindpoint2=-1;
9535 player[i].lastpathfindpoint3=-1;
9536 player[i].lastpathfindpoint4=-1;
9538 else player[i].laststanding=j;
9541 if(player[i].aiupdatedelay<0){
9542 rotatetarget=player[i].lastseen-player[i].coords;
9543 Normalise(&rotatetarget);
9544 player[i].targetrotation=-asin(0-rotatetarget.x);
9545 player[i].targetrotation*=360/6.28;
9546 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9547 player[i].lookrotation=player[i].targetrotation;
9548 player[i].aiupdatedelay=.05;
9549 player[i].forwardkeydown=1;
9551 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9552 player[i].forwardkeydown=0;
9553 player[i].aiupdatedelay=1;
9554 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9555 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9556 player[i].lastchecktime=3;
9559 player[i].leftkeydown=0;
9560 player[i].backkeydown=0;
9561 player[i].rightkeydown=0;
9562 player[i].crouchkeydown=0;
9563 player[i].attackkeydown=0;
9564 player[i].throwkeydown=0;
9566 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9567 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9569 XYZ leftpos,rightpos;
9570 float leftdist,rightdist;
9571 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9572 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9573 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9574 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9575 if(leftdist<rightdist)player[i].targetrotation+=90;
9576 else player[i].targetrotation-=90;
9580 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9581 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9583 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9584 for(j=0;j<numenvsounds;j++){
9585 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9586 player[i].aitype=attacktypecutoff;
9590 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9591 player[i].losupdatedelay=.2;
9592 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9593 {player[i].aitype=attacktypecutoff;
9594 player[i].lastseentime=1;}
9595 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9596 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9597 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9598 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)){
9599 player[i].aitype=attacktypecutoff;
9600 player[i].lastseentime=1;
9603 if(player[i].lastseentime<0){
9604 //player[i].aitype=passivetype;
9606 player[i].aitype=pathfindtype;
9607 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9608 player[i].finalpathfindpoint=-1;
9609 player[i].targetpathfindpoint=-1;
9610 player[i].lastpathfindpoint=-1;
9611 player[i].lastpathfindpoint2=-1;
9612 player[i].lastpathfindpoint3=-1;
9613 player[i].lastpathfindpoint4=-1;
9617 if(player[i].aitype!=gethelptype){
9618 player[i].runninghowlong=0;
9621 if(player[i].aitype==gethelptype){
9622 player[i].runninghowlong+=multiplier;
9623 player[i].aiupdatedelay-=multiplier;
9625 if(player[i].aiupdatedelay<0||player[i].ally==0){
9626 player[i].aiupdatedelay=.2;
9634 if(!player[i].ally){
9635 for(j=0;j<numplayers;j++){
9636 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9637 distance=findDistancefast(&player[i].coords,&player[j].coords);
9638 if(closestdist==-1||distance<closestdist){
9639 closestdist=distance;
9645 if(closest!=-1)player[i].ally=closest;
9646 else player[i].ally=0;
9647 player[i].lastseen=player[0].coords;
9648 player[i].lastseentime=12;
9652 player[i].lastchecktime=12;
9653 //player[i].lastseentime-=.5;
9655 facing=player[i].coords;
9656 flatfacing=player[player[i].ally].coords;
9657 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9658 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9659 if(-1!=checkcollide(facing,flatfacing))
9660 player[i].lastseentime-=.1;
9662 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9663 player[i].aitype=searchtype;
9664 player[i].lastseentime=12;
9667 if(player[i].ally>0){
9668 rotatetarget=player[player[i].ally].coords-player[i].coords;
9669 Normalise(&rotatetarget);
9670 player[i].targetrotation=-asin(0-rotatetarget.x);
9671 player[i].targetrotation*=360/6.28;
9672 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9673 player[i].lookrotation=player[i].targetrotation;
9674 player[i].aiupdatedelay=.05;
9675 player[i].forwardkeydown=1;
9677 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9678 player[i].aitype=searchtype;
9679 player[i].lastseentime=12;
9680 player[player[i].ally].aitype=searchtype;
9681 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9682 player[player[i].ally].lastseen=player[i].lastseen;
9683 player[player[i].ally].lastseentime=player[i].lastseentime;
9684 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9688 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9689 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9691 XYZ leftpos,rightpos;
9692 float leftdist,rightdist;
9693 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9694 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9695 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9696 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9697 if(leftdist<rightdist)player[i].targetrotation+=90;
9698 else player[i].targetrotation-=90;
9703 player[i].leftkeydown=0;
9704 player[i].backkeydown=0;
9705 player[i].rightkeydown=0;
9706 player[i].crouchkeydown=0;
9707 player[i].attackkeydown=0;
9709 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9710 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9713 if(player[i].aitype==getweapontype){
9714 player[i].aiupdatedelay-=multiplier;
9715 player[i].lastchecktime-=multiplier;
9717 if(player[i].aiupdatedelay<0){
9718 player[i].aiupdatedelay=.2;
9726 if(player[i].ally<0){
9727 for(j=0;j<weapons.numweapons;j++){
9728 if(weapons.owner[j]==-1){
9729 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9730 if(closestdist==-1||distance<closestdist){
9731 closestdist=distance;
9737 if(closest!=-1)player[i].ally=closest;
9738 else player[i].ally=-1;
9741 player[i].lastseentime=12;
9743 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9744 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9745 player[i].aitype=attacktypecutoff;
9746 player[i].lastseentime=1;
9749 if(player[i].ally>=0){
9750 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9751 player[i].aitype=attacktypecutoff;
9752 player[i].lastseentime=1;
9754 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9755 Normalise(&rotatetarget);
9756 player[i].targetrotation=-asin(0-rotatetarget.x);
9757 player[i].targetrotation*=360/6.28;
9758 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9759 player[i].lookrotation=player[i].targetrotation;
9760 player[i].aiupdatedelay=.05;
9761 player[i].forwardkeydown=1;
9764 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9765 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9767 XYZ leftpos,rightpos;
9768 float leftdist,rightdist;
9769 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9770 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9771 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9772 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9773 if(leftdist<rightdist)player[i].targetrotation+=90;
9774 else player[i].targetrotation-=90;
9777 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9778 if(abs(Random()%6)){
9779 player[i].crouchkeydown=1;
9780 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9781 if(player[i].isRun()){
9782 player[i].targetframe=0;
9784 player[i].targetanimation=sneakanim;
9787 else player[i].forwardkeydown=0;
9789 else player[i].crouchkeydown=0;
9791 else player[i].crouchkeydown=0;*/
9794 player[i].leftkeydown=0;
9795 player[i].backkeydown=0;
9796 player[i].rightkeydown=0;
9797 player[i].attackkeydown=0;
9798 player[i].throwkeydown=1;
9799 player[i].crouchkeydown=0;
9800 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9801 player[i].drawkeydown=0;
9803 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9804 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9807 if(player[i].aitype==attacktypecutoff){
9808 player[i].aiupdatedelay-=multiplier;
9809 if(player[i].damage<player[i].damagetolerance*2/3)
9810 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)){
9811 player[i].attackkeydown=0;
9812 if(player[i].isIdle())player[i].crouchkeydown=1;
9813 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9814 if(weapons.type[player[0].weaponids[0]]==knife){
9815 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9816 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9817 else player[i].targetanimation=rollanim;
9819 player[i].targetframe=0;
9820 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9821 player[i].wentforweapon=0;
9823 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9824 player[i].targetanimation=flipanim;
9826 player[i].targetframe=0;
9830 player[i].forwardkeydown=0;
9831 player[i].aiupdatedelay=.02;
9833 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9834 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9835 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9837 if(player[i].wentforweapon<3)
9838 for(j=0;j<weapons.numweapons;j++){
9839 if(player[i].creature!=wolftype)
9840 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){
9841 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9842 player[i].wentforweapon++;
9843 player[i].lastchecktime=6;
9844 player[i].aitype=getweapontype;
9849 if(player[i].damage<player[i].damagetolerance/2)
9850 if(animation[player[i].targetanimation].height!=highheight)
9851 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)))){
9852 player[i].crouchkeydown=1;
9854 if(player[i].isRun()&&!player[i].onground){
9855 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9856 test2=player[i].coords+player[i].facing;
9858 test=player[i].coords+player[i].facing;
9860 j=checkcollide(test2,test,player[i].laststanding);
9861 if(j==-1)j=checkcollide(test2,test);
9863 player[i].velocity=0;
9864 player[i].targetanimation=player[i].getStop();
9865 player[i].targetframe=0;
9867 player[i].targetrotation+=180;
9868 player[i].stunned=.5;
9869 //player[i].aitype=passivetype;
9870 player[i].aitype=pathfindtype;
9871 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9872 player[i].finalpathfindpoint=-1;
9873 player[i].targetpathfindpoint=-1;
9874 player[i].lastpathfindpoint=-1;
9875 player[i].lastpathfindpoint2=-1;
9876 player[i].lastpathfindpoint3=-1;
9877 player[i].lastpathfindpoint4=-1;
9879 else player[i].laststanding=j;
9882 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9883 player[i].aitype=pathfindtype;
9884 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9885 player[i].finalpathfindpoint=-1;
9886 player[i].targetpathfindpoint=-1;
9887 player[i].lastpathfindpoint=-1;
9888 player[i].lastpathfindpoint2=-1;
9889 player[i].lastpathfindpoint3=-1;
9890 player[i].lastpathfindpoint4=-1;
9892 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){
9893 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9894 else player[i].drawkeydown=0;
9895 player[i].rabbitkickenabled=Random()%2;
9896 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9897 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9898 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;
9899 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9900 Normalise(&rotatetarget);
9901 player[i].targetrotation=-asin(0-rotatetarget.x);
9902 player[i].targetrotation*=360/6.28;
9903 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9904 player[i].lookrotation=player[i].targetrotation;
9905 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9907 oldkey=player[i].forwardkeydown;
9908 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9909 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;
9910 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9911 else player[i].forwardkeydown=0;
9913 player[i].forwardkeydown=0;
9914 if(Random()%10==0)player[i].forwardkeydown=1;
9915 if(Random()%100==0){
9916 player[i].aitype=pathfindtype;
9917 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9918 player[i].finalpathfindpoint=-1;
9919 player[i].targetpathfindpoint=-1;
9920 player[i].lastpathfindpoint=-1;
9921 player[i].lastpathfindpoint2=-1;
9922 player[i].lastpathfindpoint3=-1;
9923 player[i].lastpathfindpoint4=-1;
9926 player[i].leftkeydown=0;
9927 player[i].backkeydown=0;
9928 player[i].rightkeydown=0;
9929 player[i].crouchkeydown=0;
9930 player[i].throwkeydown=0;
9932 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9933 /*for(j=0;j<numplayers;j++){
9934 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9935 player[i].crouchkeydown=1;
9938 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9939 else player[i].attackkeydown=0;
9940 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9941 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9942 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9943 player[i].attackkeydown=0;
9944 if(player[i].isIdle())player[i].crouchkeydown=1;
9945 player[i].forwardkeydown=0;
9946 player[i].aiupdatedelay=.02;
9949 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9951 for(j=0;j<numplayers;j++){
9952 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)){
9953 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))))){
9954 if(target>=0)target=-1;
9959 if(target>=0)player[target].Reverse();
9962 if(player[i].collided<1)player[i].jumpkeydown=0;
9963 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;
9964 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9965 player[0].jumpkeydown=0;
9966 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9967 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9968 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9970 if(tutoriallevel==1){
9971 if(!canattack)player[i].attackkeydown=0;
9975 facing=player[i].coords;
9976 flatfacing=player[0].coords;
9977 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9978 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9979 if(player[i].occluded>=2)
9980 if(-1!=checkcollide(facing,flatfacing)){
9981 if(!player[i].pause)player[i].lastseentime-=.2;
9982 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9983 player[i].aitype=searchtype;
9984 player[i].lastchecktime=12;
9985 player[i].lastseen=player[0].coords;
9986 player[i].lastseentime=12;
9989 else player[i].lastseentime=1;
9992 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9993 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9994 test=player[0].coords;
9996 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9999 // NOTE: Ask about logic of this call : NOTE
10000 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
10001 player[i].stunned>0 ||
10002 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
10004 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
10005 player[i].targetrotation=player[i].rotation;
10006 player[i].forwardkeydown=0;
10007 player[i].leftkeydown=0;
10008 player[i].backkeydown=0;
10009 player[i].rightkeydown=0;
10010 player[i].jumpkeydown=0;
10011 player[i].attackkeydown=0;
10012 player[i].crouchkeydown=0;
10013 player[i].throwkeydown=0;
10020 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
10023 if(player[i].aitype==attacktypecutoff){
10024 rotatetarget=player[0].coords-player[i].coords;
10025 Normalise(&rotatetarget);
10026 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10027 player[i].targetheadrotation*=360/6.28;
10028 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10030 player[i].targetheadrotation*=-1;
10031 player[i].targetheadrotation+=180;
10032 //player[i].targetheadrotation2=0;
10033 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10035 else if(player[i].howactive>=typesleeping){
10036 player[i].targetheadrotation=player[i].targetrotation;
10037 player[i].targetheadrotation2=0;
10040 if(player[i].interestdelay<=0){
10041 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
10042 player[i].headtarget=player[i].coords;
10043 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
10044 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
10045 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
10046 player[i].headtarget+=player[i].facing*1.5;
10048 rotatetarget=player[i].headtarget-player[i].coords;
10049 Normalise(&rotatetarget);
10050 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10051 player[i].targetheadrotation*=360/6.28;
10052 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10054 player[i].targetheadrotation*=-1;
10055 player[i].targetheadrotation+=180;
10056 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10058 //if(whichlevel==2)player[i].jumpkeydown=0;
10060 if(animation[player[i].targetanimation].attack==reversed){
10061 //player[i].targetrotation=player[i].rotation;
10062 player[i].forwardkeydown=0;
10063 player[i].leftkeydown=0;
10064 player[i].backkeydown=0;
10065 player[i].rightkeydown=0;
10066 player[i].jumpkeydown=0;
10067 player[i].attackkeydown=0;
10068 //player[i].crouchkeydown=0;
10069 player[i].throwkeydown=0;
10072 if(indialogue!=-1){
10073 player[i].forwardkeydown=0;
10074 player[i].leftkeydown=0;
10075 player[i].backkeydown=0;
10076 player[i].rightkeydown=0;
10077 player[i].jumpkeydown=0;
10078 player[i].crouchkeydown=0;
10079 player[i].drawkeydown=0;
10080 player[i].throwkeydown=0;
10083 if(player[i].collided<-.3)player[i].collided=-.3;
10084 if(player[i].collided>1)player[i].collided=1;
10085 player[i].collided-=multiplier*4;
10086 player[i].whichdirectiondelay-=multiplier;
10087 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
10088 player[i].avoidcollided=-.3;
10089 player[i].whichdirection=abs(Random()%2);
10090 player[i].whichdirectiondelay=.4;
10092 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10093 player[i].avoidcollided-=multiplier/4;
10094 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10095 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10096 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;
10098 if(!player[i].throwkeydown){
10099 player[i].throwtogglekeydown=0;
10101 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10102 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)){
10103 for(j=0;j<weapons.numweapons;j++){
10104 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)
10105 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10106 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10107 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10108 player[i].throwtogglekeydown=1;
10109 player[i].targetanimation=crouchremoveknifeanim;
10110 player[i].target=0;
10111 player[i].targetframe=0;
10112 rotatetarget=weapons.position[j]-player[i].coords;
10113 Normalise(&rotatetarget);
10114 player[i].targetrotation=-asin(0-rotatetarget.x);
10115 player[i].targetrotation*=360/6.28;
10116 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10117 player[i].hasvictim=0;
10119 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10120 player[i].throwtogglekeydown=1;
10121 player[i].hasvictim=0;
10123 //for(i=0;i<weapons.numweapons;i++){
10124 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))
10125 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10126 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10129 gLoc[0]=player[i].coords.x;
10130 gLoc[1]=player[i].coords.y;
10131 gLoc[2]=player[i].coords.z;
10132 vel[0]=player[i].velocity.x;
10133 vel[1]=player[i].velocity.y;
10134 vel[2]=player[i].velocity.z;
10135 if(weapons.type[j]!=staff){
10136 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10137 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10138 FSOUND_SetVolume(channels[knifedrawsound], 128);
10139 FSOUND_SetPaused(channels[knifedrawsound], false);
10142 player[i].weaponactive=0;
10143 weapons.owner[j]=player[i].id;
10144 if(player[i].num_weapons>0){
10145 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10147 player[i].num_weapons++;
10148 player[i].weaponids[0]=j;
10154 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){
10155 if(!player[i].isFlip()){
10156 player[i].throwtogglekeydown=1;
10157 player[i].targetanimation=removeknifeanim;
10158 player[i].target=0;
10159 player[i].targetframe=0;
10160 rotatetarget=weapons.position[j]-player[i].coords;
10161 Normalise(&rotatetarget);
10162 player[i].targetrotation=-asin(0-rotatetarget.x);
10163 player[i].targetrotation*=360/6.28;
10164 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10166 if(player[i].isFlip()){
10167 player[i].throwtogglekeydown=1;
10168 player[i].hasvictim=0;
10170 for(k=0;k<weapons.numweapons;k++){
10171 if(player[i].weaponactive==-1)
10172 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))
10173 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10176 gLoc[0]=player[i].coords.x;
10177 gLoc[1]=player[i].coords.y;
10178 gLoc[2]=player[i].coords.z;
10179 vel[0]=player[i].velocity.x;
10180 vel[1]=player[i].velocity.y;
10181 vel[2]=player[i].velocity.z;
10182 if(weapons.type[k]!=staff){
10183 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10184 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10185 FSOUND_SetVolume(channels[knifedrawsound], 128);
10186 FSOUND_SetPaused(channels[knifedrawsound], false);
10189 player[i].weaponactive=0;
10190 weapons.owner[k]=player[i].id;
10191 if(player[i].num_weapons>0){
10192 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10194 player[i].num_weapons++;
10195 player[i].weaponids[0]=k;
10202 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10204 for(j=0;j<numplayers;j++){
10205 if(player[i].weaponactive==-1)
10207 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)){
10208 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10209 player[i].throwtogglekeydown=1;
10210 player[i].victim=&player[j];
10211 player[i].hasvictim=1;
10212 player[i].targetanimation=crouchremoveknifeanim;
10213 player[i].target=0;
10214 player[i].targetframe=0;
10215 rotatetarget=player[j].coords-player[i].coords;
10216 Normalise(&rotatetarget);
10217 player[i].targetrotation=-asin(0-rotatetarget.x);
10218 player[i].targetrotation*=360/6.28;
10219 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10221 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10222 player[i].throwtogglekeydown=1;
10223 player[i].victim=&player[j];
10224 player[i].hasvictim=1;
10225 int k = player[j].weaponids[0];
10226 if(player[i].hasvictim){
10229 gLoc[0]=player[i].coords.x;
10230 gLoc[1]=player[i].coords.y;
10231 gLoc[2]=player[i].coords.z;
10232 vel[0]=player[i].velocity.x;
10233 vel[1]=player[i].velocity.y;
10234 vel[2]=player[i].velocity.z;
10237 if(player[i].victim->weaponstuck!=-1){
10238 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10243 if(weapons.type[k]!=staff){
10244 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10245 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10246 FSOUND_SetVolume(channels[knifedrawsound], 128);
10247 FSOUND_SetPaused(channels[knifedrawsound], false);
10251 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
10252 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10253 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
10254 FSOUND_SetPaused(channels[fleshstabremovesound], false);
10257 player[i].weaponactive=0;
10258 if(weapons.owner[k]!=-1){
10259 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10260 else player[i].victim->num_weapons=1;
10262 player[i].victim->skeleton.longdead=0;
10263 player[i].victim->skeleton.free=1;
10264 player[i].victim->skeleton.broken=0;
10266 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10267 player[i].victim->skeleton.joints[l].velchange=0;
10268 player[i].victim->skeleton.joints[l].locked=0;
10274 Normalise(&relative);
10275 XYZ footvel,footpoint;
10277 footpoint=weapons.position[k];
10278 if(player[i].victim->weaponstuck!=-1){
10279 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10280 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10281 weapons.bloody[k]=2;
10282 weapons.blooddrip[k]=5;
10283 player[i].victim->weaponstuck=-1;
10284 player[i].victim->bloodloss+=2000;
10285 player[i].victim->DoDamage(2000);
10288 if(player[i].victim->num_weapons>0){
10289 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10290 if(player[i].victim->weaponids[0]==k)
10291 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10294 player[i].victim->weaponactive=-1;
10296 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10297 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10298 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10299 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10301 weapons.owner[k]=i;
10302 if(player[i].num_weapons>0){
10303 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10305 player[i].num_weapons++;
10306 player[i].weaponids[0]=k;
10313 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10314 if(weapons.type[player[i].weaponids[0]]==knife){
10315 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10317 for(j=0;j<numplayers;j++){
10319 if(tutoriallevel!=1||tutorialstage==49)
10321 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)){
10322 if(!player[i].isFlip()){
10323 player[i].throwtogglekeydown=1;
10324 player[i].victim=&player[j];
10325 player[i].targetanimation=knifethrowanim;
10326 player[i].target=0;
10327 player[i].targetframe=0;
10328 rotatetarget=player[j].coords-player[i].coords;
10329 Normalise(&rotatetarget);
10330 player[i].targetrotation=-asin(0-rotatetarget.x);
10331 player[i].targetrotation*=360/6.28;
10332 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10334 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10336 if(player[i].isFlip()){
10337 if(player[i].weaponactive!=-1){
10338 player[i].throwtogglekeydown=1;
10339 player[i].victim=&player[j];
10341 weapons.owner[player[i].weaponids[0]]=-1;
10342 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);
10345 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10347 weapons.velocity[player[i].weaponids[0]]=aim*50;
10348 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10349 weapons.missed[player[i].weaponids[0]]=0;
10350 weapons.freetime[player[i].weaponids[0]]=0;
10351 weapons.firstfree[player[i].weaponids[0]]=1;
10352 weapons.physics[player[i].weaponids[0]]=0;
10353 player[i].num_weapons--;
10354 if(player[i].num_weapons){
10355 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10357 player[i].weaponactive=-1;
10364 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10365 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10367 player[i].throwtogglekeydown=1;
10368 weapons.owner[player[i].weaponids[0]]=-1;
10369 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10370 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10371 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10372 weapons.missed[player[i].weaponids[0]]=1;
10373 weapons.freetime[player[i].weaponids[0]]=0;
10374 weapons.firstfree[player[i].weaponids[0]]=1;
10375 weapons.physics[player[i].weaponids[0]]=1;
10376 player[i].num_weapons--;
10377 if(player[i].num_weapons){
10378 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10379 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10382 player[i].weaponactive=-1;
10383 for(j=0;j<numplayers;j++){
10384 player[j].wentforweapon=0;
10391 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10392 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)){
10393 //Setenvironment(1-environment);
10396 if(player[i].weaponactive!=-1){
10397 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10399 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10400 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10401 player[i].targetanimation=drawrightanim;
10402 player[i].targetframe=0;
10403 player[i].target=0;
10404 player[i].drawtogglekeydown=1;
10406 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){
10407 player[i].targetanimation=drawleftanim;
10408 player[i].targetframe=0;
10409 player[i].target=0;
10410 player[i].drawtogglekeydown=1;
10412 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10413 player[i].targetanimation=crouchdrawrightanim;
10414 player[i].targetframe=0;
10415 player[i].target=0;
10416 player[i].drawtogglekeydown=1;
10420 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){
10421 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10422 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10423 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10424 player[i].targetframe=0;
10425 player[i].target=0;
10426 player[i].hasvictim=0;
10427 //player[i].attacktogglekeydown=1;
10431 if(!player[i].drawkeydown){
10432 player[i].drawtogglekeydown=0;
10437 absflatfacing.z=-1;
10439 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10441 else absflatfacing=flatfacing;
10443 if(indialogue!=-1){
10444 player[i].forwardkeydown=0;
10445 player[i].leftkeydown=0;
10446 player[i].backkeydown=0;
10447 player[i].rightkeydown=0;
10448 player[i].jumpkeydown=0;
10449 player[i].crouchkeydown=0;
10450 player[i].drawkeydown=0;
10451 player[i].throwkeydown=0;
10455 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10456 if(!player[i].forwardkeydown){
10457 player[i].forwardstogglekeydown=0;
10459 if(player[i].crouchkeydown){
10463 player[i].superruntoggle=1;
10465 for(j=0;j<numplayers;j++){
10466 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10467 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10468 player[i].superruntoggle=0;
10475 for(j=0;j<numplayers;j++){
10476 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10477 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))){
10478 if(target>=0)target=-1;
10483 if(target>=0)player[target].Reverse();
10484 player[i].lowreversaldelay=.5;
10486 if(player[i].isIdle()){
10487 player[i].targetanimation=player[i].getCrouch();
10488 player[i].target=0;
10489 player[i].targetframe=0;
10490 player[i].transspeed=10;
10492 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10493 player[i].targetanimation=rollanim;
10494 player[i].target=0;
10495 player[i].targetframe=0;
10496 player[i].transspeed=20;
10499 if(!player[i].crouchkeydown){
10501 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10503 if(player[i].isCrouch()){
10505 for(j=0;j<numplayers;j++){
10506 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10507 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10508 if(target>=0)target=-1;
10513 if(target>=0)player[target].Reverse();
10514 player[i].highreversaldelay=.5;
10516 if(player[i].isCrouch()){
10517 if(!player[i].wasCrouch()){
10518 player[i].currentanimation=player[i].getCrouch();
10519 player[i].currentframe=0;
10521 player[i].target=0;
10522 player[i].targetanimation=player[i].getIdle();
10523 player[i].targetframe=0;
10524 player[i].transspeed=10;
10527 if(player[i].targetanimation==sneakanim){
10528 player[i].targetanimation=player[i].getIdle();
10529 player[i].target=0;
10530 player[i].targetframe=0;
10531 player[i].transspeed=10;
10534 if(player[i].forwardkeydown){
10535 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)){
10536 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10537 else player[i].targetanimation=player[i].getRun();
10538 player[i].target=0;
10539 player[i].targetframe=0;
10541 if(player[i].isCrouch()){
10542 player[i].targetanimation=sneakanim;
10543 if(player[i].wasCrouch())player[i].target=0;
10544 player[i].targetframe=0;
10546 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10547 player[i].targetanimation=climbanim;
10548 player[i].target=0;
10549 player[i].targetframe=1;
10550 player[i].jumpclimb=1;
10552 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10553 player[i].velocity+=absflatfacing*5*multiplier;
10555 player[i].forwardstogglekeydown=1;
10558 if (player[i].rightkeydown){
10559 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)){
10560 player[i].targetanimation=player[i].getRun();
10561 player[i].target=0;
10562 player[i].targetframe=0;
10564 if(player[i].isCrouch()){
10565 player[i].targetanimation=sneakanim;
10566 if(player[i].wasCrouch()) player[i].target=0;
10567 player[i].targetframe=0;
10569 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10570 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10572 player[i].targetrotation-=90;
10573 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10574 if(player[i].backkeydown)player[i].targetrotation-=45;
10577 if ( player[i].leftkeydown){
10578 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)){
10579 player[i].targetanimation=player[i].getRun();
10580 player[i].target=0;
10581 player[i].targetframe=0;
10583 if(player[i].isCrouch()){
10584 player[i].targetanimation=sneakanim;
10585 if(player[i].wasCrouch())player[i].target=0;
10586 player[i].targetframe=0;
10588 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10589 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10591 player[i].targetrotation+=90;
10592 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10593 if(player[i].backkeydown)player[i].targetrotation+=45;
10596 if(player[i].backkeydown){
10597 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)){
10598 player[i].targetanimation=player[i].getRun();
10599 player[i].target=0;
10600 player[i].targetframe=0;
10602 if(player[i].isCrouch()){
10603 player[i].targetanimation=sneakanim;
10604 if(player[i].wasCrouch())player[i].target=0;
10605 player[i].targetframe=0;
10607 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10608 player[i].velocity-=absflatfacing*5*multiplier;
10610 if(player[i].targetanimation==hanganim){
10611 player[i].currentanimation=jumpdownanim;
10612 player[i].targetanimation=jumpdownanim;
10613 player[i].target=0;
10614 player[i].currentframe=0;
10615 player[i].targetframe=1;
10616 player[i].velocity=0;
10617 player[i].velocity.y+=gravity;
10618 player[i].coords.y-=1.4;
10619 player[i].grabdelay=1;
10621 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10622 player[i].targetrotation+=180;
10625 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10626 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)){
10627 player[i].jumpstart=0;
10628 player[i].targetanimation=jumpupanim;
10629 player[i].target=0;
10630 player[i].targetframe=0;
10631 player[i].rotation=player[i].targetrotation;
10632 player[i].transspeed=20;
10633 player[i].FootLand(0,1);
10634 player[i].FootLand(1,1);
10638 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10640 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10641 if(!movekey)player[i].velocity=0;
10646 for(j=0;j<numplayers;j++){
10647 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10648 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10649 if(target>=0)target=-1;
10654 if(target>=0)player[i].velocity.y=1;
10655 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10656 player[i].velocity.y=7;
10657 player[i].crouchtogglekeydown=1;
10659 else player[i].velocity.y=5;
10661 if(mousejump&&i==0&&debugmode){
10662 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10663 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10666 player[i].coords.y+=.2;
10667 player[i].jumppower-=1;
10669 static float gLoc[3];
10670 static float vel[3];
10671 gLoc[0]=player[i].coords.x;
10672 gLoc[1]=player[i].coords.y;
10673 gLoc[2]=player[i].coords.z;
10674 vel[0]=player[i].velocity.x;
10675 vel[1]=player[i].velocity.y;
10676 vel[2]=player[i].velocity.z;
10679 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10680 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10681 FSOUND_SetVolume(channels[whooshsound], 128);
10682 FSOUND_SetPaused(channels[whooshsound], false);
10685 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10686 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10687 FSOUND_SetVolume(channels[jumpsound], 128);
10688 FSOUND_SetPaused(channels[jumpsound], false);
10690 if((player[i].isIdle())&&player[i].jumppower>1){
10691 player[i].targetanimation=player[i].getLanding();
10692 player[i].landhard=0;
10693 player[i].target=0;
10694 player[i].targetframe=2;
10695 player[i].jumpstart=1;
10696 player[i].tempdeltav=deltav;
10698 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10699 if(player[i].jumppower>multiplier*6){
10700 player[i].velocity.y+=multiplier*6;
10701 player[i].jumppower-=multiplier*6;
10703 if(player[i].jumppower<=multiplier*6){
10704 player[i].velocity.y+=player[i].jumppower;
10705 player[i].jumppower=0;
10708 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10712 if(player[i].isRun()||player[i].targetanimation==walkanim){
10713 player[i].targetanimation=player[i].getStop();
10714 player[i].target=0;
10715 player[i].targetframe=0;
10717 if(player[i].targetanimation==sneakanim){
10718 player[i].targetanimation=player[i].getCrouch();
10719 if(player[i].currentanimation==sneakanim)player[i].target=0;
10720 player[i].targetframe=0;
10723 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10724 player[i].targetanimation=player[i].getStop();
10725 player[i].target=0;
10726 player[i].targetframe=0;
10728 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10729 player[i].targetanimation=player[i].getStop();
10730 player[i].target=0;
10731 player[i].targetframe=0;
10735 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10739 for(k=0;k<numplayers;k++){
10740 if(abs(player[k].rotation-player[k].targetrotation)>180){
10741 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10742 else player[k].rotation+=360;
10745 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10746 player[k].targetanimation=player[k].getStop();
10747 player[k].targetframe=0;
10748 player[k].target=0;
10751 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10752 player[k].targettilt=0;
10754 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10755 player[k].targettilt=0;
10756 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10757 player[k].jumppower+=multiplier*7;
10758 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10759 //*(1-(player[k].damage/player[k].damagetolerance))
10760 if(player[k].jumppower>5)player[k].jumppower=5;
10763 if(player[k].isRun()){
10764 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10767 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10768 else if(player[k].tilt>player[k].targettilt){
10769 player[k].tilt-=multiplier*150;
10771 else if(player[k].tilt<player[k].targettilt){
10772 player[k].tilt+=multiplier*150;
10775 player[k].grabdelay-=multiplier;
10778 for(k=0;k<numplayers;k++){
10779 player[k].DoAnimations();
10780 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10781 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10786 player[0].righthandmorphstart=0;
10787 player[0].righthandmorphend=1;
10788 player[0].lefthandmorphstart=0;
10789 player[0].lefthandmorphend=1;
10790 player[0].headmorphstart=0;
10791 player[0].headmorphend=2;*/
10794 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10795 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10796 player[0].righthandmorphend=1;
10797 player[0].targetrighthandmorphness=1;
10799 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10800 player[0].lefthandmorphend=0;
10801 player[0].targetlefthandmorphness=1;
10803 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10804 player[0].headmorphend=2;
10805 player[0].targetheadmorphness=1;
10807 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10808 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10809 player[0].righthandmorphend=0;
10810 player[0].targetrighthandmorphness=1;
10812 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10813 player[0].lefthandmorphend=1;
10814 player[0].targetlefthandmorphness=1;
10816 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10817 player[0].headmorphend=0;
10818 player[0].targetheadmorphness=1;
10821 if(numenvsounds!=0)
10822 for(j=numenvsounds-1;j>=0;j--){
10823 envsoundlife[j]-=multiplier;
10824 if(envsoundlife[j]<0){
10826 envsoundlife[j]=envsoundlife[numenvsounds];
10827 envsound[j]=envsound[numenvsounds];
10830 if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
10831 if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
10833 if(tutoriallevel==1){
10850 if(tutorialstage>=51)
10851 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10852 FSOUND_StopSound(FSOUND_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10853 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10855 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10856 FSOUND_SetPaused(channels[stream_music3], false);
10857 FSOUND_SetVolume(channels[stream_music3], 256);
10862 float gLoc[3]={0,0,0};
10863 float vel[3]={0,0,0};
10864 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10865 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10866 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10867 FSOUND_SetVolume(channels[fireendsound], 256);
10868 FSOUND_SetPaused(channels[fireendsound], false);
10869 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10877 if(tutorialstage<51)
10878 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10881 gLoc[0]=player[0].coords.x;
10882 gLoc[1]=player[0].coords.y;
10883 gLoc[2]=player[0].coords.z;
10887 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10888 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10889 FSOUND_SetVolume(channels[fireendsound], 256);
10890 FSOUND_SetPaused(channels[fireendsound], false);
10892 player[0].coords=(oldtemp+oldtemp2)/2;
10900 if(tutorialstage>=14&&tutorialstage<50)
10901 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10904 gLoc[0]=player[1].coords.x;
10905 gLoc[1]=player[1].coords.y;
10906 gLoc[2]=player[1].coords.z;
10910 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10911 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10912 FSOUND_SetVolume(channels[fireendsound], 256);
10913 FSOUND_SetPaused(channels[fireendsound], false);
10915 for(int i=0;i<player[1].skeleton.num_joints;i++){
10917 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10918 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10919 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;
10920 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10921 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10925 player[1].coords=(oldtemp+oldtemp2)/2;
10926 for(int i=0;i<player[1].skeleton.num_joints;i++){
10927 player[1].skeleton.joints[i].velocity=0;
10929 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10930 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10931 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;
10932 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10933 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10941 static float gLoc[3];
10945 static float vel[3];
10946 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10947 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10948 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10950 //Set orientation with forward and up vectors
10951 static XYZ upvector;
10955 upvector=DoRotation(upvector,-rotation2+90,0,0);
10956 upvector=DoRotation(upvector,0,0-rotation,0);
10961 facing=DoRotation(facing,-rotation2,0,0);
10962 facing=DoRotation(facing,0,0-rotation,0);
10965 static float ori[6];
10966 ori[0] = -facing.x;
10968 ori[2] = -facing.z;
10969 ori[3] = -upvector.x;
10970 ori[4] = upvector.y;
10971 ori[5] = -upvector.z;
10973 FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10980 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10982 freezetogglekeydown=1;
10986 void Game::TickOnce(){
10989 if(directing||indialogue==-1){
10990 rotation+=deltah*.7;
10991 if(!invertmouse)rotation2+=deltav*.7;
10992 if(invertmouse)rotation2-=deltav*.7;
10993 if(rotation2>90)rotation2=90;
10994 if(rotation2<-70)rotation2=-70;
10996 if(mainmenu)rotation+=multiplier*5;
10997 if(!mainmenu&&!indemo&&!registered){
10998 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10999 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11000 FSOUND_SetPaused(channels[stream_music3], false);
11001 FSOUND_SetVolume(channels[stream_music3], 256);
11006 float gLoc[3]={0,0,0};
11007 float vel[3]={0,0,0};
11008 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11009 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11010 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11011 FSOUND_SetVolume(channels[fireendsound], 256);
11012 FSOUND_SetPaused(channels[fireendsound], false);
11013 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11022 if(tryquit==1&&!registered&&mainmenu!=12){
11023 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11024 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11025 FSOUND_SetPaused(channels[stream_music3], false);
11026 FSOUND_SetVolume(channels[stream_music3], 256);
11031 float gLoc[3]={0,0,0};
11032 float vel[3]={0,0,0};
11033 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11034 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11035 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11036 FSOUND_SetVolume(channels[fireendsound], 256);
11037 FSOUND_SetPaused(channels[fireendsound], false);
11038 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11049 void Game::TickOnceAfter(){
11050 static XYZ colviewer;
11051 static XYZ coltarget;
11054 static float brotate;
11057 static float changedelay;
11058 static bool alldead;
11059 static float unseendelay;
11060 static float cameraspeed;
11064 if(environment==snowyenvironment)music1=stream_music1snow;
11065 if(environment==grassyenvironment)music1=stream_music1grass;
11066 if(environment==desertenvironment)music1=stream_music1desert;
11071 for(i=0;i<numplayers;i++){
11072 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)){
11073 musictype=stream_music2;
11077 if(player[0].dead)musictype=stream_music3;
11080 if(musictype==stream_music2){
11084 if(oldmusictype==stream_music2&&musictype!=stream_music2){
11085 unseendelay-=multiplier;
11087 musictype=stream_music2;
11093 musictype=stream_music3;
11094 musicvolume[2]=512;
11101 if(musictype!=oldmusictype&&musictype==stream_music2){
11102 static float gLoc[3];
11103 static float vel[3];
11104 gLoc[0]=cameraloc.x;
11105 gLoc[1]=cameraloc.y;
11106 gLoc[2]=cameraloc.z;
11110 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
11111 FSOUND_SetVolume(channels[alarmsound], 512);
11112 FSOUND_SetPaused(channels[alarmsound], false);
11116 musicselected=musictype;
11118 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11119 else musicvolume[0]-=multiplier*450;
11120 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11121 else musicvolume[1]-=multiplier*450;
11122 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11123 else musicvolume[2]-=multiplier*450;
11125 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11126 else musicvolume[0]-=multiplier*450;
11127 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11128 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11129 else musicvolume[1]-=multiplier*100;
11130 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11131 else musicvolume[2]-=multiplier*450;*/
11134 if(musicvolume[i]<0)musicvolume[i]=0;
11135 if(musicvolume[i]>512)musicvolume[i]=512;
11138 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11141 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11142 PlayStreamEx( music1, strm[music1], NULL, true);
11143 FSOUND_SetPaused(channels[music1], false);
11145 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11146 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
11147 FSOUND_SetPaused(channels[stream_music2], false);
11149 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11150 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11151 FSOUND_SetPaused(channels[stream_music3], false);
11156 FSOUND_SetPaused(channels[music1], true);
11157 FSOUND_SetPaused(channels[stream_music2], true);
11158 FSOUND_SetPaused(channels[stream_music3], true);
11161 oldmusicvolume[i]=0;
11167 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11168 FSOUND_SetPaused(channels[music1], true);
11170 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11171 FSOUND_SetPaused(channels[stream_music2], true);
11173 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11174 FSOUND_SetPaused(channels[stream_music3], true);
11177 if(musicvolume[0]!=oldmusicvolume[0]){
11178 FSOUND_SetVolume(channels[music1], musicvolume[0]);
11180 if(musicvolume[1]!=oldmusicvolume[1]){
11181 FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
11183 if(musicvolume[2]!=oldmusicvolume[2]){
11184 FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
11188 oldmusicvolume[i]=musicvolume[i];
11194 for(i=0;i<numhotspots;i++){
11195 if(hotspottype[i]>10&&hotspottype[i]<20){
11196 if(player[hotspottype[i]-10].dead==0){
11199 else if(killhotspot==2)
11203 if(killhotspot==2)killhotspot=0;
11208 for(i=0;i<numhotspots;i++){
11209 if(hotspottype[i]==-1){
11210 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11217 for(i=1;i<numplayers;i++){
11218 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11220 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11222 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11223 if(player[0].dead&&changedelay<=0){
11225 targetlevel=whichlevel;
11229 for(i=1;i<numplayers;i++){
11230 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11234 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11236 targetlevel=whichlevel+1;
11237 if(targetlevel>numchallengelevels-1)targetlevel=0;
11239 if(winhotspot||windialogue){
11241 targetlevel=whichlevel+1;
11242 if(targetlevel>numchallengelevels-1)targetlevel=0;
11248 targetlevel=whichlevel+1;
11249 if(targetlevel>numchallengelevels-1)targetlevel=0;
11252 if(changedelay>0&&!player[0].dead&&!won){
11253 //high scores, awards, win
11256 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11257 accountcampaignchoicesmade[accountactive]++;
11258 accountcampaignscore[accountactive]+=bonustotal;
11260 accountcampaigntime[accountactive]+=leveltime;
11261 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11263 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11269 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11270 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11272 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11288 if(!editorenabled&&gameon&&!mainmenu){
11289 if(changedelay!=-999)changedelay-=multiplier/7;
11290 if(player[0].dead)targetlevel=whichlevel;
11291 if(loading==2&&!campaign){
11299 float gLoc[3]={0,0,0};
11300 float vel[3]={0,0,0};
11301 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11302 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11303 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11304 FSOUND_SetVolume(channels[firestartsound], 256);
11305 FSOUND_SetPaused(channels[firestartsound], false);
11306 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11308 if(!player[0].dead&&targetlevel!=whichlevel){
11309 startbonustotal=bonustotal;
11311 if(!player[0].dead)Loadlevel(targetlevel);
11312 if(player[0].dead)Loadlevel(whichlevel);
11314 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11315 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11316 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11317 FSOUND_SetVolume(channels[fireendsound], 256);
11318 FSOUND_SetPaused(channels[fireendsound], false);
11319 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11323 if(loading==2&&targetlevel==whichlevel){
11331 float gLoc[3]={0,0,0};
11332 float vel[3]={0,0,0};
11333 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11334 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11335 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11336 FSOUND_SetVolume(channels[firestartsound], 256);
11337 FSOUND_SetPaused(channels[firestartsound], false);
11338 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11340 for(i=0;i<255;i++){
11354 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11355 Loadlevel(mapname);
11357 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11358 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11359 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11360 FSOUND_SetVolume(channels[fireendsound], 256);
11361 FSOUND_SetPaused(channels[fireendsound], false);
11362 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11366 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11367 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11368 if(accountprogress[accountactive]>3&&!registered){
11369 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11370 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11371 FSOUND_SetPaused(channels[stream_music3], false);
11372 FSOUND_SetVolume(channels[stream_music3], 256);
11376 accountprogress[accountactive]=3;
11378 float gLoc[3]={0,0,0};
11379 float vel[3]={0,0,0};
11380 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11381 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11382 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11383 FSOUND_SetVolume(channels[fireendsound], 256);
11384 FSOUND_SetPaused(channels[fireendsound], false);
11385 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11394 if(whichlevel!=-2&&!loading&&!player[0].dead){
11398 if(player[0].dead)loading=1;
11404 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11405 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11409 else if(mainmenu==0&&winfreeze){
11410 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11412 else stealthloading=0;
11414 if(!stealthloading){
11415 float gLoc[3]={0,0,0};
11416 float vel[3]={0,0,0};
11417 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11418 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11419 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11420 FSOUND_SetVolume(channels[firestartsound], 256);
11421 FSOUND_SetPaused(channels[firestartsound], false);
11422 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11433 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11434 //campaignnumlevels=0;
11435 //accountcampaignchoicesmade[accountactive]=0;
11436 ipstream.ignore(256,':');
11437 ipstream >> campaignnumlevels;
11438 for(i=0;i<campaignnumlevels;i++){
11439 ipstream.ignore(256,':');
11440 ipstream.ignore(256,':');
11441 ipstream.ignore(256,' ');
11442 ipstream >> campaignmapname[i];
11443 ipstream.ignore(256,':');
11444 ipstream >> campaigndescription[i];
11445 for(j=0;j<256;j++){
11446 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11448 ipstream.ignore(256,':');
11449 ipstream >> campaignchoosenext[i];
11450 ipstream.ignore(256,':');
11451 ipstream >> campaignnumnext[i];
11452 if(campaignnumnext[i])
11453 for(j=0;j<campaignnumnext[i];j++){
11454 ipstream.ignore(256,':');
11455 ipstream >> campaignnextlevel[i][j];
11456 campaignnextlevel[i][j]-=1;
11458 ipstream.ignore(256,':');
11459 ipstream >> campaignlocationx[i];
11460 ipstream.ignore(256,':');
11461 ipstream >> campaignlocationy[i];
11465 for(i=0;i<campaignnumlevels;i++){
11467 levelhighlight[i]=0;
11471 for(i=0;i<campaignnumlevels;i++){
11473 levelhighlight[i]=0;
11478 if(accountcampaignchoicesmade[accountactive])
11479 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11480 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11481 levelvisible[levelorder[i+1]]=1;
11483 int whichlevelstart;
11484 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11485 if(whichlevelstart<0){
11486 campaignchoicenum=1;
11487 campaignchoicewhich[0]=0;
11491 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11492 if(campaignchoicenum)
11493 for(i=0;i<campaignchoicenum;i++){
11494 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11495 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11496 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11503 //if(firstload)TickOnceAfter();
11504 if(!firstload)LoadStuff();
11506 for(i=0;i<255;i++){
11521 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11522 //accountcampaignchoicesmade[accountactive]++;
11525 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11529 Loadlevel(mapname);
11533 FSOUND_SetPaused(channels[stream_music3], true);
11538 if(loading==3)loading=0;
11542 oldmusictype=musictype;
11548 facing=DoRotation(facing,-rotation2,0,0);
11549 facing=DoRotation(facing,0,0-rotation,0);
11550 viewerfacing=facing;
11554 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;
11555 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;
11557 if(player[0].skeleton.free){
11558 for(i=0;i<player[0].skeleton.num_joints;i++){
11559 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11560 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11564 if(player[0].skeleton.free!=2&&!autocam){
11566 if(findLengthfast(&player[0].velocity)>400){
11567 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11569 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11570 coltarget=target-cameraloc;
11571 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11573 Normalise(&coltarget);
11574 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11575 else cameraloc=cameraloc+coltarget*multiplier*8;
11577 if(editorenabled)cameraloc=target;
11578 cameradist+=multiplier*5;
11579 if(cameradist>2.3)cameradist=2.3;
11580 viewer=cameraloc-facing*cameradist;
11582 coltarget=cameraloc;
11583 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11584 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11585 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11586 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11588 coltarget=cameraloc;
11589 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11591 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11592 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11593 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11595 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11599 cameradist=findDistance(&viewer,&target);
11600 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11601 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11603 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11604 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11607 if(player[0].skeleton.free!=2&&autocam){
11609 if(findLengthfast(&player[0].velocity)>400){
11610 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11612 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11613 cameradist+=multiplier*5;
11614 if(cameradist>3.3)cameradist=3.3;
11615 coltarget=target-cameraloc;
11616 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11617 else if(findLengthfast(&coltarget)>1)
11619 Normalise(&coltarget);
11620 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11621 else cameraloc=cameraloc+coltarget*multiplier*8;
11623 if(editorenabled)cameraloc=target;
11626 coltarget=cameraloc;
11627 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11628 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11629 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11630 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11632 coltarget=cameraloc;
11633 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11635 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11636 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11637 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11639 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11643 cameradist=findDistance(&viewer,&target);
11644 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11645 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11647 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11648 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11651 if(camerashake>.8)camerashake=.8;
11652 //if(woozy>10)woozy=10;
11653 //woozy+=multiplier;
11655 if(player[0].dead)camerashake=0;
11656 if(player[0].dead)woozy=0;
11657 camerashake-=multiplier*2;
11658 blackout-=multiplier*2;
11659 //if(player[0].isCrouch())woozy-=multiplier*8;
11660 if(camerashake<0)camerashake=0;
11661 if(blackout<0)blackout=0;
11662 //if(woozy<0)woozy=0;
11664 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11665 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11666 viewer.z+=(float)(Random()%100)*.0005*camerashake;