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);
240 mkdir("Screenshots");
242 mkdir("Screenshots", S_IRWXU);
245 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
248 GraphicsExportComponent QT_exporter;
249 OSErr MAC_error_code;
250 CGrafPtr MAC_currentPort;
251 GDHandle MAC_currentDevice;
252 unsigned char* MAC_pixels;
253 Rect MAC_picture_rectangle;
254 GWorldPtr MAC_offscreen_graphics_port;
256 static int numscreenshots=0;
259 static char buf[256];
260 if(numscreenshots==0){
291 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
292 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
293 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
294 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
315 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
316 //assert(MAC_gWorld != NULL);
318 // Allocate memory for loading image
319 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
320 if (MAC_pixels == NULL) {
321 //UTIL_Error("Could not create Texture data.");
326 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
328 // Make a picture Rectangle
329 MAC_picture_rectangle.left = 0;
330 MAC_picture_rectangle.right = screenwidth;
331 MAC_picture_rectangle.top = 0;
332 MAC_picture_rectangle.bottom = screenheight;
334 // Create new offscreen GWorld
335 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
336 if (MAC_error_code) {
337 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
339 //UTIL_Error("Could not create offscreen GWorld. ");
344 // Copy OpenGL Context to new GWorld
345 glReadBuffer(GL_FRONT);
346 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
349 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
350 unsigned char temp = MAC_pixels[byte+0];
351 MAC_pixels[byte+0] = MAC_pixels[byte+3];
352 MAC_pixels[byte+3] = MAC_pixels[byte+2];
353 MAC_pixels[byte+2] = MAC_pixels[byte+1];
354 MAC_pixels[byte+1] = temp;
357 // Flip the image :( This could probably be optimized
362 for (int horz = 0; horz < screenwidth; ++horz)
363 for (vert = 0; vert < screenheight / 2; ++vert) {
364 src_index = (screenwidth * vert + horz) * 4;
365 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
367 temp=MAC_pixels[src_index+0];
368 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
369 MAC_pixels[dst_index+0]=temp;
371 temp=MAC_pixels[src_index+1];
372 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
373 MAC_pixels[dst_index+1]=temp;
375 temp=MAC_pixels[src_index+2];
376 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
377 MAC_pixels[dst_index+2]=temp;
379 temp=MAC_pixels[src_index+3];
380 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
381 MAC_pixels[dst_index+3]=temp;
387 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
388 if (MAC_error_code) {
389 //UTIL_Warning("Unable to export screenshot.");
390 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
391 ::DisposeGWorld(MAC_offscreen_graphics_port);
396 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
397 if (MAC_error_code) {
398 ::CloseComponent(QT_exporter);
399 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
400 ::DisposeGWorld(MAC_offscreen_graphics_port);
402 //UTIL_Warning("Unable to export screenshot.");
406 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
407 if (MAC_error_code) {
408 ::CloseComponent(QT_exporter);
409 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
410 ::DisposeGWorld(MAC_offscreen_graphics_port);
412 //UTIL_Warning("Unable to export screenshot.");
416 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
417 if (MAC_error_code) {
418 ::CloseComponent(QT_exporter);
419 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
420 ::DisposeGWorld(MAC_offscreen_graphics_port);
422 //UTIL_Warning("Unable to export screenshot.");
426 ::CloseComponent(QT_exporter);
427 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
428 ::DisposeGWorld(MAC_offscreen_graphics_port);
435 void Game::SetUpLighting(){
436 if(environment==snowyenvironment){
442 light.ambient[2]=.44;
444 if(environment==desertenvironment){
449 light.ambient[1]=.35;
453 if(environment==grassyenvironment){
459 light.ambient[2]=.44;
470 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
471 light.color[0]*=(skyboxlightr+average)/2;
472 light.color[1]*=(skyboxlightg+average)/2;
473 light.color[2]*=(skyboxlightb+average)/2;
474 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
475 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
476 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
480 light.ambient[2]=0; */
483 int Game::findPathDist(int start,int end){
484 int i,j,k,smallestcount,count,connected;
485 int last,last2,last3,last4;
495 while(last!=end&&count<30){
497 for(j=0;j<numpathpoints;j++){
498 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
501 if(numpathpointconnect[j])
502 for(k=0;k<numpathpointconnect[j];k++){
503 if(pathpointconnect[j][k]==last)connected=1;
506 if(numpathpointconnect[last])
507 for(k=0;k<numpathpointconnect[last];k++){
508 if(pathpointconnect[last][k]==j)connected=1;
511 if(closest==-1||Random()%2==0){
522 if(count<smallestcount)smallestcount=count;
524 return smallestcount;
527 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
528 static XYZ colpoint,colviewer,coltarget;
529 static float minx,minz,maxx,maxz,miny,maxy;
538 if(minx>endpoint.x)minx=endpoint.x;
540 if(miny>endpoint.y)miny=endpoint.y;
542 if(minz>endpoint.z)minz=endpoint.z;
545 if(maxx<endpoint.x)maxx=endpoint.x;
547 if(maxy<endpoint.y)maxy=endpoint.y;
549 if(maxz<endpoint.z)maxz=endpoint.z;
558 for(i=0;i<objects.numobjects;i++){
559 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){
560 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
561 colviewer=startpoint;
563 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
568 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
573 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
574 static XYZ colpoint,colviewer,coltarget;
575 static float minx,minz,maxx,maxz,miny,maxy;
584 if(minx>endpoint.x)minx=endpoint.x;
586 if(miny>endpoint.y)miny=endpoint.y;
588 if(minz>endpoint.z)minz=endpoint.z;
591 if(maxx<endpoint.x)maxx=endpoint.x;
593 if(maxy<endpoint.y)maxy=endpoint.y;
595 if(maxz<endpoint.z)maxz=endpoint.z;
605 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){
606 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
607 colviewer=startpoint;
609 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
614 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
619 void Game::Setenvironment(int which)
623 LOG(" Setting environment...");
628 FSOUND_SetPaused(channels[music1snow], true);
629 FSOUND_SetPaused(channels[music1grass], true);
630 FSOUND_SetPaused(channels[music1desert], true);
631 FSOUND_SetPaused(channels[wind], true);
632 FSOUND_SetPaused(channels[desertambient], true);
634 FSOUND_SetPaused(channels[stream_music1snow], true);
635 FSOUND_SetPaused(channels[stream_music1grass], true);
636 FSOUND_SetPaused(channels[stream_music1desert], true);
637 FSOUND_SetPaused(channels[stream_wind], true);
638 FSOUND_SetPaused(channels[stream_desertambient], true);
641 if(environment==snowyenvironment){
645 //PlaySoundEx( wind, samp[wind], NULL, true);
646 PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
647 FSOUND_SetPaused(channels[stream_wind], false);
648 FSOUND_SetVolume(channels[stream_wind], 256);
651 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
652 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
653 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
654 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
656 FSOUND_Sample_Free(samp[footstepsound]);
657 FSOUND_Sample_Free(samp[footstepsound2]);
658 FSOUND_Sample_Free(samp[footstepsound3]);
659 FSOUND_Sample_Free(samp[footstepsound4]);
660 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
661 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
662 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
663 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
664 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
665 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
666 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
667 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
669 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
671 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
673 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
678 temptexdetail=texdetail;
679 if(texdetail>1)texdetail=4;
680 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
681 ":Data:Textures:Skybox(snow):Left.jpg",
682 ":Data:Textures:Skybox(snow):Back.jpg",
683 ":Data:Textures:Skybox(snow):Right.jpg",
684 ":Data:Textures:Skybox(snow):Up.jpg",
685 ":Data:Textures:Skybox(snow):Down.jpg",
686 ":Data:Textures:Skybox(snow):Cloud.jpg",
687 ":Data:Textures:Skybox(snow):Reflect.jpg");
692 texdetail=temptexdetail;
694 if(environment==desertenvironment){
697 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
698 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
699 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
700 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
704 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
705 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
706 FSOUND_SetPaused(channels[stream_desertambient], false);
707 FSOUND_SetVolume(channels[stream_desertambient], 256);
710 FSOUND_Sample_Free(samp[footstepsound]);
711 FSOUND_Sample_Free(samp[footstepsound2]);
712 FSOUND_Sample_Free(samp[footstepsound3]);
713 FSOUND_Sample_Free(samp[footstepsound4]);
714 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
715 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
716 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0);
717 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0);
718 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
719 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
720 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
721 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
723 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
725 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
727 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
731 temptexdetail=texdetail;
732 if(texdetail>1)texdetail=4;
733 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
734 ":Data:Textures:Skybox(sand):Left.jpg",
735 ":Data:Textures:Skybox(sand):Back.jpg",
736 ":Data:Textures:Skybox(sand):Right.jpg",
737 ":Data:Textures:Skybox(sand):Up.jpg",
738 ":Data:Textures:Skybox(sand):Down.jpg",
739 ":Data:Textures:Skybox(sand):Cloud.jpg",
740 ":Data:Textures:Skybox(sand):Reflect.jpg");
745 texdetail=temptexdetail;
747 if(environment==grassyenvironment){
750 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
751 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
752 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
753 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
756 PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
757 FSOUND_SetPaused(channels[stream_wind], false);
758 FSOUND_SetVolume(channels[stream_wind], 100);
761 FSOUND_Sample_Free(samp[footstepsound]);
762 FSOUND_Sample_Free(samp[footstepsound2]);
763 FSOUND_Sample_Free(samp[footstepsound3]);
764 FSOUND_Sample_Free(samp[footstepsound4]);
765 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass1.ogg", FSOUND_HW3D, 0, 0);
766 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepgrass2.ogg", FSOUND_HW3D, 0, 0);
767 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0);
768 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0);
769 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
770 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
771 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
772 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
774 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
776 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
778 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
782 temptexdetail=texdetail;
783 if(texdetail>1)texdetail=4;
784 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
785 ":Data:Textures:Skybox(grass):Left.jpg",
786 ":Data:Textures:Skybox(grass):Back.jpg",
787 ":Data:Textures:Skybox(grass):Right.jpg",
788 ":Data:Textures:Skybox(grass):Up.jpg",
789 ":Data:Textures:Skybox(grass):Down.jpg",
790 ":Data:Textures:Skybox(grass):Cloud.jpg",
791 ":Data:Textures:Skybox(grass):Reflect.jpg");
795 texdetail=temptexdetail;
797 temptexdetail=texdetail;
799 terrain.load(":Data:Textures:heightmap.png");
801 texdetail=temptexdetail;
805 void Game::Loadlevel(int which){
808 if(which==0)Loadlevel((char *)":Data:Maps:map1");
809 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
810 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
811 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
812 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
813 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
814 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
815 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
816 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
817 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
818 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
819 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
820 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
821 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
822 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
823 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
824 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
825 else Loadlevel((char *)":Data:Maps:mapsave");
830 /*char * Game::MD5_string (unsigned char *string){
834 strcpy(temp2,(const char *)string);
835 strcat((char *)temp2,(const char *)"Lugaru");
836 sprintf (temp, "%d",strlen((char *)temp2));
837 strcat((char *)temp2,temp);
840 unsigned int len = strlen ( (char *)temp2);
842 context.update ((unsigned char *)temp2, len);
845 return context.hex_digest();
850 void Game::Loadlevel(char *name){
857 float headprop,legprop,armprop,bodyprop;
861 LOG(std::string("Loading level...") + name);
863 if(!gameon)visibleloading=1;
865 if(stealthloading)visibleloading=0;
867 if(!stillloading)loadtime=0;
872 if(tutoriallevel!=-1)tutoriallevel=0;
873 else tutoriallevel=1;
875 if(tutoriallevel==1)tutorialstage=0;
876 if(tutorialstage==0){
884 FSOUND_SetPaused(channels[whooshsound], true);
885 FSOUND_SetPaused(channels[stream_firesound], true);
889 tfile=fopen( name, "rb" );
892 FSOUND_SetPaused(channels[stream_firesound], true);
903 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
909 dialoguegonethrough[i]=0;
918 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
920 if(difficulty!=2)minimap=1;
957 bonustotal=startbonustotal;
963 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
964 FSOUND_SetVolume(channels[consolesuccesssound], 256);
965 FSOUND_SetPaused(channels[consolesuccesssound], false);
973 sprites.numsprites=0;
974 for(i=0;i<objects.numobjects;i++)
976 objects.model[i].numdecals=0;
979 j=objects.numobjects;
982 objects.DeleteObject(0);
983 if(visibleloading){loadscreencolor=4; LoadingScreen();}
986 for(i=0;i<subdivision;i++)
988 for(j=0;j<subdivision;j++)
990 terrain.patchobjectnum[i][j]=0;
993 if(visibleloading){loadscreencolor=4; LoadingScreen();}
996 weapons.numweapons=0;
998 funpackf(tfile, "Bi", &mapvers);
999 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1001 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1002 else maptype=mapkilleveryone;
1003 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1005 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1011 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1019 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1022 skyboxlightr=skyboxr;
1023 skyboxlightg=skyboxg;
1024 skyboxlightb=skyboxb;
1026 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);
1027 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1028 player[0].originalcoords=player[0].coords;
1029 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1031 for(j=0;j<player[0].num_weapons;j++)
1033 player[0].weaponids[j]=weapons.numweapons;
1034 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1035 weapons.owner[weapons.numweapons]=0;
1036 weapons.numweapons++;
1040 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1042 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1043 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1044 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1045 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1047 funpackf(tfile, "Bi", &player[0].numclothes);
1051 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1055 player[0].whichskin=0;
1056 player[0].creature=rabbittype;
1059 for(i=0;i<max_dialogues;i++)
1061 for(j=0;j<max_dialoguelength;j++)
1065 dialoguetext[i][j][k]='\0';
1069 dialoguename[i][j][k]='\0';
1074 player[0].lastattack=-1;
1075 player[0].lastattack2=-1;
1076 player[0].lastattack3=-1;
1080 funpackf(tfile, "Bi", &numdialogues);
1083 for(k=0;k<numdialogues;k++)
1085 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1086 funpackf(tfile, "Bi", &dialoguetype[k]);
1089 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1090 funpackf(tfile, "Bf", &participantrotation[k][l]);
1092 if(numdialogueboxes)
1094 for(l=0;l<numdialogueboxes[k];l++)
1096 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1097 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1098 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1099 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1100 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1104 funpackf(tfile, "Bi",&templength);
1105 if(templength>128||templength<=0)templength=128;
1106 for(m=0;m<templength;m++){
1107 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1108 if(dialoguetext[k][l][m]=='\0')break;
1111 funpackf(tfile, "Bi",&templength);
1112 if(templength>64||templength<=0)templength=64;
1113 for(m=0;m<templength;m++){
1114 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1115 if(dialoguename[k][l][m]=='\0'){
1119 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1120 funpackf(tfile, "Bi", &participantfocus[k][l]);
1121 funpackf(tfile, "Bi", &participantaction[k][l]);
1124 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1126 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1132 else numdialogues=0;
1134 if(player[0].numclothes)
1136 for(k=0;k<player[0].numclothes;k++)
1138 funpackf(tfile, "Bi", &templength);
1139 for(l=0;l<templength;l++)
1140 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1141 player[0].clothes[k][templength]='\0';
1142 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1146 funpackf(tfile, "Bi", &environment);
1148 funpackf(tfile, "Bi", &objects.numobjects);
1149 if(objects.numobjects)
1151 for(i=0;i<objects.numobjects;i++)
1153 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]);
1154 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1160 funpackf(tfile, "Bi", &numhotspots);
1163 for(i=0;i<numhotspots;i++)
1165 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1166 funpackf(tfile, "Bi", &templength);
1168 for(l=0;l<templength;l++)
1169 funpackf(tfile, "Bb", &hotspottext[i][l]);
1170 hotspottext[i][templength]='\0';
1171 if(hotspottype[i]==-111)indemo=1;
1177 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1182 for(i=0;i<objects.numobjects;i++)
1184 objects.center+=objects.position[i];
1186 objects.center/=objects.numobjects;
1189 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1191 float maxdistance=0;
1194 for(i=0;i<objects.numobjects;i++)
1196 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1197 if(tempdist>maxdistance)
1200 maxdistance=tempdist;
1203 objects.radius=fast_sqrt(maxdistance);
1206 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1207 //mapcenter=objects.center;
1208 //mapradius=objects.radius;
1210 funpackf(tfile, "Bi", &numplayers);
1211 int howmanyremoved=0;
1212 bool removeanother=0;
1213 if(numplayers>1&&numplayers<maxplayers)
1215 for(i=1;i<numplayers;i++)
1217 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1220 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);
1221 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1222 else player[i-howmanyremoved].howactive=typeactive;
1223 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1224 else player[i-howmanyremoved].scale=-1;
1225 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1226 else player[i-howmanyremoved].immobile=0;
1227 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1228 else player[i-howmanyremoved].rotation=0;
1229 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1230 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1236 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1238 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1240 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1241 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1242 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1243 weapons.numweapons++;
1246 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1247 //player[i-howmanyremoved].numwaypoints=10;
1248 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1250 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1251 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1252 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1253 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1254 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1257 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1258 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1260 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1261 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1262 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1263 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1265 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1273 if(player[i-howmanyremoved].creature==wolftype)
1275 player[i-howmanyremoved].proportionhead=1.1*headprop;
1276 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1277 player[i-howmanyremoved].proportionarms=1.1*armprop;
1278 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1281 if(player[i-howmanyremoved].creature==rabbittype)
1283 player[i-howmanyremoved].proportionhead=1.2*headprop;
1284 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1285 player[i-howmanyremoved].proportionarms=1.00*armprop;
1286 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1287 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1290 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1291 if(player[i-howmanyremoved].numclothes)
1293 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1296 funpackf(tfile, "Bi", &templength);
1297 for(l=0;l<templength;l++)
1298 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1299 player[i-howmanyremoved].clothes[k][templength]='\0';
1300 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1306 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1308 numplayers-=howmanyremoved;
1309 funpackf(tfile, "Bi", &numpathpoints);
1310 if(numpathpoints>30||numpathpoints<0)
1314 for(j=0;j<numpathpoints;j++)
1316 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1317 for(k=0;k<numpathpointconnect[j];k++){
1318 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1322 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1324 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1327 if(environment!=oldenvironment)Setenvironment(environment);
1328 oldenvironment=environment;
1332 j=objects.numobjects;
1333 objects.numobjects=0;
1336 //if(objects.type[i]!=spiketype)
1337 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1338 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1341 //if(skyboxtexture){
1342 terrain.DoShadows();
1343 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1344 objects.DoShadows();
1345 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1347 else terrain.DoLighting();
1353 oldlevel=whichlevel;
1356 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1357 for(i=0;i<numplayers;i++)
1359 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1363 if(i==0||player[i].scale<0)player[i].scale=.2;
1364 player[i].skeleton.free=0;
1365 player[i].skeleton.id=i;
1366 //if(Random()%2==0)player[i].creature=wolftype;
1367 //else player[i].creature=rabbittype;
1368 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1369 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);
1372 if(player[i].creature!=wolftype){
1373 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);
1374 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1376 if(player[i].creature==wolftype){
1377 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);
1383 texsize=512*512*3/texdetail/texdetail;
1384 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1385 //player[i].skeleton.skinText.resize(texsize);
1387 if(player[i].creature==rabbittype)
1389 if(player[i].whichskin==0){
1390 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1392 else if(player[i].whichskin==1){
1393 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1395 else if(player[i].whichskin==2){
1396 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1398 else if(player[i].whichskin==3){
1399 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1401 else if(player[i].whichskin==4){
1402 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1404 else if(player[i].whichskin==5){
1405 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1407 else if(player[i].whichskin==6){
1408 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1410 else if(player[i].whichskin==7){
1411 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1413 else if(player[i].whichskin==8){
1414 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1416 else if(player[i].whichskin==9){
1417 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1420 if(player[i].creature==wolftype)
1422 //k=abs(Random()%3);
1423 if(player[i].whichskin==0){
1424 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1426 else if(player[i].whichskin==1){
1427 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1429 else if(player[i].whichskin==2){
1430 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1434 if(player[i].numclothes)
1436 for(j=0;j<player[i].numclothes;j++)
1438 tintr=player[i].clothestintr[j];
1439 tintg=player[i].clothestintg[j];
1440 tintb=player[i].clothestintb[j];
1441 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1443 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1446 player[i].currentanimation=bounceidleanim;
1447 player[i].targetanimation=bounceidleanim;
1448 player[i].currentframe=0;
1449 player[i].targetframe=1;
1451 player[i].speed=1+(float)(Random()%100)/1000;
1452 if(difficulty==0)player[i].speed-=.2;
1453 if(difficulty==1)player[i].speed-=.1;
1455 player[i].velocity=0;
1456 player[i].oldcoords=player[i].coords;
1457 player[i].realoldcoords=player[i].coords;
1460 player[i].skeleton.id=i;
1461 player[i].updatedelay=0;
1462 player[i].normalsupdatedelay=0;
1464 player[i].aitype=passivetype;
1465 player[i].aitarget=0;
1466 player[i].madskills=0;
1470 player[i].proportionhead=1.2;
1471 player[i].proportionbody=1.05;
1472 player[i].proportionarms=1.00;
1473 player[i].proportionlegs=1.1;
1474 player[i].proportionlegs.y=1.05;
1476 player[i].headless=0;
1477 player[i].currentoffset=0;
1478 player[i].targetoffset=0;
1479 /*player[i].armorhead=1;
1480 player[i].armorhigh=1;
1481 player[i].armorlow=1;
1482 player[i].protectionhead=1;
1483 player[i].protectionhigh=1;
1484 player[i].protectionlow=1;
1485 player[i].metalhead=1;
1486 player[i].metalhigh=1;
1487 player[i].metallow=1;
1489 player[i].speedmult=1;*/
1491 player[i].damagetolerance=200;
1493 if(player[i].creature==wolftype)
1495 /*player[i].proportionhead=1.1;
1496 player[i].proportionbody=1.1;
1497 player[i].proportionarms=1.1;
1498 player[i].proportionlegs=1.1;
1499 player[i].proportionlegs.y=1.1;*/
1500 if(i==0||player[i].scale<0)player[i].scale=.23;
1502 player[i].damagetolerance=300;
1505 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1508 player[i].proportionhead.z=0;
1509 player[i].proportionbody.z=0;
1510 player[i].proportionarms.z=0;
1511 player[i].proportionlegs.z=0;
1514 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1516 player[i].headmorphness=0;
1517 player[i].targetheadmorphness=1;
1518 player[i].headmorphstart=0;
1519 player[i].headmorphend=0;
1521 player[i].pausetime=0;
1524 player[i].jumppower=5;
1526 player[i].permanentdamage=0;
1527 player[i].superpermanentdamage=0;
1529 player[i].forwardkeydown=0;
1530 player[i].leftkeydown=0;
1531 player[i].backkeydown=0;
1532 player[i].rightkeydown=0;
1533 player[i].jumpkeydown=0;
1534 player[i].crouchkeydown=0;
1535 player[i].throwkeydown=0;
1537 player[i].collided=-10;
1539 player[i].bloodloss=0;
1540 player[i].weaponactive=-1;
1541 player[i].weaponstuck=-1;
1542 player[i].bleeding=0;
1543 player[i].deathbleeding=0;
1544 player[i].stunned=0;
1545 player[i].hasvictim=0;
1546 player[i].wentforweapon=0;
1549 player[0].aitype=playercontrolled;
1550 player[0].weaponactive=-1;
1554 //player[0].speedmult=1/.9;
1555 player[0].power=1/.9;
1560 //player[0].speedmult=1/.8;
1561 player[0].power=1/.8;
1564 //player[0].weaponstuck=1;
1566 if(difficulty==1)player[0].damagetolerance=250;
1567 if(difficulty==0)player[0].damagetolerance=300;
1568 if(difficulty==0)player[0].armorhead*=1.5;
1569 if(difficulty==0)player[0].armorhigh*=1.5;
1570 if(difficulty==0)player[0].armorlow*=1.5;
1571 cameraloc=player[0].coords;
1573 rotation=player[0].rotation;
1575 hawkcoords=player[0].coords;
1578 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1579 //weapons.numweapons=numplayers;
1580 for(i=0;i<weapons.numweapons;i++)
1582 weapons.bloody[i]=0;
1583 weapons.blooddrip[i]=0;
1584 weapons.blooddripdelay[i]=0;
1585 weapons.onfire[i]=0;
1586 weapons.flamedelay[i]=0;
1587 weapons.damage[i]=0;
1588 //weapons.type[i]=sword;
1589 if(weapons.type[i]==sword){
1590 weapons.mass[i]=1.5;
1591 weapons.tipmass[i]=1;
1592 weapons.length[i]=.8;
1594 if(weapons.type[i]==staff){
1596 weapons.tipmass[i]=1;
1597 weapons.length[i]=1.5;
1599 if(weapons.type[i]==knife){
1601 weapons.tipmass[i]=1.2;
1602 weapons.length[i]=.25;
1604 weapons.position[i]=-1000;
1605 weapons.tippoint[i]=-1000;
1608 /* for(i=0;i<32;i++){
1610 FSOUND_StopSound(i);
1613 LOG("Starting background music...");
1615 FSOUND_StopSound(FSOUND_ALL);
1616 if(environment==snowyenvironment)
1620 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1621 FSOUND_SetPaused(channels[stream_wind], false);
1622 FSOUND_SetVolume(channels[stream_wind], 256);
1625 else if(environment==desertenvironment)
1629 //PlaySoundEx(desertambient,
1630 // samp[desertambient], NULL, true);
1631 PlayStreamEx(stream_desertambient,
1632 strm[stream_desertambient], NULL, true);
1633 FSOUND_SetPaused(channels[stream_desertambient], false);
1634 FSOUND_SetVolume(channels[stream_desertambient], 256);
1637 else if(environment==grassyenvironment)
1641 //PlaySoundEx(wind, samp[wind], NULL, true);
1642 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1643 FSOUND_SetPaused(channels[stream_wind], false);
1644 FSOUND_SetVolume(channels[stream_wind], 100);
1647 oldmusicvolume[0]=0;
1648 oldmusicvolume[1]=0;
1649 oldmusicvolume[2]=0;
1650 oldmusicvolume[3]=0;
1653 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1654 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1655 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1656 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1657 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1658 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1659 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1660 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1675 static int i,k,j,l,m;
1676 static XYZ facing,flatfacing,absflatfacing;
1677 static XYZ rotatetarget;
1679 static float oldtargetrotation;
1680 static int target, numgood;
1681 static XYZ tempcoords1,tempcoords2;
1684 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1685 static int whichhit;
1686 static bool donesomething;
1687 static bool oldjumpkeydown;
1691 float headprop,bodyprop,armprop,legprop;
1695 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1696 FSOUND_SetVolume(channels[consolesuccesssound], 256);
1697 FSOUND_SetPaused(channels[consolesuccesssound], false);
1701 consoletext[k][j]=consoletext[k-1][j];
1703 consolechars[k]=consolechars[k-1];
1707 displaytext[k][j]=displaytext[k-1][j];
1709 displaychars[k]=displaychars[k-1];
1710 displaytime[k]=displaytime[k-1];
1713 consoletext[1][j]=' ';
1714 displaytext[1][j]=' ';
1716 sprintf (consoletext[1], netmessages);
1717 sprintf (displaytext[1], netmessages);
1718 consolechars[1]=255;
1719 displaychars[1]=255;
1724 displaytime[i]+=multiplier;
1727 static unsigned char theKeyMap[16];
1728 GetKeys( theKeyMap );
1733 static bool mainmenutogglekeydown;
1735 if(mainmenu&&endgame==1)mainmenu=10;
1736 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1738 displaytext[0][j]=' ';
1743 mainmenutogglekeydown=1;
1745 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)){
1747 if(mainmenu==1||mainmenu==2||mainmenu==0){
1748 if(mainmenu==0&&!winfreeze)mainmenu=2;
1749 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1750 else if(mainmenu==0&&winfreeze){
1751 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1753 else stealthloading=0;
1755 if(!stealthloading){
1756 float gLoc[3]={0,0,0};
1757 float vel[3]={0,0,0};
1758 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1759 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1760 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1761 FSOUND_SetVolume(channels[firestartsound], 256);
1762 FSOUND_SetPaused(channels[firestartsound], false);
1763 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1774 for(i=0;i<campaignnumlevels;i++){
1776 levelhighlight[i]=0;
1781 if(accountcampaignchoicesmade[accountactive])
1782 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1783 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1784 levelvisible[levelorder[i+1]]=1;
1786 int whichlevelstart;
1787 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1788 if(whichlevelstart<0){
1789 campaignchoicenum=1;
1790 campaignchoicewhich[0]=0;
1794 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1795 if(campaignchoicenum)
1796 for(i=0;i<campaignchoicenum;i++){
1797 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1798 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1799 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1806 if(firstload)TickOnceAfter();
1807 if(!firstload)LoadStuff();
1824 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1825 //accountcampaignchoicesmade[accountactive]++;
1828 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1836 FSOUND_SetPaused(channels[music3], true);
1840 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1841 if(mainmenu&&musictoggle){
1842 if(mainmenu==1||mainmenu==2||mainmenu==100){
1843 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
1844 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1845 FSOUND_SetPaused(channels[stream_music3], false);
1846 FSOUND_SetVolume(channels[stream_music3], 256);
1847 FSOUND_SetPaused(channels[music1], true);
1851 FSOUND_SetPaused(channels[stream_music3], true);
1852 FSOUND_SetPaused(channels[music1], false);
1856 float gLoc[3]={0,0,0};
1857 float vel[3]={0,0,0};
1858 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1859 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1860 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1861 FSOUND_SetVolume(channels[fireendsound], 256);
1862 FSOUND_SetPaused(channels[fireendsound], false);
1863 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1871 if(newdetail>2)newdetail=detail;
1872 if(newdetail<0)newdetail=detail;
1873 #if !USE_SDL // we'll take anything that works.
1874 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1875 if(newscreenheight>3000)newscreenheight=screenheight;
1877 if(newscreenwidth<0)newscreenwidth=screenwidth;
1878 if(newscreenheight<0)newscreenheight=screenheight;
1880 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1881 opstream << "Screenwidth:\n";
1882 opstream << newscreenwidth;
1883 opstream << "\nScreenheight:\n";
1884 opstream << newscreenheight;
1885 opstream << "\nMouse sensitivity:\n";
1886 opstream << usermousesensitivity;
1887 opstream << "\nBlur(0,1):\n";
1888 opstream << ismotionblur;
1889 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1890 opstream << newdetail;
1891 opstream << "\nFloating jump:\n";
1892 opstream << floatjump;
1893 opstream << "\nMouse jump:\n";
1894 opstream << mousejump;
1895 opstream << "\nAmbient sound:\n";
1896 opstream << ambientsound;
1897 opstream << "\nBlood (0,1,2):\n";
1898 opstream << bloodtoggle;
1899 opstream << "\nAuto slomo:\n";
1900 opstream << autoslomo;
1901 opstream << "\nFoliage:\n";
1902 opstream << foliage;
1903 opstream << "\nMusic:\n";
1904 opstream << musictoggle;
1905 opstream << "\nTrilinear:\n";
1906 opstream << trilinear;
1907 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1909 opstream << "\nInvert mouse:\n";
1910 opstream << invertmouse;
1911 opstream << "\nGamespeed:\n";
1912 if(oldgamespeed==0)oldgamespeed=1;
1913 opstream << oldgamespeed;
1914 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1915 opstream << difficulty;
1916 opstream << "\nDamage effects(blackout, doublevision):\n";
1917 opstream << damageeffects;
1918 opstream << "\nText:\n";
1919 opstream << texttoggle;
1920 opstream << "\nDebug:\n";
1921 opstream << debugmode;
1922 opstream << "\nVBL Sync:\n";
1923 opstream << vblsync;
1924 opstream << "\nShow Points:\n";
1925 opstream << showpoints;
1926 opstream << "\nAlways Blur:\n";
1927 opstream << alwaysblur;
1928 opstream << "\nImmediate mode (turn on on G5):\n";
1929 opstream << immediate;
1930 opstream << "\nVelocity blur:\n";
1931 opstream << velocityblur;
1932 opstream << "\nVolume:\n";
1934 opstream << "\nForward key:\n";
1935 opstream << KeyToChar(forwardkey);
1936 opstream << "\nBack key:\n";
1937 opstream << KeyToChar(backkey);
1938 opstream << "\nLeft key:\n";
1939 opstream << KeyToChar(leftkey);
1940 opstream << "\nRight key:\n";
1941 opstream << KeyToChar(rightkey);
1942 opstream << "\nJump key:\n";
1943 opstream << KeyToChar(jumpkey);
1944 opstream << "\nCrouch key:\n";
1945 opstream << KeyToChar(crouchkey);
1946 opstream << "\nDraw key:\n";
1947 opstream << KeyToChar(drawkey);
1948 opstream << "\nThrow key:\n";
1949 opstream << KeyToChar(throwkey);
1950 opstream << "\nAttack key:\n";
1951 opstream << KeyToChar(attackkey);
1952 opstream << "\nChat key:\n";
1953 opstream << KeyToChar(chatkey);
1956 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1957 float gLoc[3]={0,0,0};
1958 float vel[3]={0,0,0};
1959 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1960 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1961 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1962 FSOUND_SetVolume(channels[fireendsound], 256);
1963 FSOUND_SetPaused(channels[fireendsound], false);
1964 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1972 if(mainmenu==3&&gameon)mainmenu=2;
1973 if(mainmenu==3&&!gameon)mainmenu=1;
1974 if(mainmenu==5&&gameon)mainmenu=2;
1975 if(mainmenu==5&&!gameon)mainmenu=1;
1976 if(mainmenu==4)mainmenu=3;
1977 if(mainmenu==6)mainmenu=5;
1978 if(mainmenu==7)mainmenu=1;
1979 if(mainmenu==9)mainmenu=5;
1980 if(mainmenu==11)mainmenu=5;
1981 if(mainmenu==12)mainmenu=5;
1982 if(mainmenu==13)mainmenu=12;
1983 if(mainmenu==14)mainmenu=13;
1984 if(mainmenu==10)mainmenu=5;
1990 mainmenutogglekeydown=1;
1992 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1993 mainmenutogglekeydown=0;
1997 /*static bool minimaptogglekeydown;
1998 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
2000 minimaptogglekeydown=1;
2002 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
2003 minimaptogglekeydown=0;
2007 static bool minimaptogglekeydown;
2008 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
2009 if(tutorialstage!=51)
2010 tutorialstagetime=tutorialmaxtime;
2011 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
2012 FSOUND_SetVolume(channels[consolefailsound], 128);
2013 FSOUND_SetPaused(channels[consolefailsound], false);
2014 minimaptogglekeydown=1;
2016 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
2017 minimaptogglekeydown=0;
2022 if(mainmenu==1||mainmenu==2){
2023 if(Button()&&!oldbutton&&selected==1){
2025 float gLoc[3]={0,0,0};
2026 float vel[3]={0,0,0};
2027 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2028 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2029 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2030 FSOUND_SetVolume(channels[firestartsound], 256);
2031 FSOUND_SetPaused(channels[firestartsound], false);
2032 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2041 if(accountactive!=-1)mainmenu=5;
2048 if(firstload)TickOnceAfter();
2049 if(!firstload)LoadStuff();
2055 FSOUND_SetPaused(channels[music3], true); */
2061 FSOUND_SetPaused(channels[stream_music3], true);
2062 FSOUND_SetPaused(channels[music1], false);
2066 if(Button()&&!oldbutton&&selected==2){
2067 float gLoc[3]={0,0,0};
2068 float vel[3]={0,0,0};
2069 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2070 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2071 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2072 FSOUND_SetVolume(channels[firestartsound], 256);
2073 FSOUND_SetPaused(channels[firestartsound], false);
2074 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2086 if(newdetail>2)newdetail=detail;
2087 if(newdetail<0)newdetail=detail;
2088 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2089 if(newscreenwidth<0)newscreenwidth=screenwidth;
2090 if(newscreenheight>3000)newscreenheight=screenheight;
2091 if(newscreenheight<0)newscreenheight=screenheight;
2094 if(Button()&&!oldbutton&&selected==3){
2095 float gLoc[3]={0,0,0};
2096 float vel[3]={0,0,0};
2097 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2098 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2099 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2100 FSOUND_SetVolume(channels[fireendsound], 256);
2101 FSOUND_SetPaused(channels[fireendsound], false);
2102 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2113 if(registered)FSOUND_SetPaused(channels[stream_music3], true);
2121 if(Button())oldbutton=1;
2126 if(Button()&&!oldbutton&&selected!=-1){
2127 float gLoc[3]={0,0,0};
2128 float vel[3]={0,0,0};
2129 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2130 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2131 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2132 FSOUND_SetVolume(channels[firestartsound], 256);
2133 FSOUND_SetPaused(channels[firestartsound], false);
2134 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2136 if(Button()&&!oldbutton&&selected==0){
2138 extern SDL_Rect **resolutions;
2139 bool isCustomResolution = true;
2141 for (int i = 0; (!found) && (resolutions[i]); i++)
2143 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2144 isCustomResolution = false;
2146 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2149 if (resolutions[i] != NULL)
2151 newscreenwidth = (int) resolutions[i]->w;
2152 newscreenheight = (int) resolutions[i]->h;
2154 else if (isCustomResolution)
2156 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2158 newscreenwidth = (int) resolutions[0]->w;
2159 newscreenheight = (int) resolutions[0]->h;
2163 newscreenwidth = screenwidth;
2164 newscreenheight = screenheight;
2169 newscreenwidth = (int) resolutions[0]->w;
2170 newscreenheight = (int) resolutions[0]->h;
2178 newscreenwidth = (int) resolutions[0]->w;
2179 newscreenheight = (int) resolutions[0]->h;
2185 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2186 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2187 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2188 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2189 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2190 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2191 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2192 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2193 if(newscreenwidth==1920&&newscreenheight==1200)whichres=8;
2195 if(whichres==-1||whichres==8){
2197 newscreenheight=480;
2201 newscreenheight=600;
2204 newscreenwidth=1024;
2205 newscreenheight=768;
2208 newscreenwidth=1280;
2209 newscreenheight=1024;
2212 newscreenwidth=1600;
2213 newscreenheight=1200;
2217 newscreenheight=524;
2220 newscreenwidth=1024;
2221 newscreenheight=640;
2224 newscreenwidth=1344;
2225 newscreenheight=840;
2228 newscreenwidth=1920;
2229 newscreenheight=1200;
2233 if(Button()&&!oldbutton&&selected==1){
2235 if(newdetail>2)newdetail=0;
2237 if(Button()&&!oldbutton&&selected==2){
2239 if(bloodtoggle>2)bloodtoggle=0;
2241 if(Button()&&!oldbutton&&selected==3){
2243 if(difficulty>2)difficulty=0;
2245 if(Button()&&!oldbutton&&selected==4){
2246 ismotionblur=1-ismotionblur;
2248 if(Button()&&!oldbutton&&selected==5){
2251 if(Button()&&!oldbutton&&selected==6){
2252 musictoggle=1-musictoggle;
2255 FSOUND_SetPaused(channels[music1], true);
2256 FSOUND_SetPaused(channels[stream_music2], true);
2257 FSOUND_SetPaused(channels[stream_music3], true);
2260 oldmusicvolume[i]=0;
2266 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2267 FSOUND_SetPaused(channels[stream_music3], false);
2268 FSOUND_SetVolume(channels[stream_music3], 256);
2271 if(Button()&&!oldbutton&&selected==9){
2272 invertmouse=1-invertmouse;
2274 if(Button()&&!oldbutton&&selected==10){
2275 usermousesensitivity+=.2;
2276 if(usermousesensitivity>2)usermousesensitivity=.2;
2278 if(Button()&&!oldbutton&&selected==11){
2280 if(volume>1.0001f)volume=0;
2281 FSOUND_SetSFXMasterVolume((int)(volume*255));
2283 if(Button()&&!oldbutton&&selected==7){
2284 /*float gLoc[3]={0,0,0};
2285 float vel[3]={0,0,0};
2286 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2287 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2288 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2289 FSOUND_SetVolume(channels[firestartsound], 256);
2290 FSOUND_SetPaused(channels[firestartsound], false);
2291 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2304 if(Button()&&!oldbutton&&selected==8){
2305 float gLoc[3]={0,0,0};
2306 float vel[3]={0,0,0};
2307 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2308 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2309 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2310 FSOUND_SetVolume(channels[fireendsound], 256);
2311 FSOUND_SetPaused(channels[fireendsound], false);
2312 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2320 if(newdetail>2)newdetail=detail;
2321 if(newdetail<0)newdetail=detail;
2322 #if !USE_SDL // we'll take anything that works.
2323 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2324 if(newscreenheight>3000)newscreenheight=screenheight;
2326 if(newscreenwidth<0)newscreenwidth=screenwidth;
2327 if(newscreenheight<0)newscreenheight=screenheight;
2330 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2331 opstream << "Screenwidth:\n";
2332 opstream << newscreenwidth;
2333 opstream << "\nScreenheight:\n";
2334 opstream << newscreenheight;
2335 opstream << "\nMouse sensitivity:\n";
2336 opstream << usermousesensitivity;
2337 opstream << "\nBlur(0,1):\n";
2338 opstream << ismotionblur;
2339 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2340 opstream << newdetail;
2341 opstream << "\nFloating jump:\n";
2342 opstream << floatjump;
2343 opstream << "\nMouse jump:\n";
2344 opstream << mousejump;
2345 opstream << "\nAmbient sound:\n";
2346 opstream << ambientsound;
2347 opstream << "\nBlood (0,1,2):\n";
2348 opstream << bloodtoggle;
2349 opstream << "\nAuto slomo:\n";
2350 opstream << autoslomo;
2351 opstream << "\nFoliage:\n";
2352 opstream << foliage;
2353 opstream << "\nMusic:\n";
2354 opstream << musictoggle;
2355 opstream << "\nTrilinear:\n";
2356 opstream << trilinear;
2357 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2359 opstream << "\nInvert mouse:\n";
2360 opstream << invertmouse;
2361 opstream << "\nGamespeed:\n";
2362 if(oldgamespeed==0)oldgamespeed=1;
2363 opstream << oldgamespeed;
2364 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2365 opstream << difficulty;
2366 opstream << "\nDamage effects(blackout, doublevision):\n";
2367 opstream << damageeffects;
2368 opstream << "\nText:\n";
2369 opstream << texttoggle;
2370 opstream << "\nDebug:\n";
2371 opstream << debugmode;
2372 opstream << "\nVBL Sync:\n";
2373 opstream << vblsync;
2374 opstream << "\nShow Points:\n";
2375 opstream << showpoints;
2376 opstream << "\nAlways Blur:\n";
2377 opstream << alwaysblur;
2378 opstream << "\nImmediate mode (turn on on G5):\n";
2379 opstream << immediate;
2380 opstream << "\nVelocity blur:\n";
2381 opstream << velocityblur;
2382 opstream << "\nVolume:\n";
2384 opstream << "\nForward key:\n";
2385 opstream << KeyToChar(forwardkey);
2386 opstream << "\nBack key:\n";
2387 opstream << KeyToChar(backkey);
2388 opstream << "\nLeft key:\n";
2389 opstream << KeyToChar(leftkey);
2390 opstream << "\nRight key:\n";
2391 opstream << KeyToChar(rightkey);
2392 opstream << "\nJump key:\n";
2393 opstream << KeyToChar(jumpkey);
2394 opstream << "\nCrouch key:\n";
2395 opstream << KeyToChar(crouchkey);
2396 opstream << "\nDraw key:\n";
2397 opstream << KeyToChar(drawkey);
2398 opstream << "\nThrow key:\n";
2399 opstream << KeyToChar(throwkey);
2400 opstream << "\nAttack key:\n";
2401 opstream << KeyToChar(attackkey);
2402 opstream << "\nChat key:\n";
2403 opstream << KeyToChar(chatkey);
2406 if(mainmenu==3&&gameon)mainmenu=2;
2407 if(mainmenu==3&&!gameon)mainmenu=1;
2409 if(Button())oldbutton=1;
2413 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2414 float gLoc[3]={0,0,0};
2415 float vel[3]={0,0,0};
2416 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2417 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2418 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2419 FSOUND_SetVolume(channels[firestartsound], 256);
2420 FSOUND_SetPaused(channels[firestartsound], false);
2421 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2423 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2431 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2433 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2434 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2435 float gLoc[3]={0,0,0};
2436 float vel[3]={0,0,0};
2437 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2438 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2439 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2440 FSOUND_SetVolume(channels[fireendsound], 256);
2441 FSOUND_SetPaused(channels[fireendsound], false);
2442 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2446 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2447 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2451 if(keyselect==0)forwardkey=keynum;
2452 if(keyselect==1)backkey=keynum;
2453 if(keyselect==2)leftkey=keynum;
2454 if(keyselect==3)rightkey=keynum;
2455 if(keyselect==4)crouchkey=keynum;
2456 if(keyselect==5)jumpkey=keynum;
2457 if(keyselect==6)drawkey=keynum;
2458 if(keyselect==7)throwkey=keynum;
2459 if(keyselect==8)attackkey=keynum;
2464 if(Button()&&!oldbutton&&selected==9){
2465 float gLoc[3]={0,0,0};
2466 float vel[3]={0,0,0};
2467 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2468 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2469 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2470 FSOUND_SetVolume(channels[fireendsound], 256);
2471 FSOUND_SetPaused(channels[fireendsound], false);
2472 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2482 if(newdetail>2)newdetail=detail;
2483 if(newdetail<0)newdetail=detail;
2484 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2485 if(newscreenwidth<0)newscreenwidth=screenwidth;
2486 if(newscreenheight>3000)newscreenheight=screenheight;
2487 if(newscreenheight<0)newscreenheight=screenheight;
2492 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2493 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
2494 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2495 FSOUND_SetPaused(channels[stream_music3], false);
2496 FSOUND_SetVolume(channels[stream_music3], 256);
2500 accountcampaignchoicesmade[accountactive]=0;
2501 accountcampaignscore[accountactive]=0;
2502 accountcampaigntime[accountactive]=0;
2504 float gLoc[3]={0,0,0};
2505 float vel[3]={0,0,0};
2506 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2507 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2508 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2509 FSOUND_SetVolume(channels[fireendsound], 256);
2510 FSOUND_SetPaused(channels[fireendsound], false);
2511 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2521 accountcampaignchoicesmade[accountactive]=0;
2522 accountcampaignscore[accountactive]=0;
2523 accountcampaigntime[accountactive]=0;
2527 if(Button()&&!oldbutton&&selected==1){
2528 float gLoc[3]={0,0,0};
2529 float vel[3]={0,0,0};
2530 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2531 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2532 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2533 FSOUND_SetVolume(channels[firestartsound], 256);
2534 FSOUND_SetPaused(channels[firestartsound], false);
2535 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2548 if(firstload)TickOnceAfter();
2549 if(!firstload)LoadStuff();
2556 FSOUND_SetPaused(channels[stream_music3], true);
2558 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2559 float gLoc[3]={0,0,0};
2560 float vel[3]={0,0,0};
2561 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2562 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2563 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2564 FSOUND_SetVolume(channels[firestartsound], 256);
2565 FSOUND_SetPaused(channels[firestartsound], false);
2566 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2579 if(firstload)TickOnceAfter();
2580 if(!firstload)LoadStuff();
2596 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2597 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2601 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2606 FSOUND_SetPaused(channels[stream_music3], true);
2608 if(Button()&&!oldbutton&&selected==4){
2609 float gLoc[3]={0,0,0};
2610 float vel[3]={0,0,0};
2611 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2612 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2613 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2614 FSOUND_SetVolume(channels[fireendsound], 256);
2615 FSOUND_SetPaused(channels[fireendsound], false);
2616 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2624 if(mainmenu==5&&gameon)mainmenu=2;
2625 if(mainmenu==5&&!gameon)mainmenu=1;
2627 if(Button()&&!oldbutton&&selected==5){
2628 float gLoc[3]={0,0,0};
2629 float vel[3]={0,0,0};
2630 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2631 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2632 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2633 FSOUND_SetVolume(channels[fireendsound], 256);
2634 FSOUND_SetPaused(channels[fireendsound], false);
2635 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2645 if(Button()&&!oldbutton&&selected==3){
2646 float gLoc[3]={0,0,0};
2647 float vel[3]={0,0,0};
2648 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2649 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2650 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2651 FSOUND_SetVolume(channels[firestartsound], 256);
2652 FSOUND_SetPaused(channels[firestartsound], false);
2653 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2663 if(Button()&&!oldbutton&&selected==2){
2664 float gLoc[3]={0,0,0};
2665 float vel[3]={0,0,0};
2666 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2667 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2668 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2669 FSOUND_SetVolume(channels[firestartsound], 256);
2670 FSOUND_SetPaused(channels[firestartsound], false);
2671 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2681 if(Button())oldbutton=1;
2685 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2686 float gLoc[3]={0,0,0};
2687 float vel[3]={0,0,0};
2688 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2689 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2690 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2691 FSOUND_SetVolume(channels[firestartsound], 256);
2692 FSOUND_SetPaused(channels[firestartsound], false);
2693 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2705 targetlevel=selected;
2706 if(firstload)TickOnceAfter();
2707 if(!firstload)LoadStuff();
2709 Loadlevel(selected);
2715 FSOUND_SetPaused(channels[stream_music3], true);
2717 if(Button()&&!oldbutton&&selected==numchallengelevels){
2718 float gLoc[3]={0,0,0};
2719 float vel[3]={0,0,0};
2720 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2721 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2722 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2723 FSOUND_SetVolume(channels[fireendsound], 256);
2724 FSOUND_SetPaused(channels[fireendsound], false);
2725 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2735 if(Button())oldbutton=1;
2739 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2740 float gLoc[3]={0,0,0};
2741 float vel[3]={0,0,0};
2742 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2743 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2744 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2745 FSOUND_SetVolume(channels[firestartsound], 256);
2746 FSOUND_SetPaused(channels[firestartsound], false);
2747 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2759 targetlevel=selected;
2760 if(firstload)TickOnceAfter();
2761 if(!firstload)LoadStuff();
2763 Loadlevel(selected);
2769 FSOUND_SetPaused(channels[stream_music3], true);
2771 if(Button()&&!oldbutton&&selected==numchallengelevels){
2772 float gLoc[3]={0,0,0};
2773 float vel[3]={0,0,0};
2774 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2775 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2776 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2777 FSOUND_SetVolume(channels[fireendsound], 256);
2778 FSOUND_SetPaused(channels[fireendsound], false);
2779 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2789 if(Button())oldbutton=1;
2794 if(Button()&&!oldbutton&&selected==3){
2795 float gLoc[3]={0,0,0};
2796 float vel[3]={0,0,0};
2797 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2798 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2799 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2800 FSOUND_SetVolume(channels[fireendsound], 256);
2801 FSOUND_SetPaused(channels[fireendsound], false);
2802 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2812 if(Button())oldbutton=1;
2816 if(mainmenu==15||mainmenu==16){
2817 if(Button()&&!oldbutton&&selected==1){
2818 float gLoc[3]={0,0,0};
2819 float vel[3]={0,0,0};
2820 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2821 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2822 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2823 FSOUND_SetVolume(channels[fireendsound], 256);
2824 FSOUND_SetPaused(channels[fireendsound], false);
2825 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2833 if(mainmenu==15)mainmenu=5;
2836 if(Button())oldbutton=1;
2842 if(Button()&&!oldbutton&&selected==3){
2844 float gLoc[3]={0,0,0};
2845 float vel[3]={0,0,0};
2846 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2847 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2848 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2849 FSOUND_SetVolume(channels[fireendsound], 256);
2850 FSOUND_SetPaused(channels[fireendsound], false);
2851 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2862 if(Button()&&!oldbutton&&selected==4){
2865 float gLoc[3]={0,0,0};
2866 float vel[3]={0,0,0};
2867 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2868 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2869 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2870 FSOUND_SetVolume(channels[fireendsound], 256);
2871 FSOUND_SetPaused(channels[fireendsound], false);
2872 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2882 if(Button()&&!oldbutton&&selected==5){
2884 float gLoc[3]={0,0,0};
2885 float vel[3]={0,0,0};
2886 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2887 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2888 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2889 FSOUND_SetVolume(channels[fireendsound], 256);
2890 FSOUND_SetPaused(channels[fireendsound], false);
2891 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2901 if(Button())oldbutton=1;
2905 if(Button()&&!oldbutton&&selected!=-1){
2906 float gLoc[3]={0,0,0};
2907 float vel[3]={0,0,0};
2908 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2909 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2910 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2911 FSOUND_SetVolume(channels[firestartsound], 256);
2912 FSOUND_SetPaused(channels[firestartsound], false);
2913 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2915 if(Button()&&!oldbutton&&selected==1){
2916 float gLoc[3]={0,0,0};
2917 float vel[3]={0,0,0};
2918 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2919 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2920 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2921 FSOUND_SetVolume(channels[fireendsound], 256);
2922 FSOUND_SetPaused(channels[fireendsound], false);
2923 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2931 for(i=accountactive;i<numaccounts-1;i++){
2932 accountdifficulty[i]=accountdifficulty[i+1];
2933 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2934 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2935 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2937 accountpoints[i]=accountpoints[i+1];
2939 accounthighscore[i][j]=accounthighscore[i+1][j];
2940 accountfasttime[i][j]=accountfasttime[i+1][j];
2943 accountunlocked[i][j]=accountunlocked[i+1][j];
2946 accountname[i][j]=accountname[i+1][j];
2948 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2949 accountprogress[i]=accountprogress[i+1];
2950 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2951 accountcampaignscore[i]=accountcampaignscore[i+1];
2952 accountcampaigntime[i]=accountcampaigntime[i+1];
2961 if(Button()&&!oldbutton&&selected==2){
2962 float gLoc[3]={0,0,0};
2963 float vel[3]={0,0,0};
2964 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2965 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2966 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2967 FSOUND_SetVolume(channels[fireendsound], 256);
2968 FSOUND_SetPaused(channels[fireendsound], false);
2969 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2979 if(Button())oldbutton=1;
2983 if(Button()&&!oldbutton&&selected!=-1){
2984 float gLoc[3]={0,0,0};
2985 float vel[3]={0,0,0};
2986 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2987 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2988 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2989 FSOUND_SetVolume(channels[firestartsound], 256);
2990 FSOUND_SetPaused(channels[firestartsound], false);
2991 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2993 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2996 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2997 accountactive=selected-1;
3005 if(Button()&&!oldbutton&&selected==numaccounts+1){
3006 float gLoc[3]={0,0,0};
3007 float vel[3]={0,0,0};
3008 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
3009 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
3010 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
3011 FSOUND_SetVolume(channels[fireendsound], 256);
3012 FSOUND_SetPaused(channels[fireendsound], false);
3013 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
3024 displaytext[0][j]=' ';
3030 if(Button())oldbutton=1;
3034 if(Button()&&!oldbutton&&selected!=-1){
3035 float gLoc[3]={0,0,0};
3036 float vel[3]={0,0,0};
3037 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3038 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3039 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3040 FSOUND_SetVolume(channels[firestartsound], 256);
3041 FSOUND_SetPaused(channels[firestartsound], false);
3042 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3044 if(selected==0)accountdifficulty[accountactive]=0;
3045 if(selected==1)accountdifficulty[accountactive]=1;
3046 if(selected==2)accountdifficulty[accountactive]=2;
3057 if(Button())oldbutton=1;
3062 if(Button())oldbutton=1;
3065 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
3068 if(newdetail>2)newdetail=detail;
3069 if(newdetail<0)newdetail=detail;
3070 #if !USE_SDL // we'll take anything that works.
3071 if(newscreenwidth>3000)newscreenwidth=screenwidth;
3072 if(newscreenheight>3000)newscreenheight=screenheight;
3074 if(newscreenwidth<0)newscreenwidth=screenwidth;
3075 if(newscreenheight<0)newscreenheight=screenheight;
3077 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
3078 opstream << "Screenwidth:\n";
3079 opstream << newscreenwidth;
3080 opstream << "\nScreenheight:\n";
3081 opstream << newscreenheight;
3082 opstream << "\nMouse sensitivity:\n";
3083 opstream << usermousesensitivity;
3084 opstream << "\nBlur(0,1):\n";
3085 opstream << ismotionblur;
3086 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
3087 opstream << newdetail;
3088 opstream << "\nFloating jump:\n";
3089 opstream << floatjump;
3090 opstream << "\nMouse jump:\n";
3091 opstream << mousejump;
3092 opstream << "\nAmbient sound:\n";
3093 opstream << ambientsound;
3094 opstream << "\nBlood (0,1,2):\n";
3095 opstream << bloodtoggle;
3096 opstream << "\nAuto slomo:\n";
3097 opstream << autoslomo;
3098 opstream << "\nFoliage:\n";
3099 opstream << foliage;
3100 opstream << "\nMusic:\n";
3101 opstream << musictoggle;
3102 opstream << "\nTrilinear:\n";
3103 opstream << trilinear;
3104 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3106 opstream << "\nInvert mouse:\n";
3107 opstream << invertmouse;
3108 opstream << "\nGamespeed:\n";
3109 if(oldgamespeed==0)oldgamespeed=1;
3110 opstream << oldgamespeed;
3111 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3112 opstream << difficulty;
3113 opstream << "\nDamage effects(blackout, doublevision):\n";
3114 opstream << damageeffects;
3115 opstream << "\nText:\n";
3116 opstream << texttoggle;
3117 opstream << "\nDebug:\n";
3118 opstream << debugmode;
3119 opstream << "\nVBL Sync:\n";
3120 opstream << vblsync;
3121 opstream << "\nShow Points:\n";
3122 opstream << showpoints;
3123 opstream << "\nAlways Blur:\n";
3124 opstream << alwaysblur;
3125 opstream << "\nImmediate mode (turn on on G5):\n";
3126 opstream << immediate;
3127 opstream << "\nVelocity blur:\n";
3128 opstream << velocityblur;
3129 opstream << "\nVolume:\n";
3131 opstream << "\nForward key:\n";
3132 opstream << KeyToChar(forwardkey);
3133 opstream << "\nBack key:\n";
3134 opstream << KeyToChar(backkey);
3135 opstream << "\nLeft key:\n";
3136 opstream << KeyToChar(leftkey);
3137 opstream << "\nRight key:\n";
3138 opstream << KeyToChar(rightkey);
3139 opstream << "\nJump key:\n";
3140 opstream << KeyToChar(jumpkey);
3141 opstream << "\nCrouch key:\n";
3142 opstream << KeyToChar(crouchkey);
3143 opstream << "\nDraw key:\n";
3144 opstream << KeyToChar(drawkey);
3145 opstream << "\nThrow key:\n";
3146 opstream << KeyToChar(throwkey);
3147 opstream << "\nAttack key:\n";
3148 opstream << KeyToChar(attackkey);
3149 opstream << "\nChat key:\n";
3150 opstream << KeyToChar(chatkey);
3155 if(mainmenu==1||mainmenu==2){
3156 if(loaddistrib>4)transition+=multiplier/8;
3164 FSOUND_SetFrequency(channels[stream_music3], 22050);
3166 if(entername||mainmenu==13||mainmenu==14){
3168 if(IsKeyDown(theKeyMap, i)){
3169 togglekeydelay[i]+=multiplier;
3170 if(togglekeydelay[i]>.4){
3172 togglekeydelay[i]=.36;
3175 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3176 for(j=255;j>=displayselected+1;j--){
3177 displaytext[0][j]=displaytext[0][j-1];
3179 displaytext[0][displayselected]=KeyToSingleChar(i);
3180 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3184 if(i==MAC_DELETE_KEY&&displayselected!=0){
3185 for(j=displayselected-1;j<255;j++){
3186 displaytext[0][j]=displaytext[0][j+1];
3188 displaytext[0][255]=' ';
3192 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3195 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3198 if(i==MAC_RETURN_KEY&&entername){
3199 if(displaychars[0]){
3201 strcpy(accountname[numaccounts-1],displaytext[0]);
3202 accountactive=numaccounts-1;
3203 accountdifficulty[accountactive]=1;
3204 accountprogress[accountactive]=0;
3205 accountpoints[accountactive]=0;
3206 accountcampaigntime[accountactive]=0;
3207 accountcampaignscore[accountactive]=0;
3208 accountcampaignfasttime[accountactive]=0;
3209 accountcampaignhighscore[accountactive]=0;
3211 accounthighscore[accountactive][j]=0;
3212 accountfasttime[accountactive][j]=0;
3215 accountunlocked[accountactive][j]=0;
3217 accountcampaignchoicesmade[accountactive]=0;
3220 displaytext[0][j]=' ';
3234 float gLoc[3]={0,0,0};
3235 float vel[3]={0,0,0};
3236 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3237 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3238 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3239 FSOUND_SetVolume(channels[firestartsound], 256);
3240 FSOUND_SetPaused(channels[firestartsound], false);
3241 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3244 displaytext[0][j]=' ';
3252 if(i==MAC_RETURN_KEY&&mainmenu==14){
3253 if(displaychars[0]){
3254 char serialstring[256];
3255 char tempstring[256];
3256 #if defined(__APPLE__)
3257 sprintf (tempstring, "%s", registrationname);
3258 #elif defined(_WIN32) || defined(__linux__)
3259 sprintf (tempstring, "%s-windows", registrationname);
3261 #error Please make sure you have the right registration key stuff here!
3268 longnum = MD5_string ( tempstring);
3269 //longnum = 1111111111111111;
3270 num1 = longnum/100000000;
3271 num2 = longnum%100000000;
3272 sprintf (tempstring, "%d-%d-%d-%d\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3276 if(num1/10000>999)numchars+=4;
3277 else if(num1/10000>99)numchars+=3;
3278 else if(num1/10000>9)numchars+=2;
3280 if(num1%10000>999)numchars+=4;
3281 else if(num1%10000>99)numchars+=3;
3282 else if(num1%10000>9)numchars+=2;
3284 if(num2/10000>999)numchars+=4;
3285 else if(num2/10000>99)numchars+=3;
3286 else if(num2/10000>9)numchars+=2;
3288 if(num2%10000>999)numchars+=4;
3289 else if(num2%10000>99)numchars+=3;
3290 else if(num2%10000>9)numchars+=2;
3295 for(j=0;j<numchars;j++){
3296 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3299 if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
3301 if(goodcode<0)goodcode=0;
3308 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3312 numchars=strlen(registrationname);
3313 fpackf(tfile, "Bb", registered);
3314 fpackf(tfile, "Bi", numchars);
3317 for(j=0;j<numchars;j++)
3319 fpackf(tfile, "Bb", registrationname[j]);
3322 fpackf(tfile, "Bi", num1);
3323 fpackf(tfile, "Bi", num2);
3337 float gLoc[3]={0,0,0};
3338 float vel[3]={0,0,0};
3339 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3340 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3341 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3342 FSOUND_SetVolume(channels[firestartsound], 256);
3343 FSOUND_SetPaused(channels[firestartsound], false);
3344 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3347 displaytext[0][j]=' ';
3353 if(i==MAC_RETURN_KEY&&mainmenu==13){
3354 if(displaychars[0]){
3355 sprintf (registrationname, "%s", displaytext[0]);
3356 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3366 float gLoc[3]={0,0,0};
3367 float vel[3]={0,0,0};
3368 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3369 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3370 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3371 FSOUND_SetVolume(channels[firestartsound], 256);
3372 FSOUND_SetPaused(channels[firestartsound], false);
3373 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3376 displaytext[0][j]=' ';
3380 /*char tempstring[50];
3381 sprintf (tempstring, registrationname);
3387 longnum = MD5_string ( tempstring);
3388 num1 = longnum/100000000;
3389 num2 = longnum%100000000;
3390 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3392 displaychars[0]=strlen(displaytext[0]);
3401 togglekeydelay[i]=0;
3405 displayblinkdelay-=multiplier;
3406 if(displayblinkdelay<=0){
3407 displayblinkdelay=.3;
3408 displayblink=1-displayblink;
3414 if(hostile==1)hostiletime+=multiplier;
3416 if(!winfreeze)leveltime+=multiplier;
3417 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3424 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3426 chattogglekeydown=1;
3427 togglekey[chatkey]=1;
3428 togglekeydelay[chatkey]=-20;
3431 if(!IsKeyDown(theKeyMap, chatkey)){
3432 chattogglekeydown=0;
3437 if(IsKeyDown(theKeyMap, i)){
3438 togglekeydelay[i]+=multiplier;
3439 if(togglekeydelay[i]>.4){
3441 togglekeydelay[i]=.36;
3444 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3445 for(j=255;j>=displayselected+1;j--){
3446 displaytext[0][j]=displaytext[0][j-1];
3448 displaytext[0][displayselected]=KeyToSingleChar(i);
3449 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3453 if(i==MAC_DELETE_KEY&&displayselected!=0){
3454 for(j=displayselected-1;j<255;j++){
3455 displaytext[0][j]=displaytext[0][j+1];
3457 displaytext[0][255]=' ';
3461 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3464 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3467 if(i==MAC_RETURN_KEY){
3468 if(displaychars[0]){
3469 /*for(j=0;j<displaychars[0];j++){
3470 talkname[j]=displaytext[0][j];
3472 talkname[displaychars[0]]='\0';
3473 sprintf (chatname, "%s: %s",playerName,talkname);
3474 //NetworkSendInformation(chatname);
3477 displaytext[0][j]=' ';
3489 togglekeydelay[i]=0;
3493 displayblinkdelay-=multiplier;
3494 if(displayblinkdelay<=0){
3495 displayblinkdelay=.3;
3496 displayblink=1-displayblink;
3500 if(chatting)keyboardfrozen=1;
3502 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3505 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3507 freezetogglekeydown=1;
3510 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3511 freezetogglekeydown=0;
3514 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3516 if(!console)freeze=0;
3518 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
3520 consoletogglekeydown=1;
3523 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3524 consoletogglekeydown=0;
3527 if(console)freeze=1;
3529 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3531 if(IsKeyDown(theKeyMap, i)){
3532 togglekeydelay[i]+=multiplier;
3533 if(togglekeydelay[i]>.4){
3535 togglekeydelay[i]=.36;
3538 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3539 for(j=255;j>=consoleselected+1;j--){
3540 consoletext[0][j]=consoletext[0][j-1];
3542 consoletext[0][consoleselected]=KeyToSingleChar(i);
3543 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3547 else if(i==MAC_ENTER_KEY){
3548 for(j=255;j>=consoleselected+1;j--){
3549 consoletext[0][j]=consoletext[0][j-1];
3551 consoletext[0][consoleselected]='\n';
3555 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3556 for(j=consoleselected-1;j<255;j++){
3557 consoletext[0][j]=consoletext[0][j+1];
3559 consoletext[0][255]=' ';
3563 if(i==MAC_ARROW_UP_KEY){
3564 if(archiveselected<14)archiveselected++;
3566 consolechars[0]=consolechars[archiveselected];
3567 consoletext[0][j]=consoletext[archiveselected][j];
3568 consoleselected=consolechars[0];
3571 if(i==MAC_ARROW_DOWN_KEY){
3572 if(archiveselected>0)archiveselected--;
3574 consolechars[0]=consolechars[archiveselected];
3575 consoletext[0][j]=consoletext[archiveselected][j];
3576 consoleselected=consolechars[0];
3579 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3582 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3585 if(i==MAC_RETURN_KEY){
3588 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3589 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3590 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3591 FSOUND_SetPaused(channels[consolesuccesssound], false);
3595 /*if(Compare(consoletext[0],"send ",0,4)){
3596 for(j=5;j<consolechars[0];j++){
3597 talkname[j-5]=consoletext[0][j];
3599 talkname[consolechars[0]-5]='\0';
3600 sprintf (chatname, "%s: %s",playerName,talkname);
3601 //NetworkSendInformation(chatname);
3604 if(Compare(consoletext[0],"name ",0,4)){
3606 numchars=consolechars[0]-5;
3607 if(numchars>32)numchars=32;
3608 for(j=5;j<numchars+5;j++){
3609 talkname[j-5]=consoletext[0][j];
3611 talkname[numchars]='\0';
3612 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3613 //NetworkSendInformation(chatname);
3614 sprintf (playerName, "%s",talkname);
3615 //NetworkSendName(playerName);
3618 if(Compare(consoletext[0],"map ",0,3)){
3630 for(j=4;j<consolechars[0];j++){
3631 mapname[j-4+11]=consoletext[0][j];
3633 mapname[consolechars[0]-4+11]='\0';
3639 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3641 unsigned char playerNameStr[32];
3642 char theIPAddress[256];
3644 NMUInt32 port = 25710;
3646 strcpy(playerName, "Client");
3647 GameC2PStr( playerName, playerNameStr );
3649 for(j=0;j<consolechars[0]-8;j++){
3650 theIPAddress[j]=consoletext[0][j+8];
3652 theIPAddress[consolechars[0]-8]='\0';
3654 sprintf( thePort, "%li", port );
3655 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3658 if(consolechars[0]>0){
3661 consoletext[k][j]=consoletext[k-1][j];
3663 consolechars[k]=consolechars[k-1];
3666 consoletext[0][j]=' ';
3668 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3669 else sprintf (consoletext[0], "Could not open connection");
3671 consolechars[0]=255;
3678 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3679 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3680 FSOUND_SetPaused(channels[consolesuccesssound], false);
3682 if(consolechars[0]>0){
3685 consoletext[k][j]=consoletext[k-1][j];
3687 consolechars[k]=consolechars[k-1];
3690 consoletext[0][j]=' ';
3692 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3694 consolechars[0]=255;
3700 if(Compare(consoletext[0],"host ",0,4)){
3701 unsigned char gameNameStr[32], playerNameStr[32];
3702 char gameName[32];//, playerName[32];
3710 strcpy(gameName, "Host's game");
3711 strcpy(playerName, "Host");
3712 GameC2PStr( gameName, gameNameStr );
3713 GameC2PStr( playerName, playerNameStr );
3715 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3718 if(consolechars[0]>0){
3721 consoletext[k][j]=consoletext[k-1][j];
3723 consolechars[k]=consolechars[k-1];
3726 consoletext[0][j]=' ';
3728 sprintf (consoletext[0], "Error #%d!!!",v);
3730 consolechars[0]=255;
3737 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3738 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3739 FSOUND_SetPaused(channels[consolesuccesssound], false);
3741 if(consolechars[0]>0){
3744 consoletext[k][j]=consoletext[k-1][j];
3746 consolechars[k]=consolechars[k-1];
3749 consoletext[0][j]=' ';
3751 sprintf (consoletext[0], "Game hosted");
3753 consolechars[0]=255;
3759 if(Compare(consoletext[0],"save ",0,4)){
3771 for(j=5;j<consolechars[0];j++){
3772 mapname[j-5+11]=consoletext[0][j];
3774 mapname[consolechars[0]-5+11]='\0';
3776 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3777 FSOUND_SetVolume(channels[consolesuccesssound], 256);
3778 FSOUND_SetPaused(channels[consolesuccesssound], false);
3785 tfile=fopen( mapname, "wb" );
3786 fpackf(tfile, "Bi", mapvers);
3787 //fpackf(tfile, "Bi", indemo);
3788 fpackf(tfile, "Bi", maptype);
3789 fpackf(tfile, "Bi", hostile);
3790 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3791 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3792 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3793 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);
3794 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3795 for(j=0;j<player[0].num_weapons;j++){
3796 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3799 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3800 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3801 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3802 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3804 fpackf(tfile, "Bi", player[0].numclothes);
3806 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3808 fpackf(tfile, "Bi", numdialogues);
3810 for(k=0;k<numdialogues;k++){
3811 fpackf(tfile, "Bi", numdialogueboxes[k]);
3812 fpackf(tfile, "Bi", dialoguetype[k]);
3814 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3815 fpackf(tfile, "Bf", participantrotation[k][l]);
3817 if(numdialogueboxes)
3818 for(l=0;l<numdialogueboxes[k];l++){
3819 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3820 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3821 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3822 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3823 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3825 templength=strlen(dialoguetext[k][l]);
3826 fpackf(tfile, "Bi",(templength));
3827 for(m=0;m<templength;m++){
3828 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3829 if(dialoguetext[k][l][m]=='\0')break;
3832 templength=strlen(dialoguename[k][l]);
3833 fpackf(tfile, "Bi",templength);
3834 for(m=0;m<templength;m++){
3835 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3836 if(dialoguename[k][l][m]=='\0')break;
3839 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3840 fpackf(tfile, "Bi", participantfocus[k][l]);
3841 fpackf(tfile, "Bi", participantaction[k][l]);
3844 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3846 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3850 if(player[0].numclothes)
3851 for(k=0;k<player[0].numclothes;k++){
3852 templength=strlen(player[0].clothes[k]);
3853 fpackf(tfile, "Bi", templength);
3854 for(l=0;l<templength;l++)
3855 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3856 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3859 fpackf(tfile, "Bi", environment);
3861 fpackf(tfile, "Bi", objects.numobjects);
3863 if(objects.numobjects)
3864 for(k=0;k<objects.numobjects;k++){
3865 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]);
3868 fpackf(tfile, "Bi", numhotspots);
3870 for(i=0;i<numhotspots;i++){
3871 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3872 templength=strlen(hotspottext[i]);
3873 fpackf(tfile, "Bi",templength);
3874 for(l=0;l<templength;l++)
3875 fpackf(tfile, "Bb", hotspottext[i][l]);
3878 fpackf(tfile, "Bi", numplayers);
3879 if(numplayers>1&&numplayers<maxplayers)
3880 for(j=1;j<numplayers;j++){
3881 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);
3882 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3883 for(k=0;k<player[j].num_weapons;k++){
3884 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3886 if(player[j].numwaypoints<30){
3887 fpackf(tfile, "Bi", player[j].numwaypoints);
3888 for(k=0;k<player[j].numwaypoints;k++){
3889 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3890 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3891 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3892 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3894 fpackf(tfile, "Bi", player[j].waypoint);
3897 player[j].numwaypoints=0;
3898 player[j].waypoint=0;
3899 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3902 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3903 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3904 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3905 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3907 if(player[j].creature==wolftype){
3908 headprop=player[j].proportionhead.x/1.1;
3909 bodyprop=player[j].proportionbody.x/1.1;
3910 armprop=player[j].proportionarms.x/1.1;
3911 legprop=player[j].proportionlegs.x/1.1;
3914 if(player[j].creature==rabbittype){
3915 headprop=player[j].proportionhead.x/1.2;
3916 bodyprop=player[j].proportionbody.x/1.05;
3917 armprop=player[j].proportionarms.x/1.00;
3918 legprop=player[j].proportionlegs.x/1.1;
3921 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3925 fpackf(tfile, "Bi", player[j].numclothes);
3926 if(player[j].numclothes)
3927 for(k=0;k<player[j].numclothes;k++){
3929 templength=strlen(player[j].clothes[k]);
3930 fpackf(tfile, "Bi", templength);
3931 for(l=0;l<templength;l++)
3932 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3933 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3937 fpackf(tfile, "Bi", numpathpoints);
3939 for(j=0;j<numpathpoints;j++){
3940 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3941 for(k=0;k<numpathpointconnect[j];k++){
3942 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3946 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3954 tfile=fopen( mapname, "wb" );
3955 fwrite( &mapvers, 1, sizeof(int), tfile );
3956 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3957 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3958 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3959 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3960 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3961 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3962 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3963 for(j=0;j<player[0].num_weapons;j++){
3964 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3967 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3968 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3969 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3970 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3971 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3972 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3973 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3974 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3975 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3976 fwrite( &player[0].power, 1, sizeof(int), tfile );
3977 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3979 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3980 if(player[0].numclothes)
3981 for(k=0;k<player[0].numclothes;k++){
3983 templength=strlen(player[0].clothes[k]);
3984 fwrite( &templength,1,sizeof(int),tfile);
3985 for(l=0;l<templength;l++)
3986 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3987 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3988 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3989 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3992 fwrite( &environment, 1, sizeof(int), tfile );
3994 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3996 for(k=0;k<objects.numobjects;k++){
3997 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3998 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3999 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
4000 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
4001 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
4002 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
4003 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
4006 fwrite( &numplayers, 1, sizeof(int), tfile );
4007 if(numplayers>1&&numplayers<maxplayers)
4008 for(j=1;j<numplayers;j++){
4009 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
4010 fwrite( &player[j].creature, 1, sizeof(int), tfile );
4011 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
4012 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
4013 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
4014 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4015 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4016 for(k=0;k<player[j].num_weapons;k++){
4017 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4019 if(player[j].numwaypoints<30){
4020 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4021 for(k=0;k<player[j].numwaypoints;k++){
4022 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
4023 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
4024 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
4026 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4027 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4030 player[j].numwaypoints=0;
4031 player[j].waypoint=0;
4032 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4033 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4034 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4036 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
4037 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
4038 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
4039 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
4040 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
4041 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
4042 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
4043 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
4044 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
4045 fwrite( &player[j].power, 1, sizeof(int), tfile );
4046 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
4048 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
4049 if(player[j].numclothes)
4050 for(k=0;k<player[j].numclothes;k++){
4052 templength=strlen(player[j].clothes[k]);
4053 fwrite( &templength,1,sizeof(int),tfile);
4054 for(l=0;l<templength;l++)
4055 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
4056 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
4057 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
4058 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
4061 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4063 for(j=0;j<numpathpoints;j++){
4064 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
4065 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
4066 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
4067 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4068 for(k=0;k<numpathpointconnect[j];k++){
4069 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4073 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
4074 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
4075 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
4077 fwrite( &mapradius, 1, sizeof(float), tfile );
4083 if(Compare(consoletext[0],"save ",0,4)){
4095 for(j=5;j<consolechars[0];j++){
4096 mapname[j-5+11]=consoletext[0][j];
4098 mapname[consolechars[0]-5+11]='\0';
4100 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
4101 FSOUND_SetVolume(channels[consolesuccesssound], 256);
4102 FSOUND_SetPaused(channels[consolesuccesssound], false);
4105 tfile=fopen( mapname, "wb" );
4106 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4107 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4108 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4109 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4110 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4111 for(j=0;j<player[0].num_weapons;j++){
4112 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4114 fwrite( &environment, 1, sizeof(int), tfile );
4116 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4117 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4118 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4119 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4120 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4122 fwrite( &numplayers, 1, sizeof(int), tfile );
4123 if(numplayers>1&&numplayers<maxplayers)
4124 for(j=1;j<numplayers;j++){
4125 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4126 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4127 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4128 for(k=0;k<player[j].num_weapons;k++){
4129 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4131 if(player[j].numwaypoints<30){
4132 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4133 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4134 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4135 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4138 player[j].numwaypoints=0;
4139 player[j].waypoint=0;
4140 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4141 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4142 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4145 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4147 for(j=0;j<numpathpoints;j++){
4148 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4149 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4150 for(k=0;k<numpathpointconnect[j];k++){
4151 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4157 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4158 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4161 /*if(Compare(consoletext[0],"Pants ",0,5)){
4162 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4163 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4167 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4168 for(j=6;j<consolechars[0];j++){
4169 mapname[j-6]=consoletext[0][j];
4172 tintr=atof(mapname);
4177 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4178 for(j=6;j<consolechars[0];j++){
4179 mapname[j-6]=consoletext[0][j];
4182 player[0].speedmult=atof(mapname);
4187 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4188 for(j=9;j<consolechars[0];j++){
4189 mapname[j-9]=consoletext[0][j];
4192 player[0].power=atof(mapname);
4197 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4198 for(j=13;j<consolechars[0];j++){
4199 mapname[j-13]=consoletext[0][j];
4202 viewdistance=atof(mapname)*100;
4207 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4208 for(j=10;j<consolechars[0];j++){
4209 mapname[j-10]=consoletext[0][j];
4212 fadestart=atof(mapname);
4217 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4218 for(j=6;j<consolechars[0];j++){
4219 mapname[j-6]=consoletext[0][j];
4222 player[0].power=atof(mapname);
4227 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4228 for(j=6;j<consolechars[0];j++){
4229 mapname[j-6]=consoletext[0][j];
4232 slomospeed=atof(mapname);
4239 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4240 for(j=8;j<consolechars[0];j++){
4241 mapname[j-8]=consoletext[0][j];
4244 slomofreq=atoi(mapname);
4249 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4250 for(j=5;j<consolechars[0];j++){
4251 mapname[j-5]=consoletext[0][j];
4254 player[0].scale=atof(mapname)*.2;
4259 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4261 float closestdist=-1;
4264 for(i=1;i<numplayers;i++){
4265 distance=findDistancefast(&player[i].coords,&player[0].coords);
4266 if(closestdist==-1||distance<closestdist){
4267 closestdist=distance;
4272 for(j=9;j<consolechars[0];j++){
4273 mapname[j-9]=consoletext[0][j];
4276 player[closest].scale=atof(mapname)*.2;
4281 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4286 float closestdist=-1;
4289 for(i=1;i<numplayers;i++){
4290 distance=findDistancefast(&player[i].coords,&player[0].coords);
4291 if(closestdist==-1||distance<closestdist){
4292 closestdist=distance;
4300 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4301 mapname[j-startpoint]=consoletext[0][j];
4303 if(consoletext[0][j]=='\0')alldone=1;
4305 mapname[j-startpoint]='\0';
4307 headprop=atof(mapname);
4311 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4312 mapname[j-startpoint]=consoletext[0][j];
4314 if(consoletext[0][j]=='\0')alldone=1;
4316 mapname[j-startpoint]='\0';
4318 bodyprop=atof(mapname);
4322 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4323 mapname[j-startpoint]=consoletext[0][j];
4325 if(consoletext[0][j]=='\0')alldone=1;
4327 mapname[j-startpoint]='\0';
4329 armprop=atof(mapname);
4333 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4334 mapname[j-startpoint]=consoletext[0][j];
4336 if(consoletext[0][j]=='\0')alldone=1;
4338 mapname[j-startpoint]='\0';
4340 legprop=atof(mapname);
4342 if(player[closest].creature==wolftype){
4343 player[closest].proportionhead=1.1*headprop;
4344 player[closest].proportionbody=1.1*bodyprop;
4345 player[closest].proportionarms=1.1*armprop;
4346 player[closest].proportionlegs=1.1*legprop;
4349 if(player[closest].creature==rabbittype){
4350 player[closest].proportionhead=1.2*headprop;
4351 player[closest].proportionbody=1.05*bodyprop;
4352 player[closest].proportionarms=1.00*armprop;
4353 player[closest].proportionlegs=1.1*legprop;
4354 player[closest].proportionlegs.y=1.05*legprop;
4361 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4362 for(i=1;i<numplayers;i++){
4363 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4369 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4370 for(j=9;j<consolechars[0];j++){
4371 mapname[j-9]=consoletext[0][j];
4374 tutoriallevel=atoi(mapname);
4380 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4381 for(j=6;j<consolechars[0];j++){
4382 mapname[j-6]=consoletext[0][j];
4385 tintg=atof(mapname);
4390 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4391 for(j=6;j<consolechars[0];j++){
4392 mapname[j-6]=consoletext[0][j];
4395 tintb=atof(mapname);
4400 if(Compare(consoletext[0],"hostile ",0,7)){
4401 for(j=8;j<consolechars[0];j++){
4402 mapname[j-8]=consoletext[0][j];
4405 hostile=atoi(mapname);
4411 if(Compare(consoletext[0],"type active ",0,11)){
4412 editoractive=typeactive;
4417 if(Compare(consoletext[0],"indemo ",0,6)){
4419 hotspot[numhotspots]=player[0].coords;
4420 hotspotsize[numhotspots]=0;
4421 hotspottype[numhotspots]=-111;
4423 strcpy(hotspottext[numhotspots],"mapname");
4429 if(Compare(consoletext[0],"notindemo ",0,9)){
4436 if(Compare(consoletext[0],"type sitting ",0,12)){
4437 editoractive=typesitting;
4442 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4443 editoractive=typesittingwall;
4448 if(Compare(consoletext[0],"type sleeping ",0,13)){
4449 editoractive=typesleeping;
4453 if(Compare(consoletext[0],"type dead1 ",0,10)){
4454 editoractive=typedead1;
4458 if(Compare(consoletext[0],"type dead2 ",0,10)){
4459 editoractive=typedead2;
4463 if(Compare(consoletext[0],"type dead3 ",0,10)){
4464 editoractive=typedead3;
4467 if(Compare(consoletext[0],"type dead4 ",0,10)){
4468 editoractive=typedead4;
4473 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4474 editorpathtype=wpkeepwalking;
4479 if(Compare(consoletext[0],"path pause ",0,10)){
4480 editorpathtype=wppause;
4485 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4486 maptype=mapkilleveryone;
4491 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4492 maptype=mapgosomewhere;
4497 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4498 maptype=mapkillsomeone;
4504 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4505 maptype=mapkillmost;
4511 if(Compare(consoletext[0],"hs ",0,2)){
4515 hotspot[numhotspots]=player[0].coords;
4520 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4521 mapname[j-startpoint]=consoletext[0][j];
4523 if(consoletext[0][j]=='\0')alldone=1;
4525 mapname[j-startpoint]='\0';
4527 hotspotsize[numhotspots]=atof(mapname);
4531 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4532 mapname[j-startpoint]=consoletext[0][j];
4534 if(consoletext[0][j]=='\0')alldone=1;
4536 mapname[j-startpoint]='\0';
4538 hotspottype[numhotspots]=atoi(mapname);
4542 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4543 mapname[j-startpoint]=consoletext[0][j];
4545 if(consoletext[0][j]=='\0')alldone=1;
4547 mapname[j-startpoint]='\n';
4548 mapname[j-startpoint+1]='\0';
4550 strcpy(hotspottext[numhotspots],mapname);
4557 if(Compare(consoletext[0],"dialogue ",0,8)){
4564 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4565 mapname[j-startpoint]=consoletext[0][j];
4567 if(consoletext[0][j]=='\0')alldone=1;
4569 mapname[j-startpoint]='\0';
4572 dialoguetype[numdialogues]=atoi(mapname);
4590 for(j=startpoint;j<consolechars[0];j++){
4591 mapname[j-startpoint+16]=consoletext[0][j];
4593 mapname[consolechars[0]-startpoint+16]='.';
4594 mapname[consolechars[0]-startpoint+17]='t';
4595 mapname[consolechars[0]-startpoint+18]='x';
4596 mapname[consolechars[0]-startpoint+19]='t';
4597 mapname[consolechars[0]-startpoint+20]='\0';
4599 for(j=0;j<max_dialoguelength;j++){
4601 dialoguetext[numdialogues][j][k]='\0';
4604 dialoguename[numdialogues][j][k]='\0';
4608 ifstream ipstream(ConvertFileName(mapname));
4609 ipstream.ignore(256,':');
4610 ipstream >> numdialogueboxes[numdialogues];
4611 for(i=0;i<numdialogueboxes[numdialogues];i++){
4612 ipstream.ignore(256,':');
4613 ipstream.ignore(256,':');
4614 ipstream.ignore(256,' ');
4615 ipstream >> dialogueboxlocation[numdialogues][i];
4616 ipstream.ignore(256,':');
4617 ipstream >> dialogueboxcolor[numdialogues][i][0];
4618 ipstream >> dialogueboxcolor[numdialogues][i][1];
4619 ipstream >> dialogueboxcolor[numdialogues][i][2];
4620 ipstream.ignore(256,':');
4621 ipstream.getline(dialoguename[numdialogues][i],64);
4622 ipstream.ignore(256,':');
4623 ipstream.ignore(256,' ');
4624 ipstream.getline(dialoguetext[numdialogues][i],128);
4626 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4628 ipstream.ignore(256,':');
4629 ipstream >> dialogueboxsound[numdialogues][i];
4632 for(i=0;i<numdialogueboxes[numdialogues];i++){
4633 for(j=0;j<numplayers;j++){
4634 participantfacing[numdialogues][i][j]=player[j].facing;
4641 whichdialogue=numdialogues;
4649 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4657 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4658 mapname[j-startpoint]=consoletext[0][j];
4660 if(consoletext[0][j]=='\0')alldone=1;
4662 mapname[j-startpoint]='\0';
4665 whichdi=atoi(mapname);
4683 for(j=startpoint;j<consolechars[0];j++){
4684 mapname[j-startpoint+16]=consoletext[0][j];
4686 mapname[consolechars[0]-startpoint+16]='.';
4687 mapname[consolechars[0]-startpoint+17]='t';
4688 mapname[consolechars[0]-startpoint+18]='x';
4689 mapname[consolechars[0]-startpoint+19]='t';
4690 mapname[consolechars[0]-startpoint+20]='\0';
4692 for(j=0;j<max_dialoguelength;j++){
4694 dialoguetext[whichdi][j][k]='\0';
4697 dialoguename[whichdi][j][k]='\0';
4701 ifstream ipstream(ConvertFileName(mapname));
4702 ipstream.ignore(256,':');
4703 ipstream >> numdialogueboxes[whichdi];
4704 for(i=0;i<numdialogueboxes[whichdi];i++){
4705 ipstream.ignore(256,':');
4706 ipstream.ignore(256,':');
4707 ipstream.ignore(256,' ');
4708 ipstream >> dialogueboxlocation[whichdi][i];
4709 ipstream.ignore(256,':');
4710 ipstream >> dialogueboxcolor[whichdi][i][0];
4711 ipstream >> dialogueboxcolor[whichdi][i][1];
4712 ipstream >> dialogueboxcolor[whichdi][i][2];
4713 ipstream.ignore(256,':');
4714 ipstream.getline(dialoguename[whichdi][i],64);
4715 ipstream.ignore(256,':');
4716 ipstream.ignore(256,' ');
4717 ipstream.getline(dialoguetext[whichdi][i],128);
4719 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4721 ipstream.ignore(256,':');
4722 ipstream >> dialogueboxsound[whichdi][i];
4730 if(Compare(consoletext[0],"fixtype ",0,7)){
4738 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4739 mapname[j-startpoint]=consoletext[0][j];
4741 if(consoletext[0][j]=='\0')alldone=1;
4743 mapname[j-startpoint]='\0';
4744 dialoguetype[0]=atoi(mapname);
4752 if(Compare(consoletext[0],"fixrotation ",0,11)){
4753 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4758 if(Compare(consoletext[0],"ddialogue ",0,9)){
4760 if(numdialogues<0)numdialogues=0;
4765 if(Compare(consoletext[0],"immobile ",0,8)){
4766 player[0].immobile=1;
4770 if(Compare(consoletext[0],"mobile ",0,6)){
4771 player[0].immobile=0;
4775 if(Compare(consoletext[0],"play ",0,4)){
4782 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4783 mapname[j-startpoint]=consoletext[0][j];
4785 if(consoletext[0][j]=='\0')alldone=1;
4787 mapname[j-startpoint]='\0';
4790 whichdialogue=atoi(mapname);
4792 if(numdialogues>whichdialogue){
4793 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4794 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4795 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4796 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4797 player[participantfocus[whichdialogue][i]].velocity=0;
4798 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4799 player[participantfocus[whichdialogue][i]].targetframe=0;
4807 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4811 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4812 temppos=temppos-viewer;
4813 Normalise(&temppos);
4823 whichsoundplay=rabbitchitter;
4824 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4825 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4826 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4827 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4828 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4829 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4830 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4831 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4832 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4833 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4834 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4835 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4836 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4837 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4838 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4839 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4840 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4841 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4842 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4843 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4844 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4845 FSOUND_SetVolume(channels[whichsoundplay], 256);
4846 FSOUND_SetPaused(channels[whichsoundplay], false);
4854 if(Compare(consoletext[0],"dhs ",0,3)){
4856 if(numhotspots<0)numhotspots=0;
4861 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4868 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4869 mapname[j-startpoint]=consoletext[0][j];
4871 if(consoletext[0][j]=='\0')alldone=1;
4873 mapname[j-startpoint]='\0';
4875 headprop=atof(mapname);
4879 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4880 mapname[j-startpoint]=consoletext[0][j];
4882 if(consoletext[0][j]=='\0')alldone=1;
4884 mapname[j-startpoint]='\0';
4886 bodyprop=atof(mapname);
4890 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4891 mapname[j-startpoint]=consoletext[0][j];
4893 if(consoletext[0][j]=='\0')alldone=1;
4895 mapname[j-startpoint]='\0';
4897 armprop=atof(mapname);
4901 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4902 mapname[j-startpoint]=consoletext[0][j];
4904 if(consoletext[0][j]=='\0')alldone=1;
4906 mapname[j-startpoint]='\0';
4908 legprop=atof(mapname);
4910 if(player[0].creature==wolftype){
4911 player[0].proportionhead=1.1*headprop;
4912 player[0].proportionbody=1.1*bodyprop;
4913 player[0].proportionarms=1.1*armprop;
4914 player[0].proportionlegs=1.1*legprop;
4917 if(player[0].creature==rabbittype){
4918 player[0].proportionhead=1.2*headprop;
4919 player[0].proportionbody=1.05*bodyprop;
4920 player[0].proportionarms=1.00*armprop;
4921 player[0].proportionlegs=1.1*legprop;
4922 player[0].proportionlegs.y=1.05*legprop;
4928 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4929 for(i=0;i<numplayers;i++){
4930 if(i>0)player[i].immobile=1;
4936 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4937 player[0].armorhead=1;
4938 player[0].armorhigh=1;
4939 player[0].armorlow=1;
4940 player[0].protectionhead=1;
4941 player[0].protectionhigh=1;
4942 player[0].protectionlow=1;
4943 player[0].metalhead=1;
4944 player[0].metalhigh=1;
4945 player[0].metallow=1;
4947 player[0].speedmult=1;
4950 if(player[0].creature==wolftype){
4951 player[0].proportionhead=1.1;
4952 player[0].proportionbody=1.1;
4953 player[0].proportionarms=1.1;
4954 player[0].proportionlegs=1.1;
4957 if(player[0].creature==rabbittype){
4958 player[0].proportionhead=1.2;
4959 player[0].proportionbody=1.05;
4960 player[0].proportionarms=1.00;
4961 player[0].proportionlegs=1.1;
4962 player[0].proportionlegs.y=1.05;
4965 player[0].numclothes=0;
4966 if(player[0].whichskin==0){
4967 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4969 else if(player[0].whichskin==1){
4970 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4972 else if(player[0].whichskin==2){
4973 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4975 else if(player[0].whichskin==3){
4976 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4978 else if(player[0].whichskin==4){
4979 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4981 else if(player[0].whichskin==5){
4982 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4984 else if(player[0].whichskin==6){
4985 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4987 else if(player[0].whichskin==7){
4988 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4990 else if(player[0].whichskin==8){
4991 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4993 else if(player[0].whichskin==9){
4994 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4997 editoractive=typeactive;
4998 player[0].immobile=0;
5005 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
5011 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5012 mapname[j-startpoint]=consoletext[0][j];
5014 if(consoletext[0][j]=='\0')alldone=1;
5016 mapname[j-startpoint]='\0';
5018 tintr=atof(mapname);
5022 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5023 mapname[j-startpoint]=consoletext[0][j];
5025 if(consoletext[0][j]=='\0')alldone=1;
5027 mapname[j-startpoint]='\0';
5029 tintg=atof(mapname);
5033 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5034 mapname[j-startpoint]=consoletext[0][j];
5036 if(consoletext[0][j]=='\0')alldone=1;
5038 mapname[j-startpoint]='\0';
5040 tintb=atof(mapname);
5045 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
5051 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5052 mapname[j-startpoint]=consoletext[0][j];
5054 if(consoletext[0][j]=='\0')alldone=1;
5056 mapname[j-startpoint]='\0';
5058 skyboxr=atof(mapname);
5062 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5063 mapname[j-startpoint]=consoletext[0][j];
5065 if(consoletext[0][j]=='\0')alldone=1;
5067 mapname[j-startpoint]='\0';
5069 skyboxg=atof(mapname);
5073 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5074 mapname[j-startpoint]=consoletext[0][j];
5076 if(consoletext[0][j]=='\0')alldone=1;
5078 mapname[j-startpoint]='\0';
5080 skyboxb=atof(mapname);
5082 skyboxlightr=skyboxr;
5083 skyboxlightg=skyboxg;
5084 skyboxlightb=skyboxb;
5088 //if(skyboxtexture){
5089 terrain.DoShadows();
5090 objects.DoShadows();
5092 else terrain.DoLighting();
5097 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5103 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5104 mapname[j-startpoint]=consoletext[0][j];
5106 if(consoletext[0][j]=='\0')alldone=1;
5108 mapname[j-startpoint]='\0';
5110 skyboxlightr=atof(mapname);
5114 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5115 mapname[j-startpoint]=consoletext[0][j];
5117 if(consoletext[0][j]=='\0')alldone=1;
5119 mapname[j-startpoint]='\0';
5121 skyboxlightg=atof(mapname);
5125 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5126 mapname[j-startpoint]=consoletext[0][j];
5128 if(consoletext[0][j]=='\0')alldone=1;
5130 mapname[j-startpoint]='\0';
5132 skyboxlightb=atof(mapname);
5136 //if(skyboxtexture){
5137 terrain.DoShadows();
5138 objects.DoShadows();
5140 else terrain.DoLighting();
5145 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5146 skyboxtexture=1-skyboxtexture;
5149 //if(skyboxtexture){
5150 terrain.DoShadows();
5151 objects.DoShadows();
5153 else terrain.DoLighting();
5158 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
5164 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5165 mapname[j-startpoint]=consoletext[0][j];
5167 if(consoletext[0][j]=='\0')alldone=1;
5169 mapname[j-startpoint]='\0';
5171 player[0].protectionhead=atof(mapname);
5175 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5176 mapname[j-startpoint]=consoletext[0][j];
5178 if(consoletext[0][j]=='\0')alldone=1;
5180 mapname[j-startpoint]='\0';
5182 player[0].protectionhigh=atof(mapname);
5186 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5187 mapname[j-startpoint]=consoletext[0][j];
5189 if(consoletext[0][j]=='\0')alldone=1;
5191 mapname[j-startpoint]='\0';
5193 player[0].protectionlow=atof(mapname);
5198 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5204 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5205 mapname[j-startpoint]=consoletext[0][j];
5207 if(consoletext[0][j]=='\0')alldone=1;
5209 mapname[j-startpoint]='\0';
5211 player[0].armorhead=atof(mapname);
5215 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5216 mapname[j-startpoint]=consoletext[0][j];
5218 if(consoletext[0][j]=='\0')alldone=1;
5220 mapname[j-startpoint]='\0';
5222 player[0].armorhigh=atof(mapname);
5226 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5227 mapname[j-startpoint]=consoletext[0][j];
5229 if(consoletext[0][j]=='\0')alldone=1;
5231 mapname[j-startpoint]='\0';
5233 player[0].armorlow=atof(mapname);
5238 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5239 for(i=0;i<numplayers;i++){
5240 player[i].protectionhead=1.0;
5241 player[i].protectionhigh=1.0;
5242 player[i].protectionlow=1.0;
5243 player[i].armorhead=1.0;
5244 player[i].armorhigh=1.0;
5245 player[i].armorlow=1.0;
5251 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5253 float closestdist=-1;
5256 for(i=1;i<numplayers;i++){
5257 distance=findDistancefast(&player[i].coords,&player[0].coords);
5258 if(closestdist==-1||distance<closestdist){
5259 closestdist=distance;
5269 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5270 mapname[j-startpoint]=consoletext[0][j];
5272 if(consoletext[0][j]=='\0')alldone=1;
5274 mapname[j-startpoint]='\0';
5276 player[closest].protectionhead=atof(mapname);
5280 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5281 mapname[j-startpoint]=consoletext[0][j];
5283 if(consoletext[0][j]=='\0')alldone=1;
5285 mapname[j-startpoint]='\0';
5287 player[closest].protectionhigh=atof(mapname);
5291 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5292 mapname[j-startpoint]=consoletext[0][j];
5294 if(consoletext[0][j]=='\0')alldone=1;
5296 mapname[j-startpoint]='\0';
5298 player[closest].protectionlow=atof(mapname);
5303 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5305 float closestdist=-1;
5308 for(i=1;i<numplayers;i++){
5309 distance=findDistancefast(&player[i].coords,&player[0].coords);
5310 if(closestdist==-1||distance<closestdist){
5311 closestdist=distance;
5320 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5321 mapname[j-startpoint]=consoletext[0][j];
5323 if(consoletext[0][j]=='\0')alldone=1;
5325 mapname[j-startpoint]='\0';
5327 player[closest].armorhead=atof(mapname);
5331 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5332 mapname[j-startpoint]=consoletext[0][j];
5334 if(consoletext[0][j]=='\0')alldone=1;
5336 mapname[j-startpoint]='\0';
5338 player[closest].armorhigh=atof(mapname);
5342 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5343 mapname[j-startpoint]=consoletext[0][j];
5345 if(consoletext[0][j]=='\0')alldone=1;
5347 mapname[j-startpoint]='\0';
5349 player[closest].armorlow=atof(mapname);
5355 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5361 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5362 mapname[j-startpoint]=consoletext[0][j];
5364 if(consoletext[0][j]=='\0')alldone=1;
5366 mapname[j-startpoint]='\0';
5368 player[0].metalhead=atof(mapname);
5372 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5373 mapname[j-startpoint]=consoletext[0][j];
5375 if(consoletext[0][j]=='\0')alldone=1;
5377 mapname[j-startpoint]='\0';
5379 player[0].metalhigh=atof(mapname);
5383 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5384 mapname[j-startpoint]=consoletext[0][j];
5386 if(consoletext[0][j]=='\0')alldone=1;
5389 mapname[j-startpoint]='\0';
5391 player[0].metallow=atof(mapname);
5396 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5398 float closestdist=-1;
5401 for(i=1;i<numplayers;i++){
5402 distance=findDistancefast(&player[i].coords,&player[0].coords);
5403 if(closestdist==-1||distance<closestdist){
5404 closestdist=distance;
5408 player[closest].numclothes=0;
5409 if(player[closest].whichskin==0){
5410 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5412 else if(player[closest].whichskin==1){
5413 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5415 else if(player[closest].whichskin==2){
5416 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5418 else if(player[closest].whichskin==3){
5419 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5421 else if(player[closest].whichskin==4){
5422 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5424 else if(player[closest].whichskin==5){
5425 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5427 else if(player[closest].whichskin==6){
5428 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5430 else if(player[closest].whichskin==7){
5431 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5433 else if(player[closest].whichskin==8){
5434 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5436 else if(player[closest].whichskin==9){
5437 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5443 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5446 player[closest].numclothes=0;
5447 if(player[closest].whichskin==0){
5448 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5450 else if(player[closest].whichskin==1){
5451 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5453 else if(player[closest].whichskin==2){
5454 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5456 else if(player[closest].whichskin==3){
5457 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5459 else if(player[closest].whichskin==4){
5460 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5462 else if(player[closest].whichskin==5){
5463 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5465 else if(player[closest].whichskin==6){
5466 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5468 else if(player[closest].whichskin==7){
5469 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5471 else if(player[closest].whichskin==8){
5472 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5474 else if(player[closest].whichskin==9){
5475 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5481 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5497 for(j=8;j<consolechars[0];j++){
5498 mapname[j-8+15]=consoletext[0][j];
5500 mapname[consolechars[0]-8+15]='.';
5501 mapname[consolechars[0]-8+16]='p';
5502 mapname[consolechars[0]-8+17]='n';
5503 mapname[consolechars[0]-8+18]='g';
5504 mapname[consolechars[0]-8+19]='\0';
5506 //:Data:Textures:Pants.png
5508 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5509 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5510 strcpy(player[0].clothes[player[0].numclothes],mapname);
5511 player[0].clothestintr[player[0].numclothes]=tintr;
5512 player[0].clothestintg[player[0].numclothes]=tintg;
5513 player[0].clothestintb[player[0].numclothes]=tintb;
5514 player[0].numclothes++;
5520 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5521 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5526 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5527 cellophane=1-cellophane;
5530 for(i=0;i<numplayers;i++){
5531 player[i].proportionhead.z=0;
5532 player[i].proportionbody.z=0;
5533 player[i].proportionarms.z=0;
5534 player[i].proportionlegs.z=0;
5539 for(i=0;i<numplayers;i++){
5540 player[i].proportionhead.z=player[i].proportionhead.x;
5541 player[i].proportionbody.z=player[i].proportionbody.x;
5542 player[i].proportionarms.z=player[i].proportionarms.x;
5543 player[i].proportionlegs.z=player[i].proportionlegs.x;
5550 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5566 for(j=12;j<consolechars[0];j++){
5567 mapname[j-12+15]=consoletext[0][j];
5569 mapname[consolechars[0]-12+15]='.';
5570 mapname[consolechars[0]-12+16]='p';
5571 mapname[consolechars[0]-12+17]='n';
5572 mapname[consolechars[0]-12+18]='g';
5573 mapname[consolechars[0]-12+19]='\0';
5575 //:Data:Textures:Pants.png
5577 float closestdist=-1;
5580 for(i=1;i<numplayers;i++){
5581 distance=findDistancefast(&player[i].coords,&player[0].coords);
5582 if(closestdist==-1||distance<closestdist){
5583 closestdist=distance;
5588 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5589 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5590 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5591 player[closest].clothestintr[player[closest].numclothes]=tintr;
5592 player[closest].clothestintg[player[closest].numclothes]=tintg;
5593 player[closest].clothestintb[player[closest].numclothes]=tintb;
5594 player[closest].numclothes++;
5600 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5601 player[0].skeleton.id=0;
5602 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);
5603 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5604 player[0].creature=rabbittype;
5607 player[0].proportionhead=1.2;
5608 player[0].proportionbody=1.05;
5609 player[0].proportionarms=1.00;
5610 player[0].proportionlegs=1.1;
5611 player[0].proportionlegs.y=1.05;
5612 player[0].headless=0;
5614 player[0].damagetolerance=200;
5618 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5619 player[0].skeleton.id=0;
5620 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);
5621 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5622 player[0].creature=wolftype;
5624 player[0].proportionhead=1.1;
5625 player[0].proportionbody=1.1;
5626 player[0].proportionarms=1.1;
5627 player[0].proportionlegs=1.1;
5628 player[0].proportionlegs.y=1.1;
5629 player[0].scale=.23;
5631 player[0].damagetolerance=300;
5635 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5636 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5639 if(Compare(consoletext[0],"rambo ",0,5)){
5640 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5643 if(Compare(consoletext[0],"david ",0,5)){
5644 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5647 if(Compare(consoletext[0],"wolf ",0,4)){
5648 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5651 if(Compare(consoletext[0],"darkwolf ",0,8)){
5652 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5655 if(Compare(consoletext[0],"snowwolf ",0,8)){
5656 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5659 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5660 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5663 if(Compare(consoletext[0],"white ",0,5)){
5664 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5667 if(Compare(consoletext[0],"brown ",0,5)){
5668 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5671 if(Compare(consoletext[0],"black ",0,5)){
5672 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5675 if(consolechars[0]>0){
5678 consoletext[k][j]=consoletext[k-1][j];
5680 consolechars[k]=consolechars[k-1];
5683 consoletext[0][j]=' ';
5689 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5690 FSOUND_SetVolume(channels[consolefailsound], 256);
5691 FSOUND_SetPaused(channels[consolefailsound], false);
5700 togglekeydelay[i]=0;
5704 consoleblinkdelay-=multiplier;
5705 if(consoleblinkdelay<=0){
5706 consoleblinkdelay=.3;
5707 consoleblink=1-consoleblink;
5711 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5714 if(newdetail>2)newdetail=detail;
5715 if(newdetail<0)newdetail=detail;
5716 #if !USE_SDL // we'll take anything that works.
5717 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5718 if(newscreenheight>3000)newscreenheight=screenheight;
5720 if(newscreenwidth<0)newscreenwidth=screenwidth;
5721 if(newscreenheight<0)newscreenheight=screenheight;
5723 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5724 opstream << "Screenwidth:\n";
5725 opstream << newscreenwidth;
5726 opstream << "\nScreenheight:\n";
5727 opstream << newscreenheight;
5728 opstream << "\nMouse sensitivity:\n";
5729 opstream << usermousesensitivity;
5730 opstream << "\nBlur(0,1):\n";
5731 opstream << ismotionblur;
5732 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5733 opstream << newdetail;
5734 opstream << "\nFloating jump:\n";
5735 opstream << floatjump;
5736 opstream << "\nMouse jump:\n";
5737 opstream << mousejump;
5738 opstream << "\nAmbient sound:\n";
5739 opstream << ambientsound;
5740 opstream << "\nBlood (0,1,2):\n";
5741 opstream << bloodtoggle;
5742 opstream << "\nAuto slomo:\n";
5743 opstream << autoslomo;
5744 opstream << "\nFoliage:\n";
5745 opstream << foliage;
5746 opstream << "\nMusic:\n";
5747 opstream << musictoggle;
5748 opstream << "\nTrilinear:\n";
5749 opstream << trilinear;
5750 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5752 opstream << "\nInvert mouse:\n";
5753 opstream << invertmouse;
5754 opstream << "\nGamespeed:\n";
5755 if(oldgamespeed==0)oldgamespeed=1;
5756 opstream << oldgamespeed;
5757 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5758 opstream << difficulty;
5759 opstream << "\nDamage effects(blackout, doublevision):\n";
5760 opstream << damageeffects;
5761 opstream << "\nText:\n";
5762 opstream << texttoggle;
5763 opstream << "\nDebug:\n";
5764 opstream << debugmode;
5765 opstream << "\nVBL Sync:\n";
5766 opstream << vblsync;
5767 opstream << "\nShow Points:\n";
5768 opstream << showpoints;
5769 opstream << "\nAlways Blur:\n";
5770 opstream << alwaysblur;
5771 opstream << "\nImmediate mode (turn on on G5):\n";
5772 opstream << immediate;
5773 opstream << "\nVelocity blur:\n";
5774 opstream << velocityblur;
5775 opstream << "\nVolume:\n";
5777 opstream << "\nForward key:\n";
5778 opstream << KeyToChar(forwardkey);
5779 opstream << "\nBack key:\n";
5780 opstream << KeyToChar(backkey);
5781 opstream << "\nLeft key:\n";
5782 opstream << KeyToChar(leftkey);
5783 opstream << "\nRight key:\n";
5784 opstream << KeyToChar(rightkey);
5785 opstream << "\nJump key:\n";
5786 opstream << KeyToChar(jumpkey);
5787 opstream << "\nCrouch key:\n";
5788 opstream << KeyToChar(crouchkey);
5789 opstream << "\nDraw key:\n";
5790 opstream << KeyToChar(drawkey);
5791 opstream << "\nThrow key:\n";
5792 opstream << KeyToChar(throwkey);
5793 opstream << "\nAttack key:\n";
5794 opstream << KeyToChar(attackkey);
5795 opstream << "\nChat key:\n";
5796 opstream << KeyToChar(chatkey);
5801 static int oldwinfreeze;
5802 if(winfreeze&&!oldwinfreeze){
5803 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
5804 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5805 FSOUND_SetVolume(channels[consolesuccesssound], 256);
5806 FSOUND_SetPaused(channels[consolesuccesssound], false);
5808 if(winfreeze==0)oldwinfreeze=winfreeze;
5809 else oldwinfreeze++;
5811 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5812 if(winfreeze)winfreeze=0;
5815 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5821 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5824 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5826 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5828 static bool oldbuttondialogue;
5830 if(indialogue!=-1)talkdelay=1;
5831 talkdelay-=multiplier;
5834 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5835 for(i=0;i<numdialogues;i++){
5836 int realdialoguetype;
5838 if(dialoguetype[i]>49){
5839 realdialoguetype=dialoguetype[i]-50;
5842 else if(dialoguetype[i]>39){
5843 realdialoguetype=dialoguetype[i]-40;
5846 else if(dialoguetype[i]>29){
5847 realdialoguetype=dialoguetype[i]-30;
5850 else if(dialoguetype[i]>19){
5851 realdialoguetype=dialoguetype[i]-20;
5854 else if(dialoguetype[i]>9){
5855 realdialoguetype=dialoguetype[i]-10;
5859 realdialoguetype=dialoguetype[i];
5862 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5863 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5865 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5866 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5867 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5868 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5869 player[participantfocus[whichdialogue][j]].velocity=0;
5870 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5871 player[participantfocus[whichdialogue][j]].targetframe=0;
5876 dialoguegonethrough[i]++;
5877 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5878 static float gLoc[3];
5879 static float vel[3];
5881 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5882 temppos=temppos-viewer;
5883 Normalise(&temppos);
5888 gLoc[2]=temppos.z;vel[0]=0;
5892 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5893 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5894 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5895 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5896 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5897 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5898 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5899 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5900 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5901 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5902 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5903 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5904 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5905 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5906 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5907 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5908 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5909 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5910 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5911 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5912 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5913 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5914 FSOUND_SetVolume(channels[whichsoundplay], 256);
5915 FSOUND_SetPaused(channels[whichsoundplay], false);
5917 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5922 windvar+=multiplier;
5923 smoketex+=multiplier;
5924 tutorialstagetime+=multiplier;
5926 static float hotspotvisual[40];
5930 for(i=0;i<numhotspots;i++)
5931 hotspotvisual[i]-=multiplier/320;
5933 for(i=0;i<numhotspots;i++){
5934 //if(hotspottype[i]<=10)
5935 while(hotspotvisual[i]<0){
5937 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5938 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5939 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5940 hotspotsprite+=hotspot[i];
5941 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5942 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5946 for(i=0;i<numhotspots;i++){
5947 if(hotspottype[i]<=10&&hotspottype[i]>0){
5948 hotspot[i]=player[hotspottype[i]].coords;
5954 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5957 if(tutorialstage<=1){
5962 if(tutorialstage==1){
5965 if(tutorialstage==2){
5968 if(tutorialstage==3){
5969 tutorialmaxtime=600;
5971 if(tutorialstage==4){
5972 tutorialmaxtime=1000;
5974 if(tutorialstage==5){
5975 tutorialmaxtime=600;
5977 if(tutorialstage==6){
5978 tutorialmaxtime=600;
5980 if(tutorialstage==7){
5981 tutorialmaxtime=600;
5983 if(tutorialstage==8){
5984 tutorialmaxtime=600;
5986 if(tutorialstage==9){
5987 tutorialmaxtime=600;
5989 if(tutorialstage==10){
5992 if(tutorialstage==11){
5993 tutorialmaxtime=1000;
5995 if(tutorialstage==12){
5996 tutorialmaxtime=1000;
5998 if(tutorialstage==13){
6001 if(tutorialstage==14){
6013 player[1].coords=(temp+temp2)/2;
6017 gLoc[0]=player[1].coords.x;
6018 gLoc[1]=player[1].coords.y;
6019 gLoc[2]=player[1].coords.z;
6023 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6024 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6025 FSOUND_SetVolume(channels[fireendsound], 256);
6026 FSOUND_SetPaused(channels[fireendsound], false);
6028 for(i=0;i<player[1].skeleton.num_joints;i++){
6030 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6031 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6032 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;
6033 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6034 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6039 if(tutorialstage==15){
6040 tutorialmaxtime=500;
6042 if(tutorialstage==16){
6043 tutorialmaxtime=500;
6045 if(tutorialstage==17){
6046 tutorialmaxtime=500;
6048 if(tutorialstage==18){
6049 tutorialmaxtime=500;
6051 if(tutorialstage==19){
6053 //tutorialmaxtime=500;
6055 if(tutorialstage==20){
6056 tutorialmaxtime=500;
6058 if(tutorialstage==21){
6059 tutorialmaxtime=500;
6066 if(tutorialstage==22){
6067 tutorialmaxtime=500;
6069 if(tutorialstage==23){
6070 tutorialmaxtime=500;
6072 if(tutorialstage==24){
6073 tutorialmaxtime=500;
6075 if(tutorialstage==25){
6076 tutorialmaxtime=500;
6078 if(tutorialstage==26){
6081 if(tutorialstage==27){
6085 player[1].aitype=attacktypecutoff;
6087 if(tutorialstage==28){
6088 tutorialmaxtime=400;
6090 if(tutorialstage==29){
6091 tutorialmaxtime=400;
6092 player[0].escapednum=0;
6094 if(tutorialstage==30){
6098 player[1].aitype=passivetype;
6100 if(tutorialstage==31){
6103 if(tutorialstage==32){
6106 if(tutorialstage==33){
6107 tutorialmaxtime=400;
6110 player[1].aitype=attacktypecutoff;
6112 if(tutorialstage==34){
6113 tutorialmaxtime=400;
6115 if(tutorialstage==35){
6116 tutorialmaxtime=400;
6118 if(tutorialstage==36){
6122 player[1].aitype=passivetype;
6124 if(tutorialstage==37){
6130 player[1].aitype=attacktypecutoff;
6132 if(tutorialstage==38){
6136 player[1].aitype=passivetype;
6138 if(tutorialstage==39){
6149 weapons.owner[weapons.numweapons]=-1;
6150 weapons.type[weapons.numweapons]=knife;
6151 weapons.damage[weapons.numweapons]=0;
6152 weapons.mass[weapons.numweapons]=1;
6153 weapons.tipmass[weapons.numweapons]=1.2;
6154 weapons.length[weapons.numweapons]=.25;
6155 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6156 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6158 weapons.velocity[weapons.numweapons]=0.1;
6159 weapons.tipvelocity[weapons.numweapons]=0.1;
6160 weapons.missed[weapons.numweapons]=1;
6161 weapons.hitsomething[weapons.numweapons]=0;
6162 weapons.freetime[weapons.numweapons]=0;
6163 weapons.firstfree[weapons.numweapons]=1;
6164 weapons.physics[weapons.numweapons]=1;
6166 weapons.numweapons++;
6168 if(tutorialstage==40){
6169 tutorialmaxtime=300;
6171 if(tutorialstage==41){
6172 tutorialmaxtime=300;
6174 if(tutorialstage==42){
6177 if(tutorialstage==43){
6178 tutorialmaxtime=300;
6180 if(tutorialstage==44){
6182 player[0].weaponactive=-1;
6183 player[0].num_weapons=0;
6184 player[1].weaponactive=0;
6185 player[1].num_weapons=1;
6186 player[1].weaponids[0]=0;
6190 player[1].aitype=attacktypecutoff;
6192 tutorialmaxtime=300;
6194 if(tutorialstage==45){
6196 player[0].weaponactive=-1;
6197 player[0].num_weapons=0;
6198 player[1].weaponactive=0;
6199 player[1].num_weapons=1;
6200 player[1].weaponids[0]=0;
6202 tutorialmaxtime=300;
6204 if(tutorialstage==46){
6206 player[0].weaponactive=-1;
6207 player[0].num_weapons=0;
6208 player[1].weaponactive=0;
6209 player[1].num_weapons=1;
6210 player[1].weaponids[0]=0;
6212 weapons.type[0]=sword;
6214 tutorialmaxtime=300;
6217 if(tutorialstage==47){
6229 weapons.owner[weapons.numweapons]=-1;
6230 weapons.type[weapons.numweapons]=sword;
6231 weapons.damage[weapons.numweapons]=0;
6232 weapons.mass[weapons.numweapons]=1;
6233 weapons.tipmass[weapons.numweapons]=1.2;
6234 weapons.length[weapons.numweapons]=.25;
6235 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6236 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6238 weapons.velocity[weapons.numweapons]=0.1;
6239 weapons.tipvelocity[weapons.numweapons]=0.1;
6240 weapons.missed[weapons.numweapons]=1;
6241 weapons.hitsomething[weapons.numweapons]=0;
6242 weapons.freetime[weapons.numweapons]=0;
6243 weapons.firstfree[weapons.numweapons]=1;
6244 weapons.physics[weapons.numweapons]=1;
6248 player[0].weaponactive=0;
6249 player[0].num_weapons=1;
6250 player[0].weaponids[0]=1;
6251 player[1].weaponactive=0;
6252 player[1].num_weapons=1;
6253 player[1].weaponids[0]=0;
6255 weapons.numweapons++;
6257 if(tutorialstage==48){
6260 player[1].aitype=passivetype;
6266 player[0].weaponactive=0;
6267 player[0].num_weapons=1;
6268 player[0].weaponids[0]=1;
6269 player[1].weaponactive=0;
6270 player[1].num_weapons=1;
6271 player[1].weaponids[0]=0;
6273 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6274 else weapons.type[0]=staff;
6276 weapons.numweapons++;
6278 if(tutorialstage==49){
6281 player[1].aitype=passivetype;
6283 tutorialmaxtime=200;
6285 weapons.position[1]=1000;
6286 weapons.tippoint[1]=1000;
6288 weapons.numweapons=1;
6290 player[1].weaponactive=-1;
6291 player[1].num_weapons=0;
6292 player[0].weaponactive=0;
6293 player[0].num_weapons=1;
6294 player[0].weaponids[0]=0;
6296 weapons.type[0]=knife;
6298 weapons.numweapons++;
6300 if(tutorialstage==50){
6306 gLoc[0]=player[1].coords.x;
6307 gLoc[1]=player[1].coords.y;
6308 gLoc[2]=player[1].coords.z;
6312 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6313 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6314 FSOUND_SetVolume(channels[fireendsound], 256);
6315 FSOUND_SetPaused(channels[fireendsound], false);
6317 for(i=0;i<player[1].skeleton.num_joints;i++){
6319 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6320 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6321 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;
6322 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6323 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6327 player[1].num_weapons=0;
6328 player[1].weaponstuck=-1;
6329 player[1].weaponactive=-1;
6331 weapons.numweapons=0;
6333 weapons.owner[0]=-1;
6334 weapons.velocity[0]=0.1;
6335 weapons.tipvelocity[0]=-0.1;
6336 weapons.missed[0]=1;
6337 weapons.hitsomething[0]=0;
6338 weapons.freetime[0]=0;
6339 weapons.firstfree[0]=1;
6340 weapons.physics[0]=1;
6342 if(tutorialstage==51){
6343 tutorialmaxtime=80000;
6345 if(tutorialstage<=51)tutorialstagetime=0;
6349 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6350 if(tutorialstage==3){
6351 if(deltah||deltav)tutorialsuccess+=multiplier;
6353 if(tutorialstage==4){
6354 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6356 if(tutorialstage==5){
6357 if(player[0].jumpkeydown)tutorialsuccess=1;
6359 if(tutorialstage==6){
6360 if(player[0].isCrouch())tutorialsuccess=1;
6362 if(tutorialstage==7){
6363 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6365 if(tutorialstage==8){
6366 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6368 if(tutorialstage==9){
6369 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6371 if(tutorialstage==11){
6372 if(player[0].isWallJump())tutorialsuccess=1;
6374 if(tutorialstage==12){
6375 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6377 if(tutorialstage==15){
6378 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6380 if(tutorialstage==16){
6381 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6383 if(tutorialstage==17){
6384 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6386 if(tutorialstage==18){
6387 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6389 if(tutorialstage==19){
6390 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6392 if(tutorialstage==20){
6393 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6395 if(tutorialstage==21){
6396 if(bonus==cannon)tutorialsuccess=1;
6398 if(tutorialstage==22){
6399 if(bonus==spinecrusher)tutorialsuccess=1;
6401 if(tutorialstage==23){
6402 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6404 if(tutorialstage==24){
6405 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6407 if(tutorialstage==25){
6408 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6410 if(tutorialstage==28){
6411 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6413 if(tutorialstage==29){
6414 if(player[0].escapednum==2){
6418 player[1].aitype=passivetype;
6421 if(tutorialstage==33){
6422 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6424 if(tutorialstage==34){
6425 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6427 if(tutorialstage==35){
6428 if(animation[player[0].targetanimation].attack==reversal){
6432 player[1].aitype=passivetype;
6435 if(tutorialstage==40){
6436 if(player[0].num_weapons>0)tutorialsuccess=1;
6438 if(tutorialstage==41){
6439 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6441 if(tutorialstage==43){
6442 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6444 if(tutorialstage==44){
6445 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6447 if(tutorialstage==45){
6448 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6450 if(tutorialstage==46){
6451 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6453 if(tutorialstage==49){
6454 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6456 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6459 if(tutorialstagetime==tutorialmaxtime-3){
6460 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6461 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6462 FSOUND_SetPaused(channels[consolesuccesssound], false);
6465 if(tutorialsuccess>=1){
6466 if(tutorialstage==34||tutorialstage==35)
6467 tutorialstagetime=tutorialmaxtime-1;
6472 if(tutorialstage<14||tutorialstage>=50){
6473 player[1].coords.y=300;
6474 player[1].velocity=0;
6478 if(tutoriallevel!=1){
6479 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6480 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6481 FSOUND_SetVolume(channels[consolesuccesssound], 256);
6482 FSOUND_SetPaused(channels[consolesuccesssound], false);
6487 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6488 FSOUND_SetVolume(channels[fireendsound], 256);
6489 FSOUND_SetPaused(channels[fireendsound], false);
6492 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6493 else bonusnum[bonus]+=0.15;
6494 if(tutoriallevel)bonusvalue=0;
6495 bonusvalue/=bonusnum[bonus];
6496 bonustotal+=bonusvalue;
6498 bonustime+=multiplier;
6500 if(environment==snowyenvironment){
6501 precipdelay-=multiplier;
6502 while(precipdelay<0){
6504 if(!detail)precipdelay+=.04;
6505 XYZ footvel,footpoint;
6508 footpoint=viewer+viewerfacing*6;
6509 footpoint.y+=((float)abs(Random()%1200))/100-6;
6510 footpoint.x+=((float)abs(Random()%1200))/100-6;
6511 footpoint.z+=((float)abs(Random()%1200))/100-6;
6512 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6515 for(k=0;k<numplayers;k++){
6516 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6517 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6519 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){
6520 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6521 else if(player[k].rotation>player[k].targetrotation){
6522 player[k].rotation-=multiplier*player[k].turnspeed;
6524 else if(player[k].rotation<player[k].targetrotation){
6525 player[k].rotation+=multiplier*player[k].turnspeed;
6530 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))){
6531 player[k].turnspeed*=2;
6532 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6533 else if(player[k].rotation>player[k].targetrotation){
6534 player[k].rotation-=multiplier*player[k].turnspeed;
6536 else if(player[k].rotation<player[k].targetrotation){
6537 player[k].rotation+=multiplier*player[k].turnspeed;
6539 player[k].turnspeed/=2;
6542 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6543 player[k].turnspeed*=4;
6544 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6545 else if(player[k].rotation>player[k].targetrotation){
6546 player[k].rotation-=multiplier*player[k].turnspeed;
6548 else if(player[k].rotation<player[k].targetrotation){
6549 player[k].rotation+=multiplier*player[k].turnspeed;
6551 player[k].turnspeed/=4;
6554 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6555 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6557 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6558 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6561 if(player[k].collide<-.3)player[k].collide=-.3;
6562 if(player[k].collide>1)player[k].collide=1;
6563 player[k].collide-=multiplier*30;
6565 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6566 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6568 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6569 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6570 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6571 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6572 lowpoint=player[k].coords;
6573 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6574 else lowpoint.y+=1.3;
6575 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){
6576 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6578 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6579 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6581 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6582 flatfacing=lowpoint-player[k].coords;
6583 player[k].coords=lowpoint;
6584 player[k].coords.y-=1.3;
6585 player[k].collide=1;
6587 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6588 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6589 tempcoords1=lowpoint;
6590 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6591 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6593 player[k].targetanimation=walljumpleftanim;
6594 player[k].targetframe=0;
6597 gLoc[0]=player[k].coords.x;
6598 gLoc[1]=player[k].coords.y;
6599 gLoc[2]=player[k].coords.z;
6603 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6604 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6605 FSOUND_SetVolume(channels[movewhooshsound], 256);
6606 FSOUND_SetPaused(channels[movewhooshsound], false);
6607 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6609 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6610 player[k].rotation=-asin(0-lowpointtarget.x);
6611 player[k].rotation*=360/6.28;
6612 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6613 player[k].targetrotation=player[k].rotation;
6614 player[k].lowrotation=player[k].rotation;
6615 if(k==0)numwallflipped++;
6619 lowpoint=tempcoords1;
6620 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6621 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6622 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6624 player[k].targetanimation=walljumprightanim;
6625 player[k].targetframe=0;
6628 gLoc[0]=player[k].coords.x;
6629 gLoc[1]=player[k].coords.y;
6630 gLoc[2]=player[k].coords.z;
6634 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6635 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6636 FSOUND_SetVolume(channels[movewhooshsound], 256);
6637 FSOUND_SetPaused(channels[movewhooshsound], false);
6638 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6640 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6641 player[k].rotation=-asin(0-lowpointtarget.x);
6642 player[k].rotation*=360/6.28;
6643 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6644 player[k].targetrotation=player[k].rotation;
6645 player[k].lowrotation=player[k].rotation;
6646 if(k==0)numwallflipped++;
6650 lowpoint=tempcoords1;
6651 lowpointtarget=lowpoint+player[k].facing*2;
6652 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6653 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6655 player[k].targetanimation=walljumpbackanim;
6656 player[k].targetframe=0;
6659 gLoc[0]=player[k].coords.x;
6660 gLoc[1]=player[k].coords.y;
6661 gLoc[2]=player[k].coords.z;
6665 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6666 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6667 FSOUND_SetVolume(channels[movewhooshsound], 256);
6668 FSOUND_SetPaused(channels[movewhooshsound], false);
6669 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6671 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6672 player[k].rotation=-asin(0-lowpointtarget.x);
6673 player[k].rotation*=360/6.28;
6674 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6675 player[k].targetrotation=player[k].rotation;
6676 player[k].lowrotation=player[k].rotation;
6677 if(k==0)numwallflipped++;
6681 lowpoint=tempcoords1;
6682 lowpointtarget=lowpoint-player[k].facing*2;
6683 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6684 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6686 player[k].targetanimation=walljumpfrontanim;
6687 player[k].targetframe=0;
6690 gLoc[0]=player[k].coords.x;
6691 gLoc[1]=player[k].coords.y;
6692 gLoc[2]=player[k].coords.z;
6696 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6697 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6698 FSOUND_SetVolume(channels[movewhooshsound], 256);
6699 FSOUND_SetPaused(channels[movewhooshsound], false);
6700 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6702 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6703 player[k].rotation=-asin(0-lowpointtarget.x);
6704 player[k].rotation*=360/6.28;
6705 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6706 player[k].rotation+=180;
6707 player[k].targetrotation=player[k].rotation;
6708 player[k].lowrotation=player[k].rotation;
6709 if(k==0)numwallflipped++;
6717 else if(objects.type[i]==rocktype){
6718 lowpoint2=player[k].coords;
6719 lowpoint=player[k].coords;
6721 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6722 player[k].coords=colpoint;
6723 player[k].collide=1;
6726 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6727 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6729 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6731 player[k].targetframe=0;
6732 player[k].onterrain=1;
6734 if(player[k].id==0){
6735 FSOUND_SetPaused(channels[whooshsound], true);
6736 FSOUND_SetVolume(channels[whooshsound], 0);
6739 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6740 if(player[k].isFlip())player[k].jumppower=-4;
6741 player[k].targetanimation=player[k].getLanding();
6744 gLoc[0]=player[k].coords.x;
6745 gLoc[1]=player[k].coords.y;
6746 gLoc[2]=player[k].coords.z;
6747 vel[0]=player[k].velocity.x;
6748 vel[1]=player[k].velocity.y;
6749 vel[2]=player[k].velocity.z;
6750 PlaySoundEx( landsound, samp[landsound], NULL, true);
6751 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6752 FSOUND_SetVolume(channels[landsound], 128);
6753 FSOUND_SetPaused(channels[landsound], false);
6755 envsound[numenvsounds]=player[k].coords;
6756 envsoundvol[numenvsounds]=16;
6757 envsoundlife[numenvsounds]=.4;
6766 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6767 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6768 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6769 lowpoint=player[k].coords;
6771 if(objects.type[i]!=rocktype)
6772 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6773 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6774 player[k].coords=lowpoint;
6775 player[k].coords.y-=1.35;
6776 player[k].collide=1;
6778 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)){
6779 lowpoint=player[k].coords;
6780 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6781 lowpoint=player[k].coords;
6785 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6786 lowpointtarget=lowpoint+facing*1.4;
6787 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6789 lowpoint=player[k].coords;
6791 lowpointtarget=lowpoint+facing*1.4;
6793 lowpointtarget2=lowpointtarget;
6795 lowpointtarget3=lowpointtarget;
6797 lowpointtarget4=lowpointtarget;
6799 lowpointtarget5=lowpointtarget;
6801 lowpointtarget6=lowpointtarget;
6803 lowpointtarget7=lowpoint;
6805 lowpointtarget2.x+=.1;
6807 lowpointtarget3.z+=.1;
6809 lowpointtarget4.x-=.1;
6811 lowpointtarget5.z-=.1;
6813 lowpointtarget6.y+=45/13;
6814 lowpointtarget6+=facing*.6;
6815 lowpointtarget7.y+=90/13;
6816 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6817 if(objects.friction[i]>.5)
6820 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6821 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6822 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6823 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)
6825 lowpoint=player[k].coords;
6826 lowpoint.y+=(float)j/13;
6827 lowpointtarget=lowpoint+facing*1.4;
6828 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6832 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6835 if(j<=25&&player[k].targetanimation==jumpdownanim){
6838 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6839 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6840 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)*/){
6841 lowpoint=player[k].coords;
6842 lowpoint.y+=(float)j/13;
6843 lowpointtarget=lowpoint+facing*1.3;
6844 flatfacing=player[k].coords;
6845 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6846 player[k].coords.y=lowpointtarget.y-.07;
6847 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6849 if(j>10||!player[k].isRun()){
6850 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6851 if(k==0)FSOUND_SetPaused(channels[whooshsound], true);
6855 gLoc[0]=player[k].coords.x;
6856 gLoc[1]=player[k].coords.y;
6857 gLoc[2]=player[k].coords.z;
6858 vel[0]=player[k].velocity.x;
6859 vel[1]=player[k].velocity.y;
6860 vel[2]=player[k].velocity.z;
6861 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6862 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6863 FSOUND_SetVolume(channels[jumpsound], 128);
6864 FSOUND_SetPaused(channels[jumpsound], false);
6866 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6867 player[k].rotation=-asin(0-lowpointtarget.x);
6868 player[k].rotation*=360/6.28;
6869 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6870 player[k].targetrotation=player[k].rotation;
6871 player[k].lowrotation=player[k].rotation;
6873 //player[k].velocity=lowpointtarget*.03;
6874 player[k].velocity=0;
6876 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6877 //player[k].currentanimation=climbanim;
6878 player[k].targetanimation=climbanim;
6879 player[k].jumppower=0;
6880 player[k].jumpclimb=1;
6882 player[k].transspeed=6;
6885 //player[k].currentframe=1;
6886 player[k].targetframe=1;
6888 //player[k].currentframe=0;
6889 player[k].targetframe=0;
6890 //player[k].currentanimation=hanganim;
6891 player[k].targetanimation=hanganim;
6892 player[k].jumppower=0;
6906 if(player[k].collide<=0){
6907 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()){
6908 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)){
6909 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6910 player[k].targetanimation=jumpdownanim;
6911 player[k].targetframe=0;
6916 gLoc[0]=player[k].coords.x;
6917 gLoc[1]=player[k].coords.y;
6918 gLoc[2]=player[k].coords.z;
6919 vel[0]=player[k].velocity.x;
6920 vel[1]=player[k].velocity.y;
6921 vel[2]=player[k].velocity.z;
6923 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6924 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6925 FSOUND_SetVolume(channels[whooshsound], 128);
6926 FSOUND_SetPaused(channels[whooshsound], false);
6929 player[k].velocity.y+=gravity;
6934 player[k].realoldcoords=player[k].coords;
6937 static XYZ oldviewer;
6940 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6941 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6942 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6943 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6944 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6945 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6946 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6947 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6951 player[0].forwardkeydown=0;
6952 player[0].leftkeydown=0;
6953 player[0].backkeydown=0;
6954 player[0].rightkeydown=0;
6955 player[0].jumpkeydown=0;
6956 player[0].crouchkeydown=0;
6957 player[0].drawkeydown=0;
6958 player[0].throwkeydown=0;
6961 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6964 static bool endkeydown;
6971 facing=DoRotation(facing,-rotation2,0,0);
6972 facing=DoRotation(facing,0,0-rotation,0);
6977 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6979 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6980 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6981 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6982 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6983 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6984 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6985 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)
6986 ||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)
6987 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6989 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6990 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6991 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6992 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6993 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6994 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6995 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6996 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6997 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6998 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6999 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
7001 participantfocus[whichdialogue][indialogue]=whichend;
7002 participantlocation[whichdialogue][whichend]=player[whichend].coords;
7003 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
7006 participantfocus[whichdialogue][indialogue]=-1;
7008 if(player[participantfocus[whichdialogue][indialogue]].dead){
7013 dialoguecamera[whichdialogue][indialogue]=viewer;
7014 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
7015 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
7017 if(indialogue<numdialogueboxes[whichdialogue]){
7018 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7019 static float gLoc[3];
7020 static float vel[3];
7022 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7023 temppos=temppos-viewer;
7024 Normalise(&temppos);
7029 gLoc[2]=temppos.z;vel[0]=0;
7033 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7034 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7035 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7036 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7037 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7038 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7039 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7040 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7041 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7042 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7043 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7044 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7045 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7046 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7047 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7048 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7049 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7050 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7051 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7052 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7053 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
7054 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7055 FSOUND_SetVolume(channels[whichsoundplay], 256);
7056 FSOUND_SetPaused(channels[whichsoundplay], false);
7060 for(j=0;j<numplayers;j++){
7061 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
7066 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)
7067 ||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)
7070 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
7071 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
7072 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
7073 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
7074 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
7075 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
7076 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
7077 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
7078 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
7079 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
7080 participantfacing[whichdialogue][indialogue][whichend]=facing;
7082 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)
7083 &&!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)
7084 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7087 if(indialogue>=numdialogueboxes[whichdialogue]){
7094 FSOUND_SetPaused(channels[whooshsound], true);
7095 viewer=dialoguecamera[whichdialogue][indialogue];
7096 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7097 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7099 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7100 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7101 if(dialoguetime>0.5)
7102 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)
7103 ||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)
7104 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7107 if(indialogue<numdialogueboxes[whichdialogue]){
7108 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7109 static float gLoc[3];
7110 static float vel[3];
7112 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7113 temppos=temppos-viewer;
7114 Normalise(&temppos);
7119 gLoc[2]=temppos.z;vel[0]=0;
7123 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7124 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7125 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7126 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7127 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7128 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7129 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7130 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7131 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7132 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7133 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7134 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7135 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7136 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7137 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7138 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7139 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7140 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7141 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7142 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7143 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7144 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7145 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
7146 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7147 FSOUND_SetVolume(channels[whichsoundplay], 256);
7148 FSOUND_SetPaused(channels[whichsoundplay], false);
7150 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7151 hotspot[numhotspots]=player[0].coords;
7152 hotspotsize[numhotspots]=10;
7153 hotspottype[numhotspots]=-1;
7157 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7161 if(player[participantfocus[whichdialogue][indialogue]].dead){
7169 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)
7170 &&!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)
7171 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7174 if(indialogue>=numdialogueboxes[whichdialogue]){
7178 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7181 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7184 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7186 for(i=1;i<numplayers;i++){
7187 player[i].aitype = attacktypecutoff;
7194 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7195 else oldbuttondialogue=1;
7197 static float keyrefreshdelay=0,bigrefreshdelay=0;
7201 /*keyrefreshdelay-=multiplier;
7202 bigrefreshdelay-=multiplier;
7204 if(keyrefreshdelay<=0){
7205 static int concat[4];
7207 concat[0]=player[0].forwardkeydown;
7208 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7209 concat[0]=concat[0]*2+player[0].rightkeydown;
7210 concat[0]=concat[0]*2+player[0].leftkeydown;
7211 concat[0]=concat[0]*2+player[0].backkeydown;
7212 concat[0]=concat[0]*2+player[0].jumpkeydown;
7213 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7214 concat[0]=concat[0]*2+player[0].crouchkeydown;
7216 concat[1]=player[0].crouchtogglekeydown;
7217 concat[1]=concat[1]*2+player[0].drawkeydown;
7218 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7219 concat[1]=concat[1]*2+player[0].throwkeydown;
7220 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7221 concat[1]=concat[1]*2+player[0].attackkeydown;
7223 //concat[2]=(char)((int)(rotation/2)%180);
7225 //concat[3]=(char)((int)(rotation2/2)%180);
7227 chatname[0]=concat[0]-128;
7228 chatname[1]=concat[1]-128;
7229 //chatname[2]=concat[2]-128;
7230 //chatname[3]=concat[3]-128;
7232 memcpy(chatname+temppoint,&rotation,sizeof(float));
7233 temppoint+=sizeof(float);
7234 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7235 temppoint+=sizeof(float);
7237 chatname[temppoint]='\0';
7239 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7240 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7241 //keyrefreshdelay=.01;
7242 keyrefreshdelay=.03;
7245 if(bigrefreshdelay<=0){
7248 memcpy(chatname+temppoint,&i,sizeof(int));
7249 temppoint+=sizeof(int);
7250 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7251 temppoint+=sizeof(float);
7252 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7253 temppoint+=sizeof(float);
7254 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7255 temppoint+=sizeof(float);
7256 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7257 temppoint+=sizeof(float);
7258 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7259 temppoint+=sizeof(float);
7260 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7261 temppoint+=sizeof(int);
7262 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7263 temppoint+=sizeof(int);
7264 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7265 temppoint+=sizeof(float);
7266 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7267 temppoint+=sizeof(float);
7268 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7269 temppoint+=sizeof(float);
7270 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7271 temppoint+=sizeof(int);
7272 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7273 temppoint+=sizeof(int);
7274 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7275 temppoint+=sizeof(float);
7276 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7277 temppoint+=sizeof(float);
7278 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7279 temppoint+=sizeof(float);
7280 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7281 temppoint+=sizeof(int);
7282 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7283 temppoint+=sizeof(int);
7284 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7285 temppoint+=sizeof(int);
7286 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7287 temppoint+=sizeof(int);
7288 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7289 temppoint+=sizeof(int);
7290 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7291 temppoint+=sizeof(int);
7292 chatname[temppoint]='\0';
7294 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);
7295 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7296 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7298 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);
7300 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7301 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7303 //bigrefreshdelay=.02;
7308 if(!player[0].jumpkeydown){
7309 player[0].jumptogglekeydown=0;
7311 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7314 dialoguetime+=multiplier;
7315 skybox.cloudmove+=multiplier;
7316 hawkrotation+=multiplier*25;
7318 realhawkcoords.x=25;
7319 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7320 hawkcalldelay-=multiplier/2;
7322 if(hawkcalldelay<=0)
7324 static float gLoc[3];
7325 static float vel[3];
7326 gLoc[0]=realhawkcoords.x;
7327 gLoc[1]=realhawkcoords.y;
7328 gLoc[2]=realhawkcoords.z;
7332 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
7333 FSOUND_3D_SetAttributes(channels[hawksound], gLoc, vel);
7334 FSOUND_SetVolume(channels[hawksound], 128);
7335 FSOUND_SetPaused(channels[hawksound], false);
7337 hawkcalldelay=16+abs(Random()%8);
7339 static float temptexdetail;
7342 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7343 player[0].damagetolerance=200000;
7346 player[0].permanentdamage=0;
7347 player[0].superpermanentdamage=0;
7350 whichchar = abs(Random()%7);
7351 registrationname[whichchar]+=1;
7355 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7357 if(environment>2)environment=0;
7358 Setenvironment(environment);
7364 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7368 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7369 cameramode=1-cameramode;
7370 cameratogglekeydown=1;
7373 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7374 cameratogglekeydown=0;
7377 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7378 if(player[0].num_weapons>0){
7379 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7380 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7381 else weapons.type[player[0].weaponids[0]]=sword;
7382 if(weapons.type[player[0].weaponids[0]]==sword){
7383 weapons.mass[player[0].weaponids[0]]=1.5;
7384 weapons.tipmass[player[0].weaponids[0]]=1;
7385 weapons.length[player[0].weaponids[0]]=.8;
7387 if(weapons.type[player[0].weaponids[0]]==staff){
7388 weapons.mass[player[0].weaponids[0]]=2;
7389 weapons.tipmass[player[0].weaponids[0]]=1;
7390 weapons.length[player[0].weaponids[0]]=1.5;
7393 if(weapons.type[player[0].weaponids[0]]==knife){
7394 weapons.mass[player[0].weaponids[0]]=1;
7395 weapons.tipmass[player[0].weaponids[0]]=1.2;
7396 weapons.length[player[0].weaponids[0]]=.25;
7400 /*for(i=0;i<objects.numobjects;i++){
7401 if(objects.type[i]==treeleavestype){
7402 for(j=0;j<objects.numobjects;j++){
7403 if(objects.type[j]==treetrunktype)
7404 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7405 objects.scale[i]=objects.scale[j];
7409 detailtogglekeydown=1;
7412 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7414 float closestdist=-1;
7417 for(i=1;i<numplayers;i++){
7418 distance=findDistancefast(&player[i].coords,&player[0].coords);
7419 if(closestdist==-1||distance<closestdist){
7420 closestdist=distance;
7425 if(player[closest].num_weapons)
7427 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7428 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7429 else weapons.type[player[closest].weaponids[0]]=sword;
7430 if(weapons.type[player[closest].weaponids[0]]==sword){
7431 weapons.mass[player[closest].weaponids[0]]=1.5;
7432 weapons.tipmass[player[closest].weaponids[0]]=1;
7433 weapons.length[player[closest].weaponids[0]]=.8;
7435 if(weapons.type[player[0].weaponids[0]]==staff){
7436 weapons.mass[player[0].weaponids[0]]=2;
7437 weapons.tipmass[player[0].weaponids[0]]=1;
7438 weapons.length[player[0].weaponids[0]]=1.5;
7440 if(weapons.type[player[closest].weaponids[0]]==knife){
7441 weapons.mass[player[closest].weaponids[0]]=1;
7442 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7443 weapons.length[player[closest].weaponids[0]]=.25;
7446 if(!player[closest].num_weapons)
7448 player[closest].weaponids[0]=weapons.numweapons;
7449 weapons.owner[weapons.numweapons]=closest;
7450 weapons.type[weapons.numweapons]=knife;
7451 weapons.damage[weapons.numweapons]=0;
7452 weapons.numweapons++;
7453 player[closest].num_weapons=1;
7454 if(weapons.type[player[closest].weaponids[0]]==sword){
7455 weapons.mass[player[closest].weaponids[0]]=1.5;
7456 weapons.tipmass[player[closest].weaponids[0]]=1;
7457 weapons.length[player[closest].weaponids[0]]=.8;
7459 if(weapons.type[player[closest].weaponids[0]]==knife){
7460 weapons.mass[player[closest].weaponids[0]]=1;
7461 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7462 weapons.length[player[closest].weaponids[0]]=.25;
7466 detailtogglekeydown=1;
7469 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7471 float closestdist=-1;
7474 for(i=1;i<numplayers;i++){
7475 distance=findDistancefast(&player[i].coords,&player[0].coords);
7476 if(closestdist==-1||distance<closestdist){
7477 closestdist=distance;
7482 player[closest].rotation+=multiplier*50;
7483 player[closest].targetrotation=player[closest].rotation;
7487 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7489 float closestdist=-1;
7492 for(i=1;i<numplayers;i++){
7493 distance=findDistancefast(&player[i].coords,&player[0].coords);
7494 if(closestdist==-1||distance<closestdist){
7495 closestdist=distance;
7499 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7502 player[closest].whichskin++;
7503 if(player[closest].whichskin>9)player[closest].whichskin=0;
7504 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7506 if(player[closest].creature==rabbittype){
7507 if(player[closest].whichskin==0){
7508 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7510 else if(player[closest].whichskin==1){
7511 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7513 else if(player[closest].whichskin==2){
7514 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7516 else if(player[closest].whichskin==3){
7517 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7519 else if(player[closest].whichskin==4){
7520 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7522 else if(player[closest].whichskin==5){
7523 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7525 else if(player[closest].whichskin==6){
7526 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7528 else if(player[closest].whichskin==7){
7529 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7531 else if(player[closest].whichskin==8){
7532 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7534 else if(player[closest].whichskin==9){
7535 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7538 if(player[closest].creature==wolftype){
7540 if(player[closest].whichskin==0){
7541 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7543 else if(player[closest].whichskin==1){
7544 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7546 else if(player[closest].whichskin==2){
7547 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7552 if(player[closest].numclothes){
7553 for(i=0;i<player[closest].numclothes;i++){
7554 tintr=player[closest].clothestintr[i];
7555 tintg=player[closest].clothestintg[i];
7556 tintb=player[closest].clothestintb[i];
7557 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7559 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7562 detailtogglekeydown=1;
7565 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7567 float closestdist=-1;
7570 for(i=1;i<numplayers;i++){
7571 distance=findDistancefast(&player[i].coords,&player[0].coords);
7572 if(closestdist==-1||distance<closestdist){
7573 closestdist=distance;
7578 if(player[closest].creature==wolftype){
7579 headprop=player[closest].proportionhead.x/1.1;
7580 bodyprop=player[closest].proportionbody.x/1.1;
7581 armprop=player[closest].proportionarms.x/1.1;
7582 legprop=player[closest].proportionlegs.x/1.1;
7585 if(player[closest].creature==rabbittype){
7586 headprop=player[closest].proportionhead.x/1.2;
7587 bodyprop=player[closest].proportionbody.x/1.05;
7588 armprop=player[closest].proportionarms.x/1.00;
7589 legprop=player[closest].proportionlegs.x/1.1;
7593 if(player[closest].creature==rabbittype){
7594 player[closest].skeleton.id=closest;
7595 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);
7596 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7597 player[closest].whichskin=0;
7598 player[closest].creature=wolftype;
7600 player[closest].proportionhead=1.1;
7601 player[closest].proportionbody=1.1;
7602 player[closest].proportionarms=1.1;
7603 player[closest].proportionlegs=1.1;
7604 player[closest].proportionlegs.y=1.1;
7605 player[closest].scale=.23*5*player[0].scale;
7607 player[closest].damagetolerance=300;
7611 player[closest].skeleton.id=closest;
7612 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);
7613 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7614 player[closest].whichskin=0;
7615 player[closest].creature=rabbittype;
7617 player[closest].proportionhead=1.2;
7618 player[closest].proportionbody=1.05;
7619 player[closest].proportionarms=1.00;
7620 player[closest].proportionlegs=1.1;
7621 player[closest].proportionlegs.y=1.05;
7622 player[closest].scale=.2*5*player[0].scale;
7624 player[closest].damagetolerance=200;
7627 if(player[closest].creature==wolftype){
7628 player[closest].proportionhead=1.1*headprop;
7629 player[closest].proportionbody=1.1*bodyprop;
7630 player[closest].proportionarms=1.1*armprop;
7631 player[closest].proportionlegs=1.1*legprop;
7634 if(player[closest].creature==rabbittype){
7635 player[closest].proportionhead=1.2*headprop;
7636 player[closest].proportionbody=1.05*bodyprop;
7637 player[closest].proportionarms=1.00*armprop;
7638 player[closest].proportionlegs=1.1*legprop;
7639 player[closest].proportionlegs.y=1.05*legprop;
7643 detailtogglekeydown=1;
7646 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7647 detailtogglekeydown=0;
7650 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7653 slomotogglekeydown=1;
7657 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7659 float closestdist=-1;
7661 XYZ flatfacing2,flatvelocity2;
7664 for(i=1;i<numplayers;i++){
7665 distance=findDistancefast(&player[i].coords,&player[0].coords);
7666 if(distance<144&&!player[i].headless)
7667 if(closestdist==-1||distance<closestdist){
7668 closestdist=distance;
7670 blah = player[i].coords;
7675 XYZ headspurtdirection;
7676 int i = player[closest].skeleton.jointlabels[head];
7677 for(k=0;k<player[closest].skeleton.num_joints; k++){
7678 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7679 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7680 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;
7681 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7682 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7683 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7684 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7685 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7686 Normalise(&headspurtdirection);
7687 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7688 flatvelocity2+=headspurtdirection*8;
7689 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7691 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7701 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7702 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7703 FSOUND_SetVolume(channels[splattersound], 256);
7704 FSOUND_SetPaused(channels[splattersound], false);
7706 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7707 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7708 FSOUND_SetVolume(channels[breaksound2], 100);
7709 FSOUND_SetPaused(channels[breaksound2], false);
7711 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7712 player[closest].RagDoll(0);
7713 player[closest].dead=2;
7714 player[closest].headless=1;
7715 player[closest].DoBloodBig(3,165);
7720 explodetogglekeydown=1;
7723 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7725 float closestdist=-1;
7727 XYZ flatfacing2,flatvelocity2;
7730 for(i=1;i<numplayers;i++){
7731 distance=findDistancefast(&player[i].coords,&player[0].coords);
7733 if(closestdist==-1||distance<closestdist){
7734 closestdist=distance;
7736 blah=player[i].coords;
7750 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7751 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
7752 FSOUND_SetVolume(channels[splattersound], 256);
7753 FSOUND_SetPaused(channels[splattersound], false);
7755 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7756 FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7757 FSOUND_SetVolume(channels[breaksound2], 600);
7758 FSOUND_SetPaused(channels[breaksound2], false);
7760 for(i=0;i<player[closest].skeleton.num_joints; i++){
7761 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7762 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7763 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;
7764 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7765 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7766 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7767 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7768 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7769 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7770 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7773 for(i=0;i<player[closest].skeleton.num_joints; i++){
7774 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7775 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7776 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;
7777 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7778 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7779 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7780 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7781 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7782 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7785 for(i=0;i<player[closest].skeleton.num_joints; i++){
7786 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7787 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7788 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;
7789 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7790 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7791 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7792 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7793 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7794 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7797 for(i=0;i<player[closest].skeleton.num_joints; i++){
7798 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7799 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7800 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;
7801 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7802 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7803 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7804 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7805 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7806 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7810 for(j=0;j<numplayers; j++){
7812 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7813 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7814 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7815 player[j].skeleton.longdead=0;
7816 player[j].RagDoll(0);
7817 for(i=0;i<player[j].skeleton.num_joints; i++){
7818 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7819 if(findDistancefast(&temppos,&player[closest].coords)<25){
7820 flatvelocity2=temppos-player[closest].coords;
7821 Normalise(&flatvelocity2);
7822 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7829 player[closest].DoDamage(10000);
7830 player[closest].RagDoll(0);
7831 player[closest].dead=2;
7832 player[closest].coords=20;
7833 player[closest].skeleton.free=2;
7839 explodetogglekeydown=1;
7842 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7843 explodetogglekeydown=0;
7847 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7849 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7850 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7851 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7852 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7853 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7854 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7855 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7857 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7858 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7859 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7860 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7861 for(j=0;j<player[0].num_weapons;j++){
7862 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7864 fwrite( &environment, 1, sizeof(int), tfile );
7866 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7867 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7868 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7869 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7870 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7872 fwrite( &numplayers, 1, sizeof(int), tfile );
7873 if(numplayers>1&&numplayers<maxplayers)
7874 for(i=1;i<numplayers;i++){
7875 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7876 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7877 for(j=0;j<player[i].num_weapons;j++){
7878 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7880 if(player[i].numwaypoints<30){
7881 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7882 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7883 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7884 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7887 player[i].numwaypoints=0;
7888 player[i].waypoint=0;
7889 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7890 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7891 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7897 slomotogglekeydown=1;
7900 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7901 slomotogglekeydown=0;
7905 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7906 player[0].onfire=1-player[0].onfire;
7907 if(player[0].onfire){
7908 player[0].CatchFire();
7910 if(!player[0].onfire){
7913 gLoc[0]=player[0].coords.x;
7914 gLoc[1]=player[0].coords.y;
7915 gLoc[2]=player[0].coords.z;
7919 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7920 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7921 FSOUND_SetVolume(channels[fireendsound], 256);
7922 FSOUND_SetPaused(channels[fireendsound], false);
7923 FSOUND_SetPaused(channels[stream_firesound], true);
7925 slomotogglekeydown=1;
7928 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7929 if(player[0].bleeding<=0)
7930 player[0].DoBlood(1,255);
7934 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7936 float closestdist=-1;
7939 for(i=1;i<numplayers;i++){
7940 distance=findDistancefast(&player[i].coords,&player[0].coords);
7941 if(closestdist==-1||distance<closestdist){
7942 closestdist=distance;
7946 if(closestdist>0&&closest>=0){
7947 //player[closest]=player[numplayers-1];
7948 //player[closest].skeleton=player[numplayers-1].skeleton;
7951 drawmodetogglekeydown=1;
7954 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7956 float closestdist=-1;
7959 for(i=1;i<max_objects;i++){
7960 distance=findDistancefast(&objects.position[i],&player[0].coords);
7961 if(closestdist==-1||distance<closestdist){
7962 closestdist=distance;
7966 if(closestdist>0&&closest>=0){
7967 objects.position[closest].y-=500;
7969 drawmodetogglekeydown=1;
7972 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7974 //if(drawmode>2)drawmode=0;
7975 if(objects.numobjects<max_objects-1){
7977 boxcoords.x=player[0].coords.x;
7978 boxcoords.z=player[0].coords.z;
7979 boxcoords.y=player[0].coords.y-3;
7980 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7981 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7982 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7983 float temprotat,temprotat2;
7984 temprotat=editorrotation;
7985 temprotat2=editorrotation2;
7986 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7987 if(temprotat2<0)temprotat2=Random()%360;
7989 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7990 if(editortype==treetrunktype)
7991 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7994 drawmodetogglekeydown=1;
7997 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7998 if(numplayers<maxplayers-1){
7999 player[numplayers].scale=.2*5*player[0].scale;
8000 player[numplayers].creature=rabbittype;
8001 player[numplayers].howactive=editoractive;
8002 player[numplayers].skeleton.id=numplayers;
8003 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);
8005 //texsize=512*512*3/texdetail/texdetail;
8006 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
8007 //player[numplayers].skeleton.skinText.resize(texsize);
8009 k=abs(Random()%2)+1;
8011 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8012 player[numplayers].whichskin=0;
8015 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8016 player[numplayers].whichskin=1;
8019 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8020 player[numplayers].whichskin=2;
8023 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
8024 player[numplayers].power=1;
8025 player[numplayers].speedmult=1;
8026 player[numplayers].currentanimation=bounceidleanim;
8027 player[numplayers].targetanimation=bounceidleanim;
8028 player[numplayers].currentframe=0;
8029 player[numplayers].targetframe=1;
8030 player[numplayers].target=0;
8031 player[numplayers].bled=0;
8032 player[numplayers].speed=1+(float)(Random()%100)/1000;
8034 player[numplayers].targetrotation=player[0].targetrotation;
8035 player[numplayers].rotation=player[0].rotation;
8037 player[numplayers].velocity=0;
8038 player[numplayers].coords=player[0].coords;
8039 player[numplayers].oldcoords=player[numplayers].coords;
8040 player[numplayers].realoldcoords=player[numplayers].coords;
8042 player[numplayers].id=numplayers;
8043 player[numplayers].skeleton.id=numplayers;
8044 player[numplayers].updatedelay=0;
8045 player[numplayers].normalsupdatedelay=0;
8047 player[numplayers].aitype=passivetype;
8048 player[numplayers].aitarget=0;
8050 if(player[0].creature==wolftype){
8051 headprop=player[0].proportionhead.x/1.1;
8052 bodyprop=player[0].proportionbody.x/1.1;
8053 armprop=player[0].proportionarms.x/1.1;
8054 legprop=player[0].proportionlegs.x/1.1;
8057 if(player[0].creature==rabbittype){
8058 headprop=player[0].proportionhead.x/1.2;
8059 bodyprop=player[0].proportionbody.x/1.05;
8060 armprop=player[0].proportionarms.x/1.00;
8061 legprop=player[0].proportionlegs.x/1.1;
8064 if(player[numplayers].creature==wolftype){
8065 player[numplayers].proportionhead=1.1*headprop;
8066 player[numplayers].proportionbody=1.1*bodyprop;
8067 player[numplayers].proportionarms=1.1*armprop;
8068 player[numplayers].proportionlegs=1.1*legprop;
8071 if(player[numplayers].creature==rabbittype){
8072 player[numplayers].proportionhead=1.2*headprop;
8073 player[numplayers].proportionbody=1.05*bodyprop;
8074 player[numplayers].proportionarms=1.00*armprop;
8075 player[numplayers].proportionlegs=1.1*legprop;
8076 player[numplayers].proportionlegs.y=1.05*legprop;
8079 player[numplayers].headless=0;
8080 player[numplayers].onfire=0;
8083 player[numplayers].proportionhead.z=0;
8084 player[numplayers].proportionbody.z=0;
8085 player[numplayers].proportionarms.z=0;
8086 player[numplayers].proportionlegs.z=0;
8089 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
8091 player[numplayers].damagetolerance=200;
8093 player[numplayers].protectionhead=player[0].protectionhead;
8094 player[numplayers].protectionhigh=player[0].protectionhigh;
8095 player[numplayers].protectionlow=player[0].protectionlow;
8096 player[numplayers].armorhead=player[0].armorhead;
8097 player[numplayers].armorhigh=player[0].armorhigh;
8098 player[numplayers].armorlow=player[0].armorlow;
8099 player[numplayers].metalhead=player[0].metalhead;
8100 player[numplayers].metalhigh=player[0].metalhigh;
8101 player[numplayers].metallow=player[0].metallow;
8103 player[numplayers].immobile=player[0].immobile;
8105 player[numplayers].numclothes=player[0].numclothes;
8106 if(player[numplayers].numclothes)
8107 for(i=0;i<player[numplayers].numclothes;i++){
8108 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8109 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8110 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8111 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8112 tintr=player[numplayers].clothestintr[i];
8113 tintg=player[numplayers].clothestintg[i];
8114 tintb=player[numplayers].clothestintb[i];
8115 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8117 if(player[numplayers].numclothes){
8118 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8121 player[numplayers].power=player[0].power;
8122 player[numplayers].speedmult=player[0].speedmult;
8124 player[numplayers].damage=0;
8125 player[numplayers].permanentdamage=0;
8126 player[numplayers].superpermanentdamage=0;
8127 player[numplayers].deathbleeding=0;
8128 player[numplayers].bleeding=0;
8129 player[numplayers].numwaypoints=0;
8130 player[numplayers].waypoint=0;
8131 player[numplayers].jumppath=0;
8132 player[numplayers].weaponstuck=-1;
8133 player[numplayers].weaponactive=-1;
8134 player[numplayers].num_weapons=0;
8135 player[numplayers].bloodloss=0;
8136 player[numplayers].dead=0;
8138 player[numplayers].loaded=1;
8142 drawmodetogglekeydown=1;
8145 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8146 if(player[numplayers-1].numwaypoints<90){
8147 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8148 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8149 player[numplayers-1].numwaypoints++;
8151 drawmodetogglekeydown=1;
8154 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8155 if(numpathpoints<30){
8156 bool connected,alreadyconnected;
8159 for(i=0;i<numpathpoints;i++){
8160 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8162 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8163 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8165 if(!alreadyconnected){
8166 numpathpointconnect[pathpointselected]++;
8168 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8174 pathpoint[numpathpoints-1]=player[0].coords;
8175 numpathpointconnect[numpathpoints-1]=0;
8176 if(numpathpoints>1&&pathpointselected!=-1){
8177 numpathpointconnect[pathpointselected]++;
8178 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8180 pathpointselected=numpathpoints-1;
8183 drawmodetogglekeydown=1;
8186 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8187 pathpointselected++;
8188 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8189 drawmodetogglekeydown=1;
8191 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8192 pathpointselected--;
8193 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8194 drawmodetogglekeydown=1;
8196 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8197 if(pathpointselected!=-1){
8199 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8200 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8201 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8202 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8204 for(i=0;i<numpathpoints;i++){
8205 for(j=0;j<numpathpointconnect[i];j++){
8206 if(pathpointconnect[i][j]==pathpointselected){
8207 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8208 numpathpointconnect[i]--;
8210 if(pathpointconnect[i][j]==numpathpoints){
8211 pathpointconnect[i][j]=pathpointselected;
8215 pathpointselected=numpathpoints-1;
8217 drawmodetogglekeydown=1;
8220 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8221 editorenabled=1-editorenabled;
8223 player[0].damagetolerance=100000;
8225 player[0].superpermanentdamage=0;
8226 player[0].bloodloss=0;
8227 player[0].deathbleeding=0;
8230 player[0].damagetolerance=200;
8232 player[0].permanentdamage=0;
8233 player[0].superpermanentdamage=0;
8234 player[0].bloodloss=0;
8235 player[0].deathbleeding=0;
8237 drawmodetogglekeydown=1;
8240 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8242 if(editortype==treeleavestype||editortype==10)editortype--;
8243 if(editortype<0)editortype=firetype;
8244 drawmodetogglekeydown=1;
8247 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8249 if(editortype==treeleavestype||editortype==10)editortype++;
8250 if(editortype>firetype)editortype=0;
8251 drawmodetogglekeydown=1;
8254 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8255 editorrotation-=multiplier*100;
8256 if(editorrotation<-.01)editorrotation=-.01;
8257 drawmodetogglekeydown=1;
8260 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8261 editorrotation+=multiplier*100;
8262 drawmodetogglekeydown=1;
8265 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8266 editorsize+=multiplier;
8267 drawmodetogglekeydown=1;
8270 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8271 editorsize-=multiplier;
8272 if(editorsize<.1)editorsize=.1;
8273 drawmodetogglekeydown=1;
8277 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8278 mapradius-=multiplier*10;
8281 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8282 mapradius+=multiplier*10;
8285 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8286 mapcenter.x+=multiplier*20;
8289 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8290 mapcenter.x-=multiplier*20;
8293 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8294 mapcenter.z+=multiplier*20;
8297 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8298 mapcenter.z-=multiplier*20;
8301 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8302 editorrotation2+=multiplier*100;
8305 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8306 editorrotation2-=multiplier*100;
8307 if(editorrotation2<-.01)editorrotation2=-.01;
8309 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8311 float closestdist=-1;
8313 for(i=0;i<objects.numobjects;i++){
8314 distance=findDistancefast(&objects.position[i],&player[0].coords);
8315 if(closestdist==-1||distance<closestdist){
8316 closestdist=distance;
8320 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8321 drawmodetogglekeydown=1;
8325 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)){
8326 drawmodetogglekeydown=0;
8329 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8330 //if(!player[0].skeleton.free)player[0].damage+=500;
8331 player[0].RagDoll(0);
8332 //player[0].spurt=1;
8333 //player[0].DoDamage(1000);
8337 gLoc[0]=player[0].coords.x;
8338 gLoc[1]=player[0].coords.y;
8339 gLoc[2]=player[0].coords.z;
8340 vel[0]=player[0].velocity.x;
8341 vel[1]=player[0].velocity.y;
8342 vel[2]=player[0].velocity.z;
8343 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
8344 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8345 FSOUND_SetVolume(channels[whooshsound], 128);
8346 FSOUND_SetPaused(channels[whooshsound], false);
8347 //FSOUND_SetPaused(channels[whooshsound], true);
8349 texturesizetogglekeydown=1;
8352 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8355 float closestdist=-1;
8357 for(i=0;i<objects.numobjects;i++){
8358 if(objects.type[i]==treeleavestype){
8359 objects.scale[i]*=.9;
8362 texturesizetogglekeydown=1;
8365 static XYZ relative;
8366 static int randattack;
8368 static bool playerrealattackkeydown=0;
8370 if(!buttons[0])oldbutton=0;
8371 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8372 if(oldattackkey)player[0].attackkeydown=0;
8373 if(oldattackkey)playerrealattackkeydown=0;
8374 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8375 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);
8376 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8377 for(k=0;k<numplayers;k++){
8378 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8379 player[k].Reverse();
8383 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8385 for(k=0;k<numplayers;k++){
8386 if(indialogue!=-1)player[k].attackkeydown=0;
8387 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8388 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8389 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)){
8390 player[k].jumppower-=2;
8392 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)){
8393 for(i=0;i<numplayers;i++){
8395 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8396 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8397 player[k].targetanimation=dodgebackanim;
8399 player[k].targetframe=0;
8400 rotatetarget=player[i].coords-player[k].coords;
8401 Normalise(&rotatetarget);
8402 player[k].targetrotation=-asin(0-rotatetarget.x);
8403 player[k].targetrotation*=360/6.28;
8404 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8406 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8409 if(player[k].targetanimation!=dodgebackanim){
8410 if(k==0)numflipped++;
8411 player[k].targetanimation=backhandspringanim;
8413 player[k].targetframe=0;
8414 player[k].targetrotation=-rotation+180;
8415 if(player[k].leftkeydown)player[k].targetrotation-=45;
8416 if(player[k].rightkeydown)player[k].targetrotation+=45;
8417 player[k].rotation=player[k].targetrotation;
8418 player[k].jumppower-=2;
8421 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())){
8422 player[k].hasvictim=0;
8424 for(i=0;i<numplayers;i++){
8426 if(!player[k].hasvictim)
8427 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8428 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){
8429 player[k].victim=&player[i];
8430 player[k].hasvictim=1;
8431 if(player[k].aitype==playercontrolled){
8432 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;
8433 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;
8434 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;
8435 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;
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&&!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;
8437 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;
8438 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;
8439 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;
8440 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;
8441 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;
8444 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8445 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8446 else randattack=abs(Random()%5);
8447 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8448 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8449 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8450 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8451 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8453 if(player[k].weaponactive!=-1){
8454 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;
8455 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;
8456 //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;
8457 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;
8458 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;
8459 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;
8460 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;
8461 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;
8465 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8467 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)){
8468 if(player[k].weaponactive==-1){
8469 player[i].targetanimation=sneakattackedanim;
8470 player[i].currentanimation=sneakattackedanim;
8471 player[k].currentanimation=sneakattackanim;
8472 player[k].targetanimation=sneakattackanim;
8473 player[k].oldcoords=player[k].coords;
8474 player[k].coords=player[i].coords;
8476 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8477 player[i].targetanimation=knifesneakattackedanim;
8478 player[i].currentanimation=knifesneakattackedanim;
8479 player[k].currentanimation=knifesneakattackanim;
8480 player[k].targetanimation=knifesneakattackanim;
8481 player[i].oldcoords=player[i].coords;
8482 player[i].coords=player[k].coords;
8484 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8485 player[i].targetanimation=swordsneakattackedanim;
8486 player[i].currentanimation=swordsneakattackedanim;
8487 player[k].currentanimation=swordsneakattackanim;
8488 player[k].targetanimation=swordsneakattackanim;
8489 player[i].oldcoords=player[i].coords;
8490 player[i].coords=player[k].coords;
8492 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8493 player[k].victim=&player[i];
8494 player[k].hasvictim=1;
8495 player[i].targettilt2=0;
8496 player[i].targetframe=1;
8497 player[i].currentframe=0;
8499 player[i].velocity=0;
8500 player[k].targettilt2=player[i].targettilt2;
8501 player[k].currentframe=player[i].currentframe;
8502 player[k].targetframe=player[i].targetframe;
8503 player[k].target=player[i].target;
8504 player[k].velocity=0;
8505 player[k].targetrotation=player[i].rotation;
8506 player[k].rotation=player[i].rotation;
8507 player[i].targetrotation=player[i].rotation;
8510 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8512 player[k].targetframe=0;
8514 //player[k].velocity=0;
8516 rotatetarget=player[i].coords-player[k].coords;
8517 Normalise(&rotatetarget);
8518 player[k].targetrotation=-asin(0-rotatetarget.x);
8519 player[k].targetrotation*=360/6.28;
8520 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8522 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8524 player[k].lastattack3=player[k].lastattack2;
8525 player[k].lastattack2=player[k].lastattack;
8526 player[k].lastattack=player[k].targetanimation;
8527 //player[k].targettilt2=0;
8531 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8532 rotatetarget=player[i].coords-player[k].coords;
8533 Normalise(&rotatetarget);
8534 player[k].targetrotation=-asin(0-rotatetarget.x);
8535 player[k].targetrotation*=360/6.28;
8536 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8537 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8539 player[k].victim=&player[i];
8540 player[k].hasvictim=1;
8541 player[i].targetanimation=knifefollowedanim;
8542 player[i].currentanimation=knifefollowedanim;
8543 player[i].targettilt2=0;
8544 player[i].targettilt2=player[k].targettilt2;
8545 player[i].targetframe=1;
8546 player[i].currentframe=0;
8548 player[i].velocity=0;
8549 player[k].currentanimation=knifefollowanim;
8550 player[k].targetanimation=knifefollowanim;
8551 player[k].targettilt2=player[i].targettilt2;
8552 player[k].currentframe=player[i].currentframe;
8553 player[k].targetframe=player[i].targetframe;
8554 player[k].target=player[i].target;
8555 player[k].velocity=0;
8556 player[k].oldcoords=player[k].coords;
8557 player[i].coords=player[k].coords;
8558 player[i].targetrotation=player[k].targetrotation;
8559 player[i].rotation=player[k].targetrotation;
8560 player[k].rotation=player[k].targetrotation;
8561 player[i].rotation=player[k].targetrotation;
8566 if(player[k].weaponactive!=-1){
8567 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8570 for(i=0;i<numplayers;i++){
8572 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8573 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8574 if(player[i].skeleton.free)
8575 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)))){
8576 player[k].victim=&player[i];
8577 player[k].hasvictim=1;
8578 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8579 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;
8580 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;
8581 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;
8583 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){
8584 player[k].targetanimation=killanim;
8585 for(j=0;j<terrain.numdecals;j++){
8586 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8587 terrain.DeleteDecal(j);
8590 for(l=0;l<objects.numobjects;l++){
8591 if(objects.model[l].type==decalstype)
8592 for(j=0;j<objects.model[l].numdecals;j++){
8593 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8594 objects.model[l].DeleteDecal(j);
8599 if(!player[i].dead||musictype!=2)
8600 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)){
8601 player[k].targetanimation=dropkickanim;
8602 for(j=0;j<terrain.numdecals;j++){
8603 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8604 terrain.DeleteDecal(j);
8607 for(l=0;l<objects.numobjects;l++){
8608 if(objects.model[l].type==decalstype)
8609 for(j=0;j<objects.model[l].numdecals;j++){
8610 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8611 objects.model[l].DeleteDecal(j);
8617 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)){
8619 player[k].targetframe=0;
8621 //player[k].velocity=0;
8623 rotatetarget=player[i].coords-player[k].coords;
8624 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8625 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;
8627 Normalise(&rotatetarget);
8628 player[k].targetrotation=-asin(0-rotatetarget.x);
8629 player[k].targetrotation*=360/6.28;
8630 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8632 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8633 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8636 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8637 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8639 player[k].lastattack3=player[k].lastattack2;
8640 player[k].lastattack2=player[k].lastattack;
8641 player[k].lastattack=player[k].targetanimation;
8643 if(player[k].targetanimation==swordgroundstabanim){
8644 player[k].targetrotation+=30;
8646 //player[k].targettilt2=0;
8652 if(!player[k].hasvictim){
8653 for(i=0;i<numplayers;i++){
8654 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8655 player[k].victim=&player[i];
8656 player[k].hasvictim=1;
8658 if(player[k].hasvictim&&!player[i].skeleton.free)
8659 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8660 player[k].victim=&player[i];
8664 if(player[k].aitype==playercontrolled)
8665 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)){
8667 player[k].targetanimation=rabbitkickanim;
8668 player[k].targetframe=0;
8671 if(animation[player[k].targetanimation].attack&&k==0){
8674 if(player[k].weaponactive!=-1){
8675 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8678 if(player[k].weaponactive!=-1){
8679 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8682 if(player[k].weaponactive!=-1){
8683 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8685 if(armedstaff)numstaffattack++;
8686 else if(armedsword)numswordattack++;
8687 else if(armedknife)numknifeattack++;
8688 else numunarmedattack++;
8695 static float collisionradius;
8697 for(k=0;k<numplayers;k++){
8698 for(i=k;i<numplayers;i++){
8701 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))
8702 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))
8703 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8704 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8705 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)
8706 if(player[i].coords.y>player[k].coords.y-3)
8707 if(player[i].coords.y<player[k].coords.y+3)
8708 if(player[i].coords.x>player[k].coords.x-3)
8709 if(player[i].coords.x<player[k].coords.x+3)
8710 if(player[i].coords.z>player[k].coords.z-3)
8711 if(player[i].coords.z<player[k].coords.z+3){
8712 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)){
8713 if(player[i].onfire||player[k].onfire){
8714 if(!player[i].onfire)player[i].CatchFire();
8715 if(!player[k].onfire)player[k].CatchFire();
8719 tempcoords1=player[i].coords;
8720 tempcoords2=player[k].coords;
8721 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8722 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8723 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8724 if(player[0].hasvictim)
8725 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8726 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8728 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)){
8729 player[k].coords.y=player[i].coords.y;
8730 player[i].velocity=player[k].velocity;
8731 player[i].skeleton.free=0;
8732 player[i].rotation=0;
8733 player[i].RagDoll(0);
8734 player[i].DoDamage(20);
8735 if(k==0)camerashake+=.3;
8736 player[i].skeleton.longdead=0;
8737 player[k].lastcollide=1;
8740 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)){
8741 player[i].coords.y=player[k].coords.y;
8742 player[k].velocity=player[i].velocity;
8743 player[k].skeleton.free=0;
8744 player[k].rotation=0;
8745 player[k].RagDoll(0);
8746 player[k].DoDamage(20);
8747 if(i==0)camerashake+=.3;
8748 player[k].skeleton.longdead=0;
8749 player[i].lastcollide=1;
8752 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)){
8753 rotatetarget=player[k].velocity-player[i].velocity;
8754 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))
8755 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))){
8757 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)){
8758 static float gLoc[3];
8759 static float vel[3];
8760 gLoc[0]=player[i].coords.x;
8761 gLoc[1]=player[i].coords.y;
8762 gLoc[2]=player[i].coords.z;
8763 vel[0]=player[i].velocity.x;
8764 vel[1]=player[i].velocity.y;
8765 vel[2]=player[i].velocity.z;
8766 if(tutoriallevel!=1){
8767 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8768 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8769 FSOUND_SetVolume(channels[heavyimpactsound], 256);
8770 FSOUND_SetPaused(channels[heavyimpactsound], false);
8772 //player[i].velocity=player[k].velocity;
8773 //player[k].velocity=player[i].velocity;
8775 player[i].RagDoll(0);
8776 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8781 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8782 player[k].RagDoll(0);
8783 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8788 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8790 //if(player[i].skeleton.oldfree){
8791 for(j=0;j<player[i].skeleton.num_joints;j++){
8792 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8795 //if(player[k].skeleton.oldfree){
8796 for(j=0;j<player[k].skeleton.num_joints;j++){
8797 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8803 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)){
8805 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8806 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)){
8807 rotatetarget=player[k].coords-player[i].coords;
8808 Normalise(&rotatetarget);
8809 player[k].coords=(player[k].coords+player[i].coords)/2;
8810 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);
8811 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8812 if(player[k].howactive==typeactive||hostile)
8813 if(player[k].isIdle()){
8814 if(player[k].howactive<typesleeping){
8815 player[k].targetanimation=player[k].getStop();
8816 player[k].targetframe=0;
8819 else if(player[k].howactive==typesleeping)
8821 player[k].targetanimation=getupfromfrontanim;
8822 player[k].targetframe=0;
8825 if(!editorenabled)player[k].howactive=typeactive;
8827 if(player[i].howactive==typeactive||hostile)
8828 if(player[i].isIdle()){
8829 if(player[i].howactive<typesleeping){
8830 player[i].targetanimation=player[i].getStop();
8831 player[i].targetframe=0;
8836 player[i].targetanimation=getupfromfrontanim;
8837 player[i].targetframe=0;
8840 if(!editorenabled)player[i].howactive=typeactive;
8844 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){
8845 player[i].velocity=player[k].velocity;
8846 player[k].velocity=player[k].velocity*-.5;
8847 //player[i].velocity.y-=10;
8848 player[k].velocity.y=player[i].velocity.y;
8849 player[i].DoDamage(20);
8850 player[i].RagDoll(0);
8851 player[k].lastcollide=1;
8858 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){
8859 player[k].velocity=player[i].velocity;
8860 player[i].velocity=player[i].velocity*-.3;
8861 //player[k].velocity.y-=10;
8862 player[i].velocity.y=player[k].velocity.y;
8863 player[k].DoDamage(20);
8864 player[k].RagDoll(0);
8865 player[i].lastcollide=1;
8876 player[i].CheckKick();
8877 player[k].CheckKick();
8883 for(k=0;k<numplayers;k++){
8884 for(i=k;i<numplayers;i++){
8886 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))){
8887 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)){
8888 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)){
8889 player[i].victim=&player[k];
8890 player[i].targetanimation=jumpreversedanim;
8891 player[i].currentanimation=jumpreversedanim;
8892 player[k].currentanimation=jumpreversalanim;
8893 player[k].targetanimation=jumpreversalanim;
8894 player[i].targettilt2=0;
8895 player[i].currentframe=0;
8896 player[i].targetframe=1;
8897 player[k].currentframe=0;
8898 player[k].targetframe=1;
8899 if(player[i].coords.y<player[k].coords.y+1){
8900 player[i].targetanimation=rabbitkickreversedanim;
8901 player[i].currentanimation=rabbitkickreversedanim;
8902 player[k].currentanimation=rabbitkickreversalanim;
8903 player[k].targetanimation=rabbitkickreversalanim;
8904 player[k].currentframe=1;
8905 player[k].targetframe=2;
8906 player[i].currentframe=1;
8907 player[i].targetframe=2;
8909 player[k].targettilt2=0;
8911 player[i].velocity=0;
8912 player[k].velocity=0;
8913 player[k].oldcoords=player[k].coords;
8914 player[i].coords=player[k].coords;
8915 player[k].targetrotation=player[i].targetrotation;
8916 player[k].rotation=player[i].targetrotation;
8917 player[k].victim=&player[i];
8918 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8920 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)){
8921 player[k].victim=&player[i];
8922 player[k].targetanimation=jumpreversedanim;
8923 player[k].currentanimation=jumpreversedanim;
8924 player[i].currentanimation=jumpreversalanim;
8925 player[i].targetanimation=jumpreversalanim;
8926 player[k].targettilt2=0;
8927 player[i].targettilt2=0;
8928 player[k].currentframe=0;
8929 player[k].targetframe=1;
8930 player[i].currentframe=0;
8931 player[i].targetframe=1;
8932 if(player[k].coords.y<player[i].coords.y+1){
8933 player[k].targetanimation=rabbitkickreversedanim;
8934 player[k].currentanimation=rabbitkickreversedanim;
8935 player[i].currentanimation=rabbitkickreversalanim;
8936 player[i].targetanimation=rabbitkickreversalanim;
8937 player[k].currentframe=1;
8938 player[k].targetframe=2;
8939 player[i].currentframe=1;
8940 player[i].targetframe=2;
8943 player[k].velocity=0;
8944 player[i].velocity=0;
8945 player[i].oldcoords=player[i].coords;
8946 player[k].coords=player[i].coords;
8947 player[i].targetrotation=player[k].targetrotation;
8948 player[i].rotation=player[k].targetrotation;
8949 player[i].victim=&player[k];
8950 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8957 for(k=0;k<numplayers;k++)
8958 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8967 static float checkdelay;
8968 checkdelay-=multiplier;
8970 static bool checkedcoll[maxplayers][maxplayers];
8971 static bool above[maxplayers];
8973 for(i=0;i<maxplayers;i++){
8974 for(j=0;j<maxplayers;j++){
8975 checkedcoll[i][j]=0;
8979 if(numplayers>1&&checkdelay<=0){
8981 for(k=0;k<numplayers;k++){
8982 if(player[k].skeleton.free!=2)above[k]=-1;
8984 for(i=k;i<numplayers;i++){
8987 if(!checkedcoll[i][k]){
8988 checkedcoll[i][k]=1;
8989 checkedcoll[k][i]=1;
8990 if(player[i].skeleton.free&&player[k].skeleton.free)
8991 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8992 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8993 if(player[i].coords.y>player[k].coords.y-3)
8994 if(player[i].coords.y<player[k].coords.y+3)
8995 if(player[i].coords.x>player[k].coords.x-3)
8996 if(player[i].coords.x<player[k].coords.x+3)
8997 if(player[i].coords.z>player[k].coords.z-3)
8998 if(player[i].coords.z<player[k].coords.z+3)
8999 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)){
9001 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
9013 above[moving]=stuck;
9014 for(l=0;l<player[moving].skeleton.num_joints;l++){
9015 for(m=0;m<player[stuck].skeleton.num_joints;m++){
9016 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
9018 player[moving].skeleton.joints[l].position.y+=.003;
9019 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
9033 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
9034 texturesizetogglekeydown=0;
9037 for(k=0;k<numplayers;k++){
9038 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9039 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9040 player[k].DoDamage(1000);
9045 static bool respawnkeydown;
9046 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
9047 targetlevel=whichlevel;
9051 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
9052 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
9057 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
9059 if(targetlevel>numchallengelevels-1)targetlevel=0;
9062 slomotogglekeydown=1;
9066 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
9068 FSOUND_SetPaused(channels[whooshsound], true);
9070 for(k=0;k<numplayers;k++){
9073 player[k].permanentdamage=0;
9074 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
9075 player[k].aitype=passivetype;
9077 player[0].aitype=playercontrolled;
9081 static bool movekey;
9082 static bool connected;
9083 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
9084 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
9085 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
9086 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
9087 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
9088 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
9090 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
9092 for(int i=0;i<numplayers;i++){
9093 if(!player[i].skeleton.free){
9094 oldtargetrotation=player[i].targetrotation;
9095 if(i==0&&indialogue==-1){
9096 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){
9097 if(!cameramode)player[0].targetrotation=-rotation+180;
9098 if(cameramode)player[0].targetrotation=0;
9104 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9105 if(cameramode){facing=flatfacing;}
9107 facing=DoRotation(facing,-rotation2,0,0);
9108 facing=DoRotation(facing,0,0-rotation,0);
9111 player[0].lookrotation=-rotation;
9113 player[i].targetheadrotation=rotation;
9114 player[i].targetheadrotation2=rotation2;
9116 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9117 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){
9118 player[i].targetrotation=-player[i].lookrotation+180;
9124 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9126 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9127 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9129 player[i].targetheadrotation=player[i].lookrotation;
9130 player[i].targetheadrotation2=player[i].lookrotation2;
9133 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9134 Normalise(&rotatetarget);
9135 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9136 player[i].targetheadrotation*=360/6.28;
9137 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9139 player[i].targetheadrotation*=-1;
9140 player[i].targetheadrotation+=180;
9141 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9149 player[i].avoidsomething=0;
9151 for(j=0;j<objects.numobjects;j++){
9152 if(objects.onfire[j]){
9153 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9155 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9156 player[i].collided=0;
9157 player[i].avoidcollided=1;
9158 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9159 player[i].avoidwhere=objects.position[j];
9165 //Add avoidwhere to players
9167 for(j=0;j<numplayers;j++){
9168 if(player[j].onfire){
9169 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9171 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9172 player[i].collided=0;
9173 player[i].avoidcollided=1;
9174 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9175 player[i].avoidwhere=objects.position[j];
9181 if(player[i].collided>.8)player[i].avoidcollided=0;
9182 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9183 player[i].jumpclimb=0;
9185 if(editorenabled)player[i].stunned=1;
9188 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9189 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;
9191 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9192 player[i].forwardkeydown=0;
9193 player[i].leftkeydown=0;
9194 player[i].backkeydown=0;
9195 player[i].rightkeydown=0;
9196 player[i].crouchkeydown=0;
9197 player[i].attackkeydown=0;
9198 player[i].jumpkeydown=0;
9199 player[i].throwkeydown=0;
9202 if(player[i].aitype==pathfindtype){
9203 if(player[i].finalpathfindpoint==-1){
9204 float closestdistance;
9210 for(j=0;j<numpathpoints;j++){
9211 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9212 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9214 player[i].finaltarget=pathpoint[j];
9217 player[i].finalpathfindpoint=closest;
9218 for(j=0;j<numpathpoints;j++){
9219 if(numpathpointconnect[j])
9220 for(k=0;k<numpathpointconnect[j];k++){
9221 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9222 if(tempdist*tempdist<closestdistance){
9223 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9224 closestdistance=tempdist*tempdist;
9226 player[i].finaltarget=colpoint;
9231 player[i].finalpathfindpoint=closest;
9234 if(player[i].targetpathfindpoint==-1){
9235 float closestdistance;
9241 if(player[i].lastpathfindpoint==-1){
9242 for(j=0;j<numpathpoints;j++){
9243 if(j!=player[i].lastpathfindpoint)
9244 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9245 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9249 player[i].targetpathfindpoint=closest;
9250 for(j=0;j<numpathpoints;j++){
9251 if(j!=player[i].lastpathfindpoint)
9252 if(numpathpointconnect[j])
9253 for(k=0;k<numpathpointconnect[j];k++){
9254 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9255 if(tempdist*tempdist<closestdistance){
9256 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9257 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9258 closestdistance=tempdist*tempdist;
9265 player[i].targetpathfindpoint=closest;
9269 for(j=0;j<numpathpoints;j++){
9270 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9273 if(numpathpointconnect[j])
9274 for(k=0;k<numpathpointconnect[j];k++){
9275 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9278 if(numpathpointconnect[player[i].lastpathfindpoint])
9279 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9280 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9283 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9284 if(closest==-1||tempdist<closestdistance){
9285 closestdistance=tempdist;
9291 player[i].targetpathfindpoint=closest;
9294 player[i].losupdatedelay-=multiplier;
9296 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9297 Normalise(&rotatetarget);
9298 player[i].targetrotation=-asin(0-rotatetarget.x);
9299 player[i].targetrotation*=360/6.28;
9300 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9301 player[i].lookrotation=player[i].targetrotation;
9302 //player[i].aiupdatedelay=.05;
9304 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9305 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9306 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9307 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9308 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9309 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9310 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9311 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9312 player[i].targetpathfindpoint=-1;
9314 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){
9315 player[i].aitype=passivetype;
9318 player[i].forwardkeydown=1;
9319 player[i].leftkeydown=0;
9320 player[i].backkeydown=0;
9321 player[i].rightkeydown=0;
9322 player[i].crouchkeydown=0;
9323 player[i].attackkeydown=0;
9324 player[i].throwkeydown=0;
9326 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9328 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9329 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9331 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9332 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))
9333 player[i].aitype=attacktypecutoff;
9334 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9335 player[i].aitype=attacktypecutoff;
9337 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9338 player[i].losupdatedelay=.2;
9339 for(j=0;j<numplayers;j++){
9340 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9341 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9342 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9343 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9344 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9345 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)){
9346 player[i].aitype=searchtype;
9347 player[i].lastchecktime=12;
9348 player[i].lastseen=player[j].coords;
9349 player[i].lastseentime=12;
9355 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9356 if(player[i].creature!=wolftype){
9357 player[i].stunned=.6;
9358 player[i].surprised=.6;
9363 if(player[i].aitype!=passivetype&&leveltime>.5){
9364 player[i].howactive=typeactive;
9367 if(player[i].aitype==passivetype){
9368 player[i].aiupdatedelay-=multiplier;
9369 player[i].losupdatedelay-=multiplier;
9370 player[i].lastseentime+=multiplier;
9371 player[i].pausetime-=multiplier;
9372 if(player[i].lastseentime>1)player[i].lastseentime=1;
9374 if(player[i].aiupdatedelay<0){
9375 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9376 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9377 Normalise(&rotatetarget);
9378 player[i].targetrotation=-asin(0-rotatetarget.x);
9379 player[i].targetrotation*=360/6.28;
9380 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9381 player[i].lookrotation=player[i].targetrotation;
9382 player[i].aiupdatedelay=.05;
9384 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9385 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9386 player[i].waypoint++;
9387 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9392 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9393 else player[i].forwardkeydown=0;
9394 player[i].leftkeydown=0;
9395 player[i].backkeydown=0;
9396 player[i].rightkeydown=0;
9397 player[i].crouchkeydown=0;
9398 player[i].attackkeydown=0;
9399 player[i].throwkeydown=0;
9401 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9402 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9404 XYZ leftpos,rightpos;
9405 float leftdist,rightdist;
9406 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9407 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9408 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9409 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9410 if(leftdist<rightdist)player[i].targetrotation+=90;
9411 else player[i].targetrotation-=90;
9415 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9416 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9420 if(player[i].howactive<typesleeping)
9421 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9422 for(j=0;j<numenvsounds;j++){
9423 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9424 player[i].aitype=attacktypecutoff;
9428 if(player[i].howactive==typesleeping)
9429 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9430 for(j=0;j<numenvsounds;j++){
9431 if(envsoundvol[j]>14)
9432 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9433 player[i].aitype=attacktypecutoff;
9437 if(player[i].aitype!=passivetype){
9438 if(player[i].howactive==typesleeping){
9439 player[i].targetanimation=getupfromfrontanim;
9440 player[i].targetframe=0;
9444 player[i].howactive=typeactive;
9448 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9449 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9450 player[i].aitype=attacktypecutoff;
9451 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9452 player[i].aitype=attacktypecutoff;
9454 if(player[i].creature==wolftype){
9456 float smelldistance;
9458 for(j=0;j<numplayers;j++){
9459 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9460 if(j==0&&player[j].num_weapons>0){
9461 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9462 if(player[j].num_weapons==2)
9463 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9468 windsmell=windvector;
9469 Normalise(&windsmell);
9470 windsmell=windsmell*2+player[j].coords;
9471 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9472 player[i].aitype=attacktypecutoff;
9477 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9478 player[i].losupdatedelay=.2;
9479 for(j=0;j<numplayers;j++){
9480 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9481 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9482 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9483 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9484 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)){
9485 player[i].lastseentime-=.2;
9486 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9487 else player[i].lastseentime-=.6;
9489 if(player[i].lastseentime<=0){
9490 player[i].aitype=searchtype;
9491 player[i].lastchecktime=12;
9492 player[i].lastseen=player[j].coords;
9493 player[i].lastseentime=12;
9499 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9500 if(player[i].creature!=wolftype){
9501 player[i].stunned=.6;
9502 player[i].surprised=.6;
9504 if(player[i].creature==wolftype){
9505 player[i].stunned=.47;
9506 player[i].surprised=.47;
9512 if(player[i].aitype==searchtype){
9513 player[i].aiupdatedelay-=multiplier;
9514 player[i].losupdatedelay-=multiplier;
9515 if(!player[i].pause)player[i].lastseentime-=multiplier;
9516 player[i].lastchecktime-=multiplier;
9518 if(player[i].isRun()&&!player[i].onground){
9519 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9520 test2=player[i].coords+player[i].facing;
9522 test=player[i].coords+player[i].facing;
9524 j=checkcollide(test2,test,player[i].laststanding);
9525 if(j==-1)j=checkcollide(test2,test);
9527 player[i].velocity=0;
9528 player[i].targetanimation=player[i].getStop();
9529 player[i].targetframe=0;
9531 player[i].targetrotation+=180;
9532 player[i].stunned=.5;
9533 //player[i].aitype=passivetype;
9534 player[i].aitype=pathfindtype;
9535 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9536 player[i].finalpathfindpoint=-1;
9537 player[i].targetpathfindpoint=-1;
9538 player[i].lastpathfindpoint=-1;
9539 player[i].lastpathfindpoint2=-1;
9540 player[i].lastpathfindpoint3=-1;
9541 player[i].lastpathfindpoint4=-1;
9543 else player[i].laststanding=j;
9546 if(player[i].aiupdatedelay<0){
9547 rotatetarget=player[i].lastseen-player[i].coords;
9548 Normalise(&rotatetarget);
9549 player[i].targetrotation=-asin(0-rotatetarget.x);
9550 player[i].targetrotation*=360/6.28;
9551 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9552 player[i].lookrotation=player[i].targetrotation;
9553 player[i].aiupdatedelay=.05;
9554 player[i].forwardkeydown=1;
9556 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9557 player[i].forwardkeydown=0;
9558 player[i].aiupdatedelay=1;
9559 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9560 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9561 player[i].lastchecktime=3;
9564 player[i].leftkeydown=0;
9565 player[i].backkeydown=0;
9566 player[i].rightkeydown=0;
9567 player[i].crouchkeydown=0;
9568 player[i].attackkeydown=0;
9569 player[i].throwkeydown=0;
9571 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9572 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9574 XYZ leftpos,rightpos;
9575 float leftdist,rightdist;
9576 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9577 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9578 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9579 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9580 if(leftdist<rightdist)player[i].targetrotation+=90;
9581 else player[i].targetrotation-=90;
9585 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9586 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9588 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9589 for(j=0;j<numenvsounds;j++){
9590 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9591 player[i].aitype=attacktypecutoff;
9595 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9596 player[i].losupdatedelay=.2;
9597 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9598 {player[i].aitype=attacktypecutoff;
9599 player[i].lastseentime=1;}
9600 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9601 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9602 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9603 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)){
9604 player[i].aitype=attacktypecutoff;
9605 player[i].lastseentime=1;
9608 if(player[i].lastseentime<0){
9609 //player[i].aitype=passivetype;
9611 player[i].aitype=pathfindtype;
9612 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9613 player[i].finalpathfindpoint=-1;
9614 player[i].targetpathfindpoint=-1;
9615 player[i].lastpathfindpoint=-1;
9616 player[i].lastpathfindpoint2=-1;
9617 player[i].lastpathfindpoint3=-1;
9618 player[i].lastpathfindpoint4=-1;
9622 if(player[i].aitype!=gethelptype){
9623 player[i].runninghowlong=0;
9626 if(player[i].aitype==gethelptype){
9627 player[i].runninghowlong+=multiplier;
9628 player[i].aiupdatedelay-=multiplier;
9630 if(player[i].aiupdatedelay<0||player[i].ally==0){
9631 player[i].aiupdatedelay=.2;
9639 if(!player[i].ally){
9640 for(j=0;j<numplayers;j++){
9641 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9642 distance=findDistancefast(&player[i].coords,&player[j].coords);
9643 if(closestdist==-1||distance<closestdist){
9644 closestdist=distance;
9650 if(closest!=-1)player[i].ally=closest;
9651 else player[i].ally=0;
9652 player[i].lastseen=player[0].coords;
9653 player[i].lastseentime=12;
9657 player[i].lastchecktime=12;
9658 //player[i].lastseentime-=.5;
9660 facing=player[i].coords;
9661 flatfacing=player[player[i].ally].coords;
9662 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9663 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9664 if(-1!=checkcollide(facing,flatfacing))
9665 player[i].lastseentime-=.1;
9667 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9668 player[i].aitype=searchtype;
9669 player[i].lastseentime=12;
9672 if(player[i].ally>0){
9673 rotatetarget=player[player[i].ally].coords-player[i].coords;
9674 Normalise(&rotatetarget);
9675 player[i].targetrotation=-asin(0-rotatetarget.x);
9676 player[i].targetrotation*=360/6.28;
9677 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9678 player[i].lookrotation=player[i].targetrotation;
9679 player[i].aiupdatedelay=.05;
9680 player[i].forwardkeydown=1;
9682 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9683 player[i].aitype=searchtype;
9684 player[i].lastseentime=12;
9685 player[player[i].ally].aitype=searchtype;
9686 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9687 player[player[i].ally].lastseen=player[i].lastseen;
9688 player[player[i].ally].lastseentime=player[i].lastseentime;
9689 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9693 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9694 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9696 XYZ leftpos,rightpos;
9697 float leftdist,rightdist;
9698 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9699 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9700 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9701 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9702 if(leftdist<rightdist)player[i].targetrotation+=90;
9703 else player[i].targetrotation-=90;
9708 player[i].leftkeydown=0;
9709 player[i].backkeydown=0;
9710 player[i].rightkeydown=0;
9711 player[i].crouchkeydown=0;
9712 player[i].attackkeydown=0;
9714 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9715 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9718 if(player[i].aitype==getweapontype){
9719 player[i].aiupdatedelay-=multiplier;
9720 player[i].lastchecktime-=multiplier;
9722 if(player[i].aiupdatedelay<0){
9723 player[i].aiupdatedelay=.2;
9731 if(player[i].ally<0){
9732 for(j=0;j<weapons.numweapons;j++){
9733 if(weapons.owner[j]==-1){
9734 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9735 if(closestdist==-1||distance<closestdist){
9736 closestdist=distance;
9742 if(closest!=-1)player[i].ally=closest;
9743 else player[i].ally=-1;
9746 player[i].lastseentime=12;
9748 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9749 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9750 player[i].aitype=attacktypecutoff;
9751 player[i].lastseentime=1;
9754 if(player[i].ally>=0){
9755 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9756 player[i].aitype=attacktypecutoff;
9757 player[i].lastseentime=1;
9759 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9760 Normalise(&rotatetarget);
9761 player[i].targetrotation=-asin(0-rotatetarget.x);
9762 player[i].targetrotation*=360/6.28;
9763 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9764 player[i].lookrotation=player[i].targetrotation;
9765 player[i].aiupdatedelay=.05;
9766 player[i].forwardkeydown=1;
9769 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9770 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9772 XYZ leftpos,rightpos;
9773 float leftdist,rightdist;
9774 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9775 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9776 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9777 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9778 if(leftdist<rightdist)player[i].targetrotation+=90;
9779 else player[i].targetrotation-=90;
9782 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9783 if(abs(Random()%6)){
9784 player[i].crouchkeydown=1;
9785 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9786 if(player[i].isRun()){
9787 player[i].targetframe=0;
9789 player[i].targetanimation=sneakanim;
9792 else player[i].forwardkeydown=0;
9794 else player[i].crouchkeydown=0;
9796 else player[i].crouchkeydown=0;*/
9799 player[i].leftkeydown=0;
9800 player[i].backkeydown=0;
9801 player[i].rightkeydown=0;
9802 player[i].attackkeydown=0;
9803 player[i].throwkeydown=1;
9804 player[i].crouchkeydown=0;
9805 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9806 player[i].drawkeydown=0;
9808 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9809 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9812 if(player[i].aitype==attacktypecutoff){
9813 player[i].aiupdatedelay-=multiplier;
9814 if(player[i].damage<player[i].damagetolerance*2/3)
9815 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)){
9816 player[i].attackkeydown=0;
9817 if(player[i].isIdle())player[i].crouchkeydown=1;
9818 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9819 if(weapons.type[player[0].weaponids[0]]==knife){
9820 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9821 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9822 else player[i].targetanimation=rollanim;
9824 player[i].targetframe=0;
9825 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9826 player[i].wentforweapon=0;
9828 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9829 player[i].targetanimation=flipanim;
9831 player[i].targetframe=0;
9835 player[i].forwardkeydown=0;
9836 player[i].aiupdatedelay=.02;
9838 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9839 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9840 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9842 if(player[i].wentforweapon<3)
9843 for(j=0;j<weapons.numweapons;j++){
9844 if(player[i].creature!=wolftype)
9845 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){
9846 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9847 player[i].wentforweapon++;
9848 player[i].lastchecktime=6;
9849 player[i].aitype=getweapontype;
9854 if(player[i].damage<player[i].damagetolerance/2)
9855 if(animation[player[i].targetanimation].height!=highheight)
9856 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)))){
9857 player[i].crouchkeydown=1;
9859 if(player[i].isRun()&&!player[i].onground){
9860 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9861 test2=player[i].coords+player[i].facing;
9863 test=player[i].coords+player[i].facing;
9865 j=checkcollide(test2,test,player[i].laststanding);
9866 if(j==-1)j=checkcollide(test2,test);
9868 player[i].velocity=0;
9869 player[i].targetanimation=player[i].getStop();
9870 player[i].targetframe=0;
9872 player[i].targetrotation+=180;
9873 player[i].stunned=.5;
9874 //player[i].aitype=passivetype;
9875 player[i].aitype=pathfindtype;
9876 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9877 player[i].finalpathfindpoint=-1;
9878 player[i].targetpathfindpoint=-1;
9879 player[i].lastpathfindpoint=-1;
9880 player[i].lastpathfindpoint2=-1;
9881 player[i].lastpathfindpoint3=-1;
9882 player[i].lastpathfindpoint4=-1;
9884 else player[i].laststanding=j;
9887 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9888 player[i].aitype=pathfindtype;
9889 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9890 player[i].finalpathfindpoint=-1;
9891 player[i].targetpathfindpoint=-1;
9892 player[i].lastpathfindpoint=-1;
9893 player[i].lastpathfindpoint2=-1;
9894 player[i].lastpathfindpoint3=-1;
9895 player[i].lastpathfindpoint4=-1;
9897 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){
9898 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9899 else player[i].drawkeydown=0;
9900 player[i].rabbitkickenabled=Random()%2;
9901 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9902 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9903 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;
9904 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9905 Normalise(&rotatetarget);
9906 player[i].targetrotation=-asin(0-rotatetarget.x);
9907 player[i].targetrotation*=360/6.28;
9908 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9909 player[i].lookrotation=player[i].targetrotation;
9910 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9912 oldkey=player[i].forwardkeydown;
9913 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9914 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;
9915 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9916 else player[i].forwardkeydown=0;
9918 player[i].forwardkeydown=0;
9919 if(Random()%10==0)player[i].forwardkeydown=1;
9920 if(Random()%100==0){
9921 player[i].aitype=pathfindtype;
9922 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9923 player[i].finalpathfindpoint=-1;
9924 player[i].targetpathfindpoint=-1;
9925 player[i].lastpathfindpoint=-1;
9926 player[i].lastpathfindpoint2=-1;
9927 player[i].lastpathfindpoint3=-1;
9928 player[i].lastpathfindpoint4=-1;
9931 player[i].leftkeydown=0;
9932 player[i].backkeydown=0;
9933 player[i].rightkeydown=0;
9934 player[i].crouchkeydown=0;
9935 player[i].throwkeydown=0;
9937 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9938 /*for(j=0;j<numplayers;j++){
9939 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9940 player[i].crouchkeydown=1;
9943 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9944 else player[i].attackkeydown=0;
9945 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9946 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9947 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9948 player[i].attackkeydown=0;
9949 if(player[i].isIdle())player[i].crouchkeydown=1;
9950 player[i].forwardkeydown=0;
9951 player[i].aiupdatedelay=.02;
9954 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9956 for(j=0;j<numplayers;j++){
9957 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)){
9958 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))))){
9959 if(target>=0)target=-1;
9964 if(target>=0)player[target].Reverse();
9967 if(player[i].collided<1)player[i].jumpkeydown=0;
9968 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;
9969 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9970 player[0].jumpkeydown=0;
9971 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9972 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9973 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9975 if(tutoriallevel==1){
9976 if(!canattack)player[i].attackkeydown=0;
9980 facing=player[i].coords;
9981 flatfacing=player[0].coords;
9982 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9983 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9984 if(player[i].occluded>=2)
9985 if(-1!=checkcollide(facing,flatfacing)){
9986 if(!player[i].pause)player[i].lastseentime-=.2;
9987 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9988 player[i].aitype=searchtype;
9989 player[i].lastchecktime=12;
9990 player[i].lastseen=player[0].coords;
9991 player[i].lastseentime=12;
9994 else player[i].lastseentime=1;
9997 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9998 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9999 test=player[0].coords;
10001 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
10004 // NOTE: Ask about logic of this call : NOTE
10005 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
10006 player[i].stunned>0 ||
10007 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
10009 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
10010 player[i].targetrotation=player[i].rotation;
10011 player[i].forwardkeydown=0;
10012 player[i].leftkeydown=0;
10013 player[i].backkeydown=0;
10014 player[i].rightkeydown=0;
10015 player[i].jumpkeydown=0;
10016 player[i].attackkeydown=0;
10017 player[i].crouchkeydown=0;
10018 player[i].throwkeydown=0;
10025 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
10028 if(player[i].aitype==attacktypecutoff){
10029 rotatetarget=player[0].coords-player[i].coords;
10030 Normalise(&rotatetarget);
10031 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10032 player[i].targetheadrotation*=360/6.28;
10033 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10035 player[i].targetheadrotation*=-1;
10036 player[i].targetheadrotation+=180;
10037 //player[i].targetheadrotation2=0;
10038 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10040 else if(player[i].howactive>=typesleeping){
10041 player[i].targetheadrotation=player[i].targetrotation;
10042 player[i].targetheadrotation2=0;
10045 if(player[i].interestdelay<=0){
10046 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
10047 player[i].headtarget=player[i].coords;
10048 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
10049 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
10050 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
10051 player[i].headtarget+=player[i].facing*1.5;
10053 rotatetarget=player[i].headtarget-player[i].coords;
10054 Normalise(&rotatetarget);
10055 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10056 player[i].targetheadrotation*=360/6.28;
10057 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10059 player[i].targetheadrotation*=-1;
10060 player[i].targetheadrotation+=180;
10061 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10063 //if(whichlevel==2)player[i].jumpkeydown=0;
10065 if(animation[player[i].targetanimation].attack==reversed){
10066 //player[i].targetrotation=player[i].rotation;
10067 player[i].forwardkeydown=0;
10068 player[i].leftkeydown=0;
10069 player[i].backkeydown=0;
10070 player[i].rightkeydown=0;
10071 player[i].jumpkeydown=0;
10072 player[i].attackkeydown=0;
10073 //player[i].crouchkeydown=0;
10074 player[i].throwkeydown=0;
10077 if(indialogue!=-1){
10078 player[i].forwardkeydown=0;
10079 player[i].leftkeydown=0;
10080 player[i].backkeydown=0;
10081 player[i].rightkeydown=0;
10082 player[i].jumpkeydown=0;
10083 player[i].crouchkeydown=0;
10084 player[i].drawkeydown=0;
10085 player[i].throwkeydown=0;
10088 if(player[i].collided<-.3)player[i].collided=-.3;
10089 if(player[i].collided>1)player[i].collided=1;
10090 player[i].collided-=multiplier*4;
10091 player[i].whichdirectiondelay-=multiplier;
10092 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
10093 player[i].avoidcollided=-.3;
10094 player[i].whichdirection=abs(Random()%2);
10095 player[i].whichdirectiondelay=.4;
10097 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10098 player[i].avoidcollided-=multiplier/4;
10099 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10100 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10101 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;
10103 if(!player[i].throwkeydown){
10104 player[i].throwtogglekeydown=0;
10106 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10107 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)){
10108 for(j=0;j<weapons.numweapons;j++){
10109 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)
10110 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10111 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10112 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10113 player[i].throwtogglekeydown=1;
10114 player[i].targetanimation=crouchremoveknifeanim;
10115 player[i].target=0;
10116 player[i].targetframe=0;
10117 rotatetarget=weapons.position[j]-player[i].coords;
10118 Normalise(&rotatetarget);
10119 player[i].targetrotation=-asin(0-rotatetarget.x);
10120 player[i].targetrotation*=360/6.28;
10121 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10122 player[i].hasvictim=0;
10124 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10125 player[i].throwtogglekeydown=1;
10126 player[i].hasvictim=0;
10128 //for(i=0;i<weapons.numweapons;i++){
10129 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))
10130 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10131 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10134 gLoc[0]=player[i].coords.x;
10135 gLoc[1]=player[i].coords.y;
10136 gLoc[2]=player[i].coords.z;
10137 vel[0]=player[i].velocity.x;
10138 vel[1]=player[i].velocity.y;
10139 vel[2]=player[i].velocity.z;
10140 if(weapons.type[j]!=staff){
10141 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10142 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10143 FSOUND_SetVolume(channels[knifedrawsound], 128);
10144 FSOUND_SetPaused(channels[knifedrawsound], false);
10147 player[i].weaponactive=0;
10148 weapons.owner[j]=player[i].id;
10149 if(player[i].num_weapons>0){
10150 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10152 player[i].num_weapons++;
10153 player[i].weaponids[0]=j;
10159 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){
10160 if(!player[i].isFlip()){
10161 player[i].throwtogglekeydown=1;
10162 player[i].targetanimation=removeknifeanim;
10163 player[i].target=0;
10164 player[i].targetframe=0;
10165 rotatetarget=weapons.position[j]-player[i].coords;
10166 Normalise(&rotatetarget);
10167 player[i].targetrotation=-asin(0-rotatetarget.x);
10168 player[i].targetrotation*=360/6.28;
10169 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10171 if(player[i].isFlip()){
10172 player[i].throwtogglekeydown=1;
10173 player[i].hasvictim=0;
10175 for(k=0;k<weapons.numweapons;k++){
10176 if(player[i].weaponactive==-1)
10177 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))
10178 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10181 gLoc[0]=player[i].coords.x;
10182 gLoc[1]=player[i].coords.y;
10183 gLoc[2]=player[i].coords.z;
10184 vel[0]=player[i].velocity.x;
10185 vel[1]=player[i].velocity.y;
10186 vel[2]=player[i].velocity.z;
10187 if(weapons.type[k]!=staff){
10188 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10189 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10190 FSOUND_SetVolume(channels[knifedrawsound], 128);
10191 FSOUND_SetPaused(channels[knifedrawsound], false);
10194 player[i].weaponactive=0;
10195 weapons.owner[k]=player[i].id;
10196 if(player[i].num_weapons>0){
10197 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10199 player[i].num_weapons++;
10200 player[i].weaponids[0]=k;
10207 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10209 for(j=0;j<numplayers;j++){
10210 if(player[i].weaponactive==-1)
10212 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)){
10213 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10214 player[i].throwtogglekeydown=1;
10215 player[i].victim=&player[j];
10216 player[i].hasvictim=1;
10217 player[i].targetanimation=crouchremoveknifeanim;
10218 player[i].target=0;
10219 player[i].targetframe=0;
10220 rotatetarget=player[j].coords-player[i].coords;
10221 Normalise(&rotatetarget);
10222 player[i].targetrotation=-asin(0-rotatetarget.x);
10223 player[i].targetrotation*=360/6.28;
10224 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10226 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10227 player[i].throwtogglekeydown=1;
10228 player[i].victim=&player[j];
10229 player[i].hasvictim=1;
10230 int k = player[j].weaponids[0];
10231 if(player[i].hasvictim){
10234 gLoc[0]=player[i].coords.x;
10235 gLoc[1]=player[i].coords.y;
10236 gLoc[2]=player[i].coords.z;
10237 vel[0]=player[i].velocity.x;
10238 vel[1]=player[i].velocity.y;
10239 vel[2]=player[i].velocity.z;
10242 if(player[i].victim->weaponstuck!=-1){
10243 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10248 if(weapons.type[k]!=staff){
10249 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10250 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10251 FSOUND_SetVolume(channels[knifedrawsound], 128);
10252 FSOUND_SetPaused(channels[knifedrawsound], false);
10256 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
10257 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10258 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
10259 FSOUND_SetPaused(channels[fleshstabremovesound], false);
10262 player[i].weaponactive=0;
10263 if(weapons.owner[k]!=-1){
10264 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10265 else player[i].victim->num_weapons=1;
10267 player[i].victim->skeleton.longdead=0;
10268 player[i].victim->skeleton.free=1;
10269 player[i].victim->skeleton.broken=0;
10271 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10272 player[i].victim->skeleton.joints[l].velchange=0;
10273 player[i].victim->skeleton.joints[l].locked=0;
10279 Normalise(&relative);
10280 XYZ footvel,footpoint;
10282 footpoint=weapons.position[k];
10283 if(player[i].victim->weaponstuck!=-1){
10284 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10285 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10286 weapons.bloody[k]=2;
10287 weapons.blooddrip[k]=5;
10288 player[i].victim->weaponstuck=-1;
10289 player[i].victim->bloodloss+=2000;
10290 player[i].victim->DoDamage(2000);
10293 if(player[i].victim->num_weapons>0){
10294 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10295 if(player[i].victim->weaponids[0]==k)
10296 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10299 player[i].victim->weaponactive=-1;
10301 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10302 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10303 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10304 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10306 weapons.owner[k]=i;
10307 if(player[i].num_weapons>0){
10308 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10310 player[i].num_weapons++;
10311 player[i].weaponids[0]=k;
10318 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10319 if(weapons.type[player[i].weaponids[0]]==knife){
10320 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10322 for(j=0;j<numplayers;j++){
10324 if(tutoriallevel!=1||tutorialstage==49)
10326 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)){
10327 if(!player[i].isFlip()){
10328 player[i].throwtogglekeydown=1;
10329 player[i].victim=&player[j];
10330 player[i].targetanimation=knifethrowanim;
10331 player[i].target=0;
10332 player[i].targetframe=0;
10333 rotatetarget=player[j].coords-player[i].coords;
10334 Normalise(&rotatetarget);
10335 player[i].targetrotation=-asin(0-rotatetarget.x);
10336 player[i].targetrotation*=360/6.28;
10337 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10339 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10341 if(player[i].isFlip()){
10342 if(player[i].weaponactive!=-1){
10343 player[i].throwtogglekeydown=1;
10344 player[i].victim=&player[j];
10346 weapons.owner[player[i].weaponids[0]]=-1;
10347 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);
10350 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10352 weapons.velocity[player[i].weaponids[0]]=aim*50;
10353 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10354 weapons.missed[player[i].weaponids[0]]=0;
10355 weapons.freetime[player[i].weaponids[0]]=0;
10356 weapons.firstfree[player[i].weaponids[0]]=1;
10357 weapons.physics[player[i].weaponids[0]]=0;
10358 player[i].num_weapons--;
10359 if(player[i].num_weapons){
10360 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10362 player[i].weaponactive=-1;
10369 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10370 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10372 player[i].throwtogglekeydown=1;
10373 weapons.owner[player[i].weaponids[0]]=-1;
10374 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10375 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10376 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10377 weapons.missed[player[i].weaponids[0]]=1;
10378 weapons.freetime[player[i].weaponids[0]]=0;
10379 weapons.firstfree[player[i].weaponids[0]]=1;
10380 weapons.physics[player[i].weaponids[0]]=1;
10381 player[i].num_weapons--;
10382 if(player[i].num_weapons){
10383 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10384 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10387 player[i].weaponactive=-1;
10388 for(j=0;j<numplayers;j++){
10389 player[j].wentforweapon=0;
10396 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10397 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)){
10398 //Setenvironment(1-environment);
10401 if(player[i].weaponactive!=-1){
10402 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10404 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10405 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10406 player[i].targetanimation=drawrightanim;
10407 player[i].targetframe=0;
10408 player[i].target=0;
10409 player[i].drawtogglekeydown=1;
10411 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){
10412 player[i].targetanimation=drawleftanim;
10413 player[i].targetframe=0;
10414 player[i].target=0;
10415 player[i].drawtogglekeydown=1;
10417 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10418 player[i].targetanimation=crouchdrawrightanim;
10419 player[i].targetframe=0;
10420 player[i].target=0;
10421 player[i].drawtogglekeydown=1;
10425 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){
10426 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10427 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10428 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10429 player[i].targetframe=0;
10430 player[i].target=0;
10431 player[i].hasvictim=0;
10432 //player[i].attacktogglekeydown=1;
10436 if(!player[i].drawkeydown){
10437 player[i].drawtogglekeydown=0;
10442 absflatfacing.z=-1;
10444 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10446 else absflatfacing=flatfacing;
10448 if(indialogue!=-1){
10449 player[i].forwardkeydown=0;
10450 player[i].leftkeydown=0;
10451 player[i].backkeydown=0;
10452 player[i].rightkeydown=0;
10453 player[i].jumpkeydown=0;
10454 player[i].crouchkeydown=0;
10455 player[i].drawkeydown=0;
10456 player[i].throwkeydown=0;
10460 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10461 if(!player[i].forwardkeydown){
10462 player[i].forwardstogglekeydown=0;
10464 if(player[i].crouchkeydown){
10468 player[i].superruntoggle=1;
10470 for(j=0;j<numplayers;j++){
10471 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10472 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10473 player[i].superruntoggle=0;
10480 for(j=0;j<numplayers;j++){
10481 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10482 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))){
10483 if(target>=0)target=-1;
10488 if(target>=0)player[target].Reverse();
10489 player[i].lowreversaldelay=.5;
10491 if(player[i].isIdle()){
10492 player[i].targetanimation=player[i].getCrouch();
10493 player[i].target=0;
10494 player[i].targetframe=0;
10495 player[i].transspeed=10;
10497 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10498 player[i].targetanimation=rollanim;
10499 player[i].target=0;
10500 player[i].targetframe=0;
10501 player[i].transspeed=20;
10504 if(!player[i].crouchkeydown){
10506 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10508 if(player[i].isCrouch()){
10510 for(j=0;j<numplayers;j++){
10511 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10512 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10513 if(target>=0)target=-1;
10518 if(target>=0)player[target].Reverse();
10519 player[i].highreversaldelay=.5;
10521 if(player[i].isCrouch()){
10522 if(!player[i].wasCrouch()){
10523 player[i].currentanimation=player[i].getCrouch();
10524 player[i].currentframe=0;
10526 player[i].target=0;
10527 player[i].targetanimation=player[i].getIdle();
10528 player[i].targetframe=0;
10529 player[i].transspeed=10;
10532 if(player[i].targetanimation==sneakanim){
10533 player[i].targetanimation=player[i].getIdle();
10534 player[i].target=0;
10535 player[i].targetframe=0;
10536 player[i].transspeed=10;
10539 if(player[i].forwardkeydown){
10540 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)){
10541 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10542 else player[i].targetanimation=player[i].getRun();
10543 player[i].target=0;
10544 player[i].targetframe=0;
10546 if(player[i].isCrouch()){
10547 player[i].targetanimation=sneakanim;
10548 if(player[i].wasCrouch())player[i].target=0;
10549 player[i].targetframe=0;
10551 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10552 player[i].targetanimation=climbanim;
10553 player[i].target=0;
10554 player[i].targetframe=1;
10555 player[i].jumpclimb=1;
10557 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10558 player[i].velocity+=absflatfacing*5*multiplier;
10560 player[i].forwardstogglekeydown=1;
10563 if (player[i].rightkeydown){
10564 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)){
10565 player[i].targetanimation=player[i].getRun();
10566 player[i].target=0;
10567 player[i].targetframe=0;
10569 if(player[i].isCrouch()){
10570 player[i].targetanimation=sneakanim;
10571 if(player[i].wasCrouch()) player[i].target=0;
10572 player[i].targetframe=0;
10574 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10575 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10577 player[i].targetrotation-=90;
10578 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10579 if(player[i].backkeydown)player[i].targetrotation-=45;
10582 if ( player[i].leftkeydown){
10583 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)){
10584 player[i].targetanimation=player[i].getRun();
10585 player[i].target=0;
10586 player[i].targetframe=0;
10588 if(player[i].isCrouch()){
10589 player[i].targetanimation=sneakanim;
10590 if(player[i].wasCrouch())player[i].target=0;
10591 player[i].targetframe=0;
10593 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10594 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10596 player[i].targetrotation+=90;
10597 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10598 if(player[i].backkeydown)player[i].targetrotation+=45;
10601 if(player[i].backkeydown){
10602 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)){
10603 player[i].targetanimation=player[i].getRun();
10604 player[i].target=0;
10605 player[i].targetframe=0;
10607 if(player[i].isCrouch()){
10608 player[i].targetanimation=sneakanim;
10609 if(player[i].wasCrouch())player[i].target=0;
10610 player[i].targetframe=0;
10612 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10613 player[i].velocity-=absflatfacing*5*multiplier;
10615 if(player[i].targetanimation==hanganim){
10616 player[i].currentanimation=jumpdownanim;
10617 player[i].targetanimation=jumpdownanim;
10618 player[i].target=0;
10619 player[i].currentframe=0;
10620 player[i].targetframe=1;
10621 player[i].velocity=0;
10622 player[i].velocity.y+=gravity;
10623 player[i].coords.y-=1.4;
10624 player[i].grabdelay=1;
10626 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10627 player[i].targetrotation+=180;
10630 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10631 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)){
10632 player[i].jumpstart=0;
10633 player[i].targetanimation=jumpupanim;
10634 player[i].target=0;
10635 player[i].targetframe=0;
10636 player[i].rotation=player[i].targetrotation;
10637 player[i].transspeed=20;
10638 player[i].FootLand(0,1);
10639 player[i].FootLand(1,1);
10643 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10645 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10646 if(!movekey)player[i].velocity=0;
10651 for(j=0;j<numplayers;j++){
10652 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10653 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10654 if(target>=0)target=-1;
10659 if(target>=0)player[i].velocity.y=1;
10660 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10661 player[i].velocity.y=7;
10662 player[i].crouchtogglekeydown=1;
10664 else player[i].velocity.y=5;
10666 if(mousejump&&i==0&&debugmode){
10667 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10668 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10671 player[i].coords.y+=.2;
10672 player[i].jumppower-=1;
10674 static float gLoc[3];
10675 static float vel[3];
10676 gLoc[0]=player[i].coords.x;
10677 gLoc[1]=player[i].coords.y;
10678 gLoc[2]=player[i].coords.z;
10679 vel[0]=player[i].velocity.x;
10680 vel[1]=player[i].velocity.y;
10681 vel[2]=player[i].velocity.z;
10684 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10685 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10686 FSOUND_SetVolume(channels[whooshsound], 128);
10687 FSOUND_SetPaused(channels[whooshsound], false);
10690 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10691 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10692 FSOUND_SetVolume(channels[jumpsound], 128);
10693 FSOUND_SetPaused(channels[jumpsound], false);
10695 if((player[i].isIdle())&&player[i].jumppower>1){
10696 player[i].targetanimation=player[i].getLanding();
10697 player[i].landhard=0;
10698 player[i].target=0;
10699 player[i].targetframe=2;
10700 player[i].jumpstart=1;
10701 player[i].tempdeltav=deltav;
10703 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10704 if(player[i].jumppower>multiplier*6){
10705 player[i].velocity.y+=multiplier*6;
10706 player[i].jumppower-=multiplier*6;
10708 if(player[i].jumppower<=multiplier*6){
10709 player[i].velocity.y+=player[i].jumppower;
10710 player[i].jumppower=0;
10713 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10717 if(player[i].isRun()||player[i].targetanimation==walkanim){
10718 player[i].targetanimation=player[i].getStop();
10719 player[i].target=0;
10720 player[i].targetframe=0;
10722 if(player[i].targetanimation==sneakanim){
10723 player[i].targetanimation=player[i].getCrouch();
10724 if(player[i].currentanimation==sneakanim)player[i].target=0;
10725 player[i].targetframe=0;
10728 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10729 player[i].targetanimation=player[i].getStop();
10730 player[i].target=0;
10731 player[i].targetframe=0;
10733 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10734 player[i].targetanimation=player[i].getStop();
10735 player[i].target=0;
10736 player[i].targetframe=0;
10740 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10744 for(k=0;k<numplayers;k++){
10745 if(abs(player[k].rotation-player[k].targetrotation)>180){
10746 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10747 else player[k].rotation+=360;
10750 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10751 player[k].targetanimation=player[k].getStop();
10752 player[k].targetframe=0;
10753 player[k].target=0;
10756 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10757 player[k].targettilt=0;
10759 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10760 player[k].targettilt=0;
10761 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10762 player[k].jumppower+=multiplier*7;
10763 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10764 //*(1-(player[k].damage/player[k].damagetolerance))
10765 if(player[k].jumppower>5)player[k].jumppower=5;
10768 if(player[k].isRun()){
10769 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10772 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10773 else if(player[k].tilt>player[k].targettilt){
10774 player[k].tilt-=multiplier*150;
10776 else if(player[k].tilt<player[k].targettilt){
10777 player[k].tilt+=multiplier*150;
10780 player[k].grabdelay-=multiplier;
10783 for(k=0;k<numplayers;k++){
10784 player[k].DoAnimations();
10785 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10786 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10791 player[0].righthandmorphstart=0;
10792 player[0].righthandmorphend=1;
10793 player[0].lefthandmorphstart=0;
10794 player[0].lefthandmorphend=1;
10795 player[0].headmorphstart=0;
10796 player[0].headmorphend=2;*/
10799 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10800 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10801 player[0].righthandmorphend=1;
10802 player[0].targetrighthandmorphness=1;
10804 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10805 player[0].lefthandmorphend=0;
10806 player[0].targetlefthandmorphness=1;
10808 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10809 player[0].headmorphend=2;
10810 player[0].targetheadmorphness=1;
10812 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10813 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10814 player[0].righthandmorphend=0;
10815 player[0].targetrighthandmorphness=1;
10817 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10818 player[0].lefthandmorphend=1;
10819 player[0].targetlefthandmorphness=1;
10821 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10822 player[0].headmorphend=0;
10823 player[0].targetheadmorphness=1;
10826 if(numenvsounds!=0)
10827 for(j=numenvsounds-1;j>=0;j--){
10828 envsoundlife[j]-=multiplier;
10829 if(envsoundlife[j]<0){
10831 envsoundlife[j]=envsoundlife[numenvsounds];
10832 envsound[j]=envsound[numenvsounds];
10835 if(!slomo)FSOUND_SetFrequency(FSOUND_ALL, 22050);
10836 if(slomo)FSOUND_SetFrequency(FSOUND_ALL, slomofreq);
10838 if(tutoriallevel==1){
10855 if(tutorialstage>=51)
10856 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10857 FSOUND_StopSound(FSOUND_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10858 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
10860 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10861 FSOUND_SetPaused(channels[stream_music3], false);
10862 FSOUND_SetVolume(channels[stream_music3], 256);
10867 float gLoc[3]={0,0,0};
10868 float vel[3]={0,0,0};
10869 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10870 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10871 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10872 FSOUND_SetVolume(channels[fireendsound], 256);
10873 FSOUND_SetPaused(channels[fireendsound], false);
10874 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10882 if(tutorialstage<51)
10883 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10886 gLoc[0]=player[0].coords.x;
10887 gLoc[1]=player[0].coords.y;
10888 gLoc[2]=player[0].coords.z;
10892 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10893 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10894 FSOUND_SetVolume(channels[fireendsound], 256);
10895 FSOUND_SetPaused(channels[fireendsound], false);
10897 player[0].coords=(oldtemp+oldtemp2)/2;
10905 if(tutorialstage>=14&&tutorialstage<50)
10906 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10909 gLoc[0]=player[1].coords.x;
10910 gLoc[1]=player[1].coords.y;
10911 gLoc[2]=player[1].coords.z;
10915 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10916 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10917 FSOUND_SetVolume(channels[fireendsound], 256);
10918 FSOUND_SetPaused(channels[fireendsound], false);
10920 for(int i=0;i<player[1].skeleton.num_joints;i++){
10922 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10923 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10924 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;
10925 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10926 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10930 player[1].coords=(oldtemp+oldtemp2)/2;
10931 for(int i=0;i<player[1].skeleton.num_joints;i++){
10932 player[1].skeleton.joints[i].velocity=0;
10934 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10935 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10936 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;
10937 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10938 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10946 static float gLoc[3];
10950 static float vel[3];
10951 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10952 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10953 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10955 //Set orientation with forward and up vectors
10956 static XYZ upvector;
10960 upvector=DoRotation(upvector,-rotation2+90,0,0);
10961 upvector=DoRotation(upvector,0,0-rotation,0);
10966 facing=DoRotation(facing,-rotation2,0,0);
10967 facing=DoRotation(facing,0,0-rotation,0);
10970 static float ori[6];
10971 ori[0] = -facing.x;
10973 ori[2] = -facing.z;
10974 ori[3] = -upvector.x;
10975 ori[4] = upvector.y;
10976 ori[5] = -upvector.z;
10978 FSOUND_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10985 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10987 freezetogglekeydown=1;
10991 void Game::TickOnce(){
10994 if(directing||indialogue==-1){
10995 rotation+=deltah*.7;
10996 if(!invertmouse)rotation2+=deltav*.7;
10997 if(invertmouse)rotation2-=deltav*.7;
10998 if(rotation2>90)rotation2=90;
10999 if(rotation2<-70)rotation2=-70;
11001 if(mainmenu)rotation+=multiplier*5;
11002 if(!mainmenu&&!indemo&&!registered){
11003 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11004 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11005 FSOUND_SetPaused(channels[stream_music3], false);
11006 FSOUND_SetVolume(channels[stream_music3], 256);
11011 float gLoc[3]={0,0,0};
11012 float vel[3]={0,0,0};
11013 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11014 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11015 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11016 FSOUND_SetVolume(channels[fireendsound], 256);
11017 FSOUND_SetPaused(channels[fireendsound], false);
11018 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11027 if(tryquit==1&&!registered&&mainmenu!=12){
11028 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11029 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11030 FSOUND_SetPaused(channels[stream_music3], false);
11031 FSOUND_SetVolume(channels[stream_music3], 256);
11036 float gLoc[3]={0,0,0};
11037 float vel[3]={0,0,0};
11038 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11039 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11040 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11041 FSOUND_SetVolume(channels[fireendsound], 256);
11042 FSOUND_SetPaused(channels[fireendsound], false);
11043 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11054 void Game::TickOnceAfter(){
11055 static XYZ colviewer;
11056 static XYZ coltarget;
11059 static float brotate;
11062 static float changedelay;
11063 static bool alldead;
11064 static float unseendelay;
11065 static float cameraspeed;
11069 if(environment==snowyenvironment)music1=stream_music1snow;
11070 if(environment==grassyenvironment)music1=stream_music1grass;
11071 if(environment==desertenvironment)music1=stream_music1desert;
11076 for(i=0;i<numplayers;i++){
11077 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)){
11078 musictype=stream_music2;
11082 if(player[0].dead)musictype=stream_music3;
11085 if(musictype==stream_music2){
11089 if(oldmusictype==stream_music2&&musictype!=stream_music2){
11090 unseendelay-=multiplier;
11092 musictype=stream_music2;
11098 musictype=stream_music3;
11099 musicvolume[2]=512;
11106 if(musictype!=oldmusictype&&musictype==stream_music2){
11107 static float gLoc[3];
11108 static float vel[3];
11109 gLoc[0]=cameraloc.x;
11110 gLoc[1]=cameraloc.y;
11111 gLoc[2]=cameraloc.z;
11115 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
11116 FSOUND_SetVolume(channels[alarmsound], 512);
11117 FSOUND_SetPaused(channels[alarmsound], false);
11121 musicselected=musictype;
11123 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11124 else musicvolume[0]-=multiplier*450;
11125 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11126 else musicvolume[1]-=multiplier*450;
11127 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11128 else musicvolume[2]-=multiplier*450;
11130 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11131 else musicvolume[0]-=multiplier*450;
11132 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11133 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11134 else musicvolume[1]-=multiplier*100;
11135 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11136 else musicvolume[2]-=multiplier*450;*/
11139 if(musicvolume[i]<0)musicvolume[i]=0;
11140 if(musicvolume[i]>512)musicvolume[i]=512;
11143 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11146 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11147 PlayStreamEx( music1, strm[music1], NULL, true);
11148 FSOUND_SetPaused(channels[music1], false);
11150 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11151 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
11152 FSOUND_SetPaused(channels[stream_music2], false);
11154 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11155 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11156 FSOUND_SetPaused(channels[stream_music3], false);
11161 FSOUND_SetPaused(channels[music1], true);
11162 FSOUND_SetPaused(channels[stream_music2], true);
11163 FSOUND_SetPaused(channels[stream_music3], true);
11166 oldmusicvolume[i]=0;
11172 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11173 FSOUND_SetPaused(channels[music1], true);
11175 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11176 FSOUND_SetPaused(channels[stream_music2], true);
11178 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11179 FSOUND_SetPaused(channels[stream_music3], true);
11182 if(musicvolume[0]!=oldmusicvolume[0]){
11183 FSOUND_SetVolume(channels[music1], musicvolume[0]);
11185 if(musicvolume[1]!=oldmusicvolume[1]){
11186 FSOUND_SetVolume(channels[stream_music2], musicvolume[1]);
11188 if(musicvolume[2]!=oldmusicvolume[2]){
11189 FSOUND_SetVolume(channels[stream_music3], musicvolume[2]);
11193 oldmusicvolume[i]=musicvolume[i];
11199 for(i=0;i<numhotspots;i++){
11200 if(hotspottype[i]>10&&hotspottype[i]<20){
11201 if(player[hotspottype[i]-10].dead==0){
11204 else if(killhotspot==2)
11208 if(killhotspot==2)killhotspot=0;
11213 for(i=0;i<numhotspots;i++){
11214 if(hotspottype[i]==-1){
11215 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11222 for(i=1;i<numplayers;i++){
11223 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11225 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11227 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11228 if(player[0].dead&&changedelay<=0){
11230 targetlevel=whichlevel;
11234 for(i=1;i<numplayers;i++){
11235 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11239 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11241 targetlevel=whichlevel+1;
11242 if(targetlevel>numchallengelevels-1)targetlevel=0;
11244 if(winhotspot||windialogue){
11246 targetlevel=whichlevel+1;
11247 if(targetlevel>numchallengelevels-1)targetlevel=0;
11253 targetlevel=whichlevel+1;
11254 if(targetlevel>numchallengelevels-1)targetlevel=0;
11257 if(changedelay>0&&!player[0].dead&&!won){
11258 //high scores, awards, win
11261 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11262 accountcampaignchoicesmade[accountactive]++;
11263 accountcampaignscore[accountactive]+=bonustotal;
11265 accountcampaigntime[accountactive]+=leveltime;
11266 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11268 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11274 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11275 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11277 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11293 if(!editorenabled&&gameon&&!mainmenu){
11294 if(changedelay!=-999)changedelay-=multiplier/7;
11295 if(player[0].dead)targetlevel=whichlevel;
11296 if(loading==2&&!campaign){
11304 float gLoc[3]={0,0,0};
11305 float vel[3]={0,0,0};
11306 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11307 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11308 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11309 FSOUND_SetVolume(channels[firestartsound], 256);
11310 FSOUND_SetPaused(channels[firestartsound], false);
11311 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11313 if(!player[0].dead&&targetlevel!=whichlevel){
11314 startbonustotal=bonustotal;
11316 if(!player[0].dead)Loadlevel(targetlevel);
11317 if(player[0].dead)Loadlevel(whichlevel);
11319 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11320 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11321 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11322 FSOUND_SetVolume(channels[fireendsound], 256);
11323 FSOUND_SetPaused(channels[fireendsound], false);
11324 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11328 if(loading==2&&targetlevel==whichlevel){
11336 float gLoc[3]={0,0,0};
11337 float vel[3]={0,0,0};
11338 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11339 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11340 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11341 FSOUND_SetVolume(channels[firestartsound], 256);
11342 FSOUND_SetPaused(channels[firestartsound], false);
11343 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11345 for(i=0;i<255;i++){
11359 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11360 Loadlevel(mapname);
11362 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11363 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11364 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11365 FSOUND_SetVolume(channels[fireendsound], 256);
11366 FSOUND_SetPaused(channels[fireendsound], false);
11367 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11371 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11372 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11373 if(accountprogress[accountactive]>3&&!registered){
11374 FSOUND_SetFrequency(FSOUND_ALL, 0.001);
11375 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11376 FSOUND_SetPaused(channels[stream_music3], false);
11377 FSOUND_SetVolume(channels[stream_music3], 256);
11381 accountprogress[accountactive]=3;
11383 float gLoc[3]={0,0,0};
11384 float vel[3]={0,0,0};
11385 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11386 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11387 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11388 FSOUND_SetVolume(channels[fireendsound], 256);
11389 FSOUND_SetPaused(channels[fireendsound], false);
11390 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11399 if(whichlevel!=-2&&!loading&&!player[0].dead){
11403 if(player[0].dead)loading=1;
11409 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11410 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11414 else if(mainmenu==0&&winfreeze){
11415 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11417 else stealthloading=0;
11419 if(!stealthloading){
11420 float gLoc[3]={0,0,0};
11421 float vel[3]={0,0,0};
11422 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11423 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11424 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11425 FSOUND_SetVolume(channels[firestartsound], 256);
11426 FSOUND_SetPaused(channels[firestartsound], false);
11427 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11438 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11439 //campaignnumlevels=0;
11440 //accountcampaignchoicesmade[accountactive]=0;
11441 ipstream.ignore(256,':');
11442 ipstream >> campaignnumlevels;
11443 for(i=0;i<campaignnumlevels;i++){
11444 ipstream.ignore(256,':');
11445 ipstream.ignore(256,':');
11446 ipstream.ignore(256,' ');
11447 ipstream >> campaignmapname[i];
11448 ipstream.ignore(256,':');
11449 ipstream >> campaigndescription[i];
11450 for(j=0;j<256;j++){
11451 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11453 ipstream.ignore(256,':');
11454 ipstream >> campaignchoosenext[i];
11455 ipstream.ignore(256,':');
11456 ipstream >> campaignnumnext[i];
11457 if(campaignnumnext[i])
11458 for(j=0;j<campaignnumnext[i];j++){
11459 ipstream.ignore(256,':');
11460 ipstream >> campaignnextlevel[i][j];
11461 campaignnextlevel[i][j]-=1;
11463 ipstream.ignore(256,':');
11464 ipstream >> campaignlocationx[i];
11465 ipstream.ignore(256,':');
11466 ipstream >> campaignlocationy[i];
11470 for(i=0;i<campaignnumlevels;i++){
11472 levelhighlight[i]=0;
11476 for(i=0;i<campaignnumlevels;i++){
11478 levelhighlight[i]=0;
11483 if(accountcampaignchoicesmade[accountactive])
11484 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11485 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11486 levelvisible[levelorder[i+1]]=1;
11488 int whichlevelstart;
11489 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11490 if(whichlevelstart<0){
11491 campaignchoicenum=1;
11492 campaignchoicewhich[0]=0;
11496 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11497 if(campaignchoicenum)
11498 for(i=0;i<campaignchoicenum;i++){
11499 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11500 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11501 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11508 //if(firstload)TickOnceAfter();
11509 if(!firstload)LoadStuff();
11511 for(i=0;i<255;i++){
11526 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11527 //accountcampaignchoicesmade[accountactive]++;
11530 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11534 Loadlevel(mapname);
11538 FSOUND_SetPaused(channels[stream_music3], true);
11543 if(loading==3)loading=0;
11547 oldmusictype=musictype;
11553 facing=DoRotation(facing,-rotation2,0,0);
11554 facing=DoRotation(facing,0,0-rotation,0);
11555 viewerfacing=facing;
11559 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;
11560 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;
11562 if(player[0].skeleton.free){
11563 for(i=0;i<player[0].skeleton.num_joints;i++){
11564 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11565 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11569 if(player[0].skeleton.free!=2&&!autocam){
11571 if(findLengthfast(&player[0].velocity)>400){
11572 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11574 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11575 coltarget=target-cameraloc;
11576 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11578 Normalise(&coltarget);
11579 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11580 else cameraloc=cameraloc+coltarget*multiplier*8;
11582 if(editorenabled)cameraloc=target;
11583 cameradist+=multiplier*5;
11584 if(cameradist>2.3)cameradist=2.3;
11585 viewer=cameraloc-facing*cameradist;
11587 coltarget=cameraloc;
11588 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11589 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11590 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11591 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11593 coltarget=cameraloc;
11594 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11596 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11597 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11598 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11600 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11604 cameradist=findDistance(&viewer,&target);
11605 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11606 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11608 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11609 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11612 if(player[0].skeleton.free!=2&&autocam){
11614 if(findLengthfast(&player[0].velocity)>400){
11615 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11617 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11618 cameradist+=multiplier*5;
11619 if(cameradist>3.3)cameradist=3.3;
11620 coltarget=target-cameraloc;
11621 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11622 else if(findLengthfast(&coltarget)>1)
11624 Normalise(&coltarget);
11625 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11626 else cameraloc=cameraloc+coltarget*multiplier*8;
11628 if(editorenabled)cameraloc=target;
11631 coltarget=cameraloc;
11632 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11633 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11634 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11635 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11637 coltarget=cameraloc;
11638 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11640 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11641 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11642 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11644 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11648 cameradist=findDistance(&viewer,&target);
11649 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11650 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11652 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11653 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11656 if(camerashake>.8)camerashake=.8;
11657 //if(woozy>10)woozy=10;
11658 //woozy+=multiplier;
11660 if(player[0].dead)camerashake=0;
11661 if(player[0].dead)woozy=0;
11662 camerashake-=multiplier*2;
11663 blackout-=multiplier*2;
11664 //if(player[0].isCrouch())woozy-=multiplier*8;
11665 if(camerashake<0)camerashake=0;
11666 if(blackout<0)blackout=0;
11667 //if(woozy<0)woozy=0;
11669 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11670 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11671 viewer.z+=(float)(Random()%100)*.0005*camerashake;