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>
32 #include "openal_wrapper.h"
36 extern float multiplier;
38 extern int environment;
39 extern float texscale;
40 extern Terrain terrain;
41 extern OPENAL_SAMPLE *samp[100];
42 extern int channels[100];
43 extern Sprites sprites;
44 extern int kTextureSize;
45 extern float screenwidth,screenheight;
48 extern float texdetail;
49 extern Objects objects;
51 extern float slomodelay;
52 extern bool floatjump;
54 extern Animation animation[animation_count];
56 extern float texdetail;
57 extern GLubyte bloodText[512*512*3];
58 extern GLubyte wolfbloodText[512*512*3];
59 extern float terraindetail;
60 extern float camerashake;
62 extern float blackout;
63 extern bool cellophane;
64 extern bool musictoggle;
65 extern int difficulty;
66 extern Weapons weapons;
67 extern Person player[maxplayers];
68 extern int numplayers;
69 extern int bloodtoggle;
70 extern bool invertmouse;
72 extern float precipdelay;
73 extern XYZ viewerfacing;
74 extern bool ambientsound;
75 extern bool mousejump;
76 extern float viewdistance;
78 extern bool autoslomo;
79 extern bool keyboardfrozen;
80 extern int netdatanew;
81 extern bool loadingstuff;
82 extern char mapname[256];
83 extern XYZ windvector;
84 extern bool buttons[3];
85 extern bool debugmode;
88 extern int oldmainmenu;
89 extern bool visibleloading;
90 extern int loadscreencolor;
91 extern float flashamount,flashr,flashg,flashb;
92 extern int flashdelay;
93 extern XYZ envsound[30];
94 extern float envsoundvol[30];
95 extern int numenvsounds;
96 extern float envsoundlife[30];
97 extern float usermousesensitivity;
98 extern bool ismotionblur;
100 extern bool trilinear;
101 extern bool damageeffects;
102 extern bool showpoints;
103 extern bool texttoggle;
104 extern bool alwaysblur;
105 extern float gamespeed;
108 extern bool immediate;
109 extern bool velocityblur;
112 extern float bonusvalue;
113 extern float bonustotal;
114 extern float bonustime;
115 extern float startbonustotal;
116 extern float tintr,tintg,tintb;
117 extern float bonusnum[100];
118 extern bool skyboxtexture;
119 extern float skyboxr;
120 extern float skyboxg;
121 extern float skyboxb;
122 extern float skyboxlightr;
123 extern float skyboxlightg;
124 extern float skyboxlightb;
125 extern float fadestart;
126 extern float slomospeed;
127 extern float slomofreq;
128 extern int tutoriallevel;
129 extern float smoketex;
130 extern float tutorialstagetime;
131 extern int tutorialstage;
132 extern float tutorialmaxtime;
133 extern float tutorialsuccess;
134 extern bool againbonus;
135 extern bool reversaltrain;
136 extern bool canattack;
137 extern bool cananger;
138 extern float damagedealt;
139 extern float damagetaken;
141 extern int editoractive;
142 extern int editorpathtype;
143 extern bool oldbuttons[3];
145 extern float hostiletime;
147 extern bool gamestarted;
149 extern int numhotspots;
150 extern int winhotspot;
151 extern int windialogue;
152 extern int killhotspot;
153 extern XYZ hotspot[40];
154 extern int hotspottype[40];
155 extern float hotspotsize[40];
156 extern char hotspottext[40][256];
157 extern int currenthotspot;
159 extern int kBitsPerPixel;
162 extern int numaccounts;
163 extern int accountactive;
164 extern int accountdifficulty[10];
165 extern int accountprogress[10];
166 extern float accountpoints[10];
167 extern float accounthighscore[10][50];
168 extern float accountfasttime[10][50];
169 extern bool accountunlocked[10][60];
170 extern char accountname[10][256];
172 extern bool stillloading;
173 extern bool winfreeze;
176 extern int numflipfail;
178 extern int numstaffattack;
179 extern int numswordattack;
180 extern int numknifeattack;
181 extern int numunarmedattack;
182 extern int numescaped;
183 extern int numflipped;
184 extern int numwallflipped;
185 extern int numthrowkill;
186 extern int numafterkill;
187 extern int numreversals;
188 extern int numattacks;
189 extern int maxalarmed;
190 extern int numresponded;
192 extern int numdialogues;
193 extern int numdialogueboxes[max_dialogues];
194 extern int dialoguetype[max_dialogues];
195 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
196 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
197 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
198 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
199 extern char dialoguename[max_dialogues][max_dialoguelength][64];
200 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
201 extern XYZ participantlocation[max_dialogues][10];
202 extern int participantfocus[max_dialogues][max_dialoguelength];
203 extern int participantaction[max_dialogues][max_dialoguelength];
204 extern float participantrotation[max_dialogues][10];
205 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
206 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
207 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
208 extern int indialogue;
209 extern int whichdialogue;
210 extern int directing;
211 extern float dialoguetime;
212 extern int dialoguegonethrough[20];
214 extern bool campaign;
216 extern float oldgamespeed;
218 extern float accountcampaignhighscore[10];
219 extern float accountcampaignfasttime[10];
220 extern float accountcampaignscore[10];
221 extern float accountcampaigntime[10];
223 extern int accountcampaignchoicesmade[10];
224 extern int accountcampaignchoices[10][5000];
225 /********************> Tick() <*****/
226 extern OPENAL_STREAM * strm[20];
227 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
228 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
230 extern void ScreenShot(const char * fname);
231 void Screenshot (void)
234 time_t t = time(NULL);
235 struct tm *tme = localtime(&t);
236 sprintf(temp, "Screenshots\\Screenshot_%04d_%02d_%02d--%02d_%02d_%02d.png", tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
239 mkdir("Screenshots");
241 mkdir("Screenshots", S_IRWXU);
244 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
247 GraphicsExportComponent QT_exporter;
248 OSErr MAC_error_code;
249 CGrafPtr MAC_currentPort;
250 GDHandle MAC_currentDevice;
251 unsigned char* MAC_pixels;
252 Rect MAC_picture_rectangle;
253 GWorldPtr MAC_offscreen_graphics_port;
255 static int numscreenshots=0;
258 static char buf[256];
259 if(numscreenshots==0){
290 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
291 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
292 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
293 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
314 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
315 //assert(MAC_gWorld != NULL);
317 // Allocate memory for loading image
318 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
319 if (MAC_pixels == NULL) {
320 //UTIL_Error("Could not create Texture data.");
325 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
327 // Make a picture Rectangle
328 MAC_picture_rectangle.left = 0;
329 MAC_picture_rectangle.right = screenwidth;
330 MAC_picture_rectangle.top = 0;
331 MAC_picture_rectangle.bottom = screenheight;
333 // Create new offscreen GWorld
334 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
335 if (MAC_error_code) {
336 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
338 //UTIL_Error("Could not create offscreen GWorld. ");
343 // Copy OpenGL Context to new GWorld
344 glReadBuffer(GL_FRONT);
345 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
348 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
349 unsigned char temp = MAC_pixels[byte+0];
350 MAC_pixels[byte+0] = MAC_pixels[byte+3];
351 MAC_pixels[byte+3] = MAC_pixels[byte+2];
352 MAC_pixels[byte+2] = MAC_pixels[byte+1];
353 MAC_pixels[byte+1] = temp;
356 // Flip the image :( This could probably be optimized
361 for (int horz = 0; horz < screenwidth; ++horz)
362 for (vert = 0; vert < screenheight / 2; ++vert) {
363 src_index = (screenwidth * vert + horz) * 4;
364 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
366 temp=MAC_pixels[src_index+0];
367 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
368 MAC_pixels[dst_index+0]=temp;
370 temp=MAC_pixels[src_index+1];
371 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
372 MAC_pixels[dst_index+1]=temp;
374 temp=MAC_pixels[src_index+2];
375 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
376 MAC_pixels[dst_index+2]=temp;
378 temp=MAC_pixels[src_index+3];
379 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
380 MAC_pixels[dst_index+3]=temp;
386 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
387 if (MAC_error_code) {
388 //UTIL_Warning("Unable to export screenshot.");
389 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
390 ::DisposeGWorld(MAC_offscreen_graphics_port);
395 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
396 if (MAC_error_code) {
397 ::CloseComponent(QT_exporter);
398 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
399 ::DisposeGWorld(MAC_offscreen_graphics_port);
401 //UTIL_Warning("Unable to export screenshot.");
405 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
406 if (MAC_error_code) {
407 ::CloseComponent(QT_exporter);
408 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
409 ::DisposeGWorld(MAC_offscreen_graphics_port);
411 //UTIL_Warning("Unable to export screenshot.");
415 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
416 if (MAC_error_code) {
417 ::CloseComponent(QT_exporter);
418 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
419 ::DisposeGWorld(MAC_offscreen_graphics_port);
421 //UTIL_Warning("Unable to export screenshot.");
425 ::CloseComponent(QT_exporter);
426 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
427 ::DisposeGWorld(MAC_offscreen_graphics_port);
434 void Game::SetUpLighting(){
435 if(environment==snowyenvironment){
441 light.ambient[2]=.44;
443 if(environment==desertenvironment){
448 light.ambient[1]=.35;
452 if(environment==grassyenvironment){
458 light.ambient[2]=.44;
469 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
470 light.color[0]*=(skyboxlightr+average)/2;
471 light.color[1]*=(skyboxlightg+average)/2;
472 light.color[2]*=(skyboxlightb+average)/2;
473 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
474 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
475 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
479 light.ambient[2]=0; */
482 int Game::findPathDist(int start,int end){
483 int i,j,k,smallestcount,count,connected;
484 int last,last2,last3,last4;
494 while(last!=end&&count<30){
496 for(j=0;j<numpathpoints;j++){
497 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
500 if(numpathpointconnect[j])
501 for(k=0;k<numpathpointconnect[j];k++){
502 if(pathpointconnect[j][k]==last)connected=1;
505 if(numpathpointconnect[last])
506 for(k=0;k<numpathpointconnect[last];k++){
507 if(pathpointconnect[last][k]==j)connected=1;
510 if(closest==-1||Random()%2==0){
521 if(count<smallestcount)smallestcount=count;
523 return smallestcount;
526 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
527 static XYZ colpoint,colviewer,coltarget;
528 static float minx,minz,maxx,maxz,miny,maxy;
537 if(minx>endpoint.x)minx=endpoint.x;
539 if(miny>endpoint.y)miny=endpoint.y;
541 if(minz>endpoint.z)minz=endpoint.z;
544 if(maxx<endpoint.x)maxx=endpoint.x;
546 if(maxy<endpoint.y)maxy=endpoint.y;
548 if(maxz<endpoint.z)maxz=endpoint.z;
557 for(i=0;i<objects.numobjects;i++){
558 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){
559 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
560 colviewer=startpoint;
562 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
567 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
572 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
573 static XYZ colpoint,colviewer,coltarget;
574 static float minx,minz,maxx,maxz,miny,maxy;
583 if(minx>endpoint.x)minx=endpoint.x;
585 if(miny>endpoint.y)miny=endpoint.y;
587 if(minz>endpoint.z)minz=endpoint.z;
590 if(maxx<endpoint.x)maxx=endpoint.x;
592 if(maxy<endpoint.y)maxy=endpoint.y;
594 if(maxz<endpoint.z)maxz=endpoint.z;
604 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){
605 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
606 colviewer=startpoint;
608 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
613 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
618 void Game::Setenvironment(int which)
622 LOG(" Setting environment...");
627 OPENAL_SetPaused(channels[music1snow], true);
628 OPENAL_SetPaused(channels[music1grass], true);
629 OPENAL_SetPaused(channels[music1desert], true);
630 OPENAL_SetPaused(channels[wind], true);
631 OPENAL_SetPaused(channels[desertambient], true);
633 OPENAL_SetPaused(channels[stream_music1snow], true);
634 OPENAL_SetPaused(channels[stream_music1grass], true);
635 OPENAL_SetPaused(channels[stream_music1desert], true);
636 OPENAL_SetPaused(channels[stream_wind], true);
637 OPENAL_SetPaused(channels[stream_desertambient], true);
640 if(environment==snowyenvironment){
644 //PlaySoundEx( wind, samp[wind], NULL, true);
645 PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
646 OPENAL_SetPaused(channels[stream_wind], false);
647 OPENAL_SetVolume(channels[stream_wind], 256);
650 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
651 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
652 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
653 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
655 OPENAL_Sample_Free(samp[footstepsound]);
656 OPENAL_Sample_Free(samp[footstepsound2]);
657 OPENAL_Sample_Free(samp[footstepsound3]);
658 OPENAL_Sample_Free(samp[footstepsound4]);
659 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow1.ogg", OPENAL_HW3D, 0, 0);
660 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow2.ogg", OPENAL_HW3D, 0, 0);
661 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone1.ogg", OPENAL_HW3D, 0, 0);
662 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone2.ogg", OPENAL_HW3D, 0, 0);
663 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
664 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
665 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
666 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
668 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
670 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
672 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
677 temptexdetail=texdetail;
678 if(texdetail>1)texdetail=4;
679 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
680 ":Data:Textures:Skybox(snow):Left.jpg",
681 ":Data:Textures:Skybox(snow):Back.jpg",
682 ":Data:Textures:Skybox(snow):Right.jpg",
683 ":Data:Textures:Skybox(snow):Up.jpg",
684 ":Data:Textures:Skybox(snow):Down.jpg",
685 ":Data:Textures:Skybox(snow):Cloud.jpg",
686 ":Data:Textures:Skybox(snow):Reflect.jpg");
691 texdetail=temptexdetail;
693 if(environment==desertenvironment){
696 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
697 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
698 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
699 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
703 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
704 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
705 OPENAL_SetPaused(channels[stream_desertambient], false);
706 OPENAL_SetVolume(channels[stream_desertambient], 256);
709 OPENAL_Sample_Free(samp[footstepsound]);
710 OPENAL_Sample_Free(samp[footstepsound2]);
711 OPENAL_Sample_Free(samp[footstepsound3]);
712 OPENAL_Sample_Free(samp[footstepsound4]);
713 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow1.ogg", OPENAL_HW3D, 0, 0);
714 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow2.ogg", OPENAL_HW3D, 0, 0);
715 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow1.ogg", OPENAL_HW3D, 0, 0);
716 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow2.ogg", OPENAL_HW3D, 0, 0);
717 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
718 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
719 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
720 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
722 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
724 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
726 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
730 temptexdetail=texdetail;
731 if(texdetail>1)texdetail=4;
732 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
733 ":Data:Textures:Skybox(sand):Left.jpg",
734 ":Data:Textures:Skybox(sand):Back.jpg",
735 ":Data:Textures:Skybox(sand):Right.jpg",
736 ":Data:Textures:Skybox(sand):Up.jpg",
737 ":Data:Textures:Skybox(sand):Down.jpg",
738 ":Data:Textures:Skybox(sand):Cloud.jpg",
739 ":Data:Textures:Skybox(sand):Reflect.jpg");
744 texdetail=temptexdetail;
746 if(environment==grassyenvironment){
749 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
750 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
751 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
752 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
755 PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
756 OPENAL_SetPaused(channels[stream_wind], false);
757 OPENAL_SetVolume(channels[stream_wind], 100);
760 OPENAL_Sample_Free(samp[footstepsound]);
761 OPENAL_Sample_Free(samp[footstepsound2]);
762 OPENAL_Sample_Free(samp[footstepsound3]);
763 OPENAL_Sample_Free(samp[footstepsound4]);
764 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepgrass1.ogg", OPENAL_HW3D, 0, 0);
765 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepgrass2.ogg", OPENAL_HW3D, 0, 0);
766 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone1.ogg", OPENAL_HW3D, 0, 0);
767 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone2.ogg", OPENAL_HW3D, 0, 0);
768 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
769 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
770 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
771 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
773 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
775 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
777 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
781 temptexdetail=texdetail;
782 if(texdetail>1)texdetail=4;
783 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
784 ":Data:Textures:Skybox(grass):Left.jpg",
785 ":Data:Textures:Skybox(grass):Back.jpg",
786 ":Data:Textures:Skybox(grass):Right.jpg",
787 ":Data:Textures:Skybox(grass):Up.jpg",
788 ":Data:Textures:Skybox(grass):Down.jpg",
789 ":Data:Textures:Skybox(grass):Cloud.jpg",
790 ":Data:Textures:Skybox(grass):Reflect.jpg");
794 texdetail=temptexdetail;
796 temptexdetail=texdetail;
798 terrain.load(":Data:Textures:heightmap.png");
800 texdetail=temptexdetail;
804 void Game::Loadlevel(int which){
807 if(which==0)Loadlevel((char *)":Data:Maps:map1");
808 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
809 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
810 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
811 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
812 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
813 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
814 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
815 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
816 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
817 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
818 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
819 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
820 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
821 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
822 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
823 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
824 else Loadlevel((char *)":Data:Maps:mapsave");
829 /*char * Game::MD5_string (unsigned char *string){
833 strcpy(temp2,(const char *)string);
834 strcat((char *)temp2,(const char *)"Lugaru");
835 sprintf (temp, "%d",strlen((char *)temp2));
836 strcat((char *)temp2,temp);
839 unsigned int len = strlen ( (char *)temp2);
841 context.update ((unsigned char *)temp2, len);
844 return context.hex_digest();
849 void Game::Loadlevel(char *name){
856 float headprop,legprop,armprop,bodyprop;
860 LOG(std::string("Loading level...") + name);
862 if(!gameon)visibleloading=1;
864 if(stealthloading)visibleloading=0;
866 if(!stillloading)loadtime=0;
871 if(tutoriallevel!=-1)tutoriallevel=0;
872 else tutoriallevel=1;
874 if(tutoriallevel==1)tutorialstage=0;
875 if(tutorialstage==0){
883 OPENAL_SetPaused(channels[whooshsound], true);
884 OPENAL_SetPaused(channels[stream_firesound], true);
888 tfile=fopen( name, "rb" );
891 OPENAL_SetPaused(channels[stream_firesound], true);
902 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
908 dialoguegonethrough[i]=0;
917 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
919 if(difficulty!=2)minimap=1;
956 bonustotal=startbonustotal;
962 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
963 OPENAL_SetVolume(channels[consolesuccesssound], 256);
964 OPENAL_SetPaused(channels[consolesuccesssound], false);
972 sprites.numsprites=0;
973 for(i=0;i<objects.numobjects;i++)
975 objects.model[i].numdecals=0;
978 j=objects.numobjects;
981 objects.DeleteObject(0);
982 if(visibleloading){loadscreencolor=4; LoadingScreen();}
985 for(i=0;i<subdivision;i++)
987 for(j=0;j<subdivision;j++)
989 terrain.patchobjectnum[i][j]=0;
992 if(visibleloading){loadscreencolor=4; LoadingScreen();}
995 weapons.numweapons=0;
997 funpackf(tfile, "Bi", &mapvers);
998 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1000 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1001 else maptype=mapkilleveryone;
1002 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1004 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1010 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1018 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1021 skyboxlightr=skyboxr;
1022 skyboxlightg=skyboxg;
1023 skyboxlightb=skyboxb;
1025 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);
1026 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1027 player[0].originalcoords=player[0].coords;
1028 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1030 for(j=0;j<player[0].num_weapons;j++)
1032 player[0].weaponids[j]=weapons.numweapons;
1033 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1034 weapons.owner[weapons.numweapons]=0;
1035 weapons.numweapons++;
1039 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1041 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1042 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1043 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1044 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1046 funpackf(tfile, "Bi", &player[0].numclothes);
1050 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1054 player[0].whichskin=0;
1055 player[0].creature=rabbittype;
1058 for(i=0;i<max_dialogues;i++)
1060 for(j=0;j<max_dialoguelength;j++)
1064 dialoguetext[i][j][k]='\0';
1068 dialoguename[i][j][k]='\0';
1073 player[0].lastattack=-1;
1074 player[0].lastattack2=-1;
1075 player[0].lastattack3=-1;
1079 funpackf(tfile, "Bi", &numdialogues);
1082 for(k=0;k<numdialogues;k++)
1084 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1085 funpackf(tfile, "Bi", &dialoguetype[k]);
1088 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1089 funpackf(tfile, "Bf", &participantrotation[k][l]);
1091 if(numdialogueboxes)
1093 for(l=0;l<numdialogueboxes[k];l++)
1095 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1096 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1097 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1098 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1099 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1103 funpackf(tfile, "Bi",&templength);
1104 if(templength>128||templength<=0)templength=128;
1105 for(m=0;m<templength;m++){
1106 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1107 if(dialoguetext[k][l][m]=='\0')break;
1110 funpackf(tfile, "Bi",&templength);
1111 if(templength>64||templength<=0)templength=64;
1112 for(m=0;m<templength;m++){
1113 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1114 if(dialoguename[k][l][m]=='\0'){
1118 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1119 funpackf(tfile, "Bi", &participantfocus[k][l]);
1120 funpackf(tfile, "Bi", &participantaction[k][l]);
1123 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1125 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1131 else numdialogues=0;
1133 if(player[0].numclothes)
1135 for(k=0;k<player[0].numclothes;k++)
1137 funpackf(tfile, "Bi", &templength);
1138 for(l=0;l<templength;l++)
1139 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1140 player[0].clothes[k][templength]='\0';
1141 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1145 funpackf(tfile, "Bi", &environment);
1147 funpackf(tfile, "Bi", &objects.numobjects);
1148 if(objects.numobjects)
1150 for(i=0;i<objects.numobjects;i++)
1152 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]);
1153 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1159 funpackf(tfile, "Bi", &numhotspots);
1162 for(i=0;i<numhotspots;i++)
1164 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1165 funpackf(tfile, "Bi", &templength);
1167 for(l=0;l<templength;l++)
1168 funpackf(tfile, "Bb", &hotspottext[i][l]);
1169 hotspottext[i][templength]='\0';
1170 if(hotspottype[i]==-111)indemo=1;
1176 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1181 for(i=0;i<objects.numobjects;i++)
1183 objects.center+=objects.position[i];
1185 objects.center/=objects.numobjects;
1188 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1190 float maxdistance=0;
1193 for(i=0;i<objects.numobjects;i++)
1195 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1196 if(tempdist>maxdistance)
1199 maxdistance=tempdist;
1202 objects.radius=fast_sqrt(maxdistance);
1205 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1206 //mapcenter=objects.center;
1207 //mapradius=objects.radius;
1209 funpackf(tfile, "Bi", &numplayers);
1210 int howmanyremoved=0;
1211 bool removeanother=0;
1212 if(numplayers>1&&numplayers<maxplayers)
1214 for(i=1;i<numplayers;i++)
1216 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1219 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);
1220 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1221 else player[i-howmanyremoved].howactive=typeactive;
1222 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1223 else player[i-howmanyremoved].scale=-1;
1224 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1225 else player[i-howmanyremoved].immobile=0;
1226 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1227 else player[i-howmanyremoved].rotation=0;
1228 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1229 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1235 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1237 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1239 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1240 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1241 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1242 weapons.numweapons++;
1245 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1246 //player[i-howmanyremoved].numwaypoints=10;
1247 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1249 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1250 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1251 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1252 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1253 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1256 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1257 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1259 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1260 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1261 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1262 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1264 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1272 if(player[i-howmanyremoved].creature==wolftype)
1274 player[i-howmanyremoved].proportionhead=1.1*headprop;
1275 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1276 player[i-howmanyremoved].proportionarms=1.1*armprop;
1277 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1280 if(player[i-howmanyremoved].creature==rabbittype)
1282 player[i-howmanyremoved].proportionhead=1.2*headprop;
1283 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1284 player[i-howmanyremoved].proportionarms=1.00*armprop;
1285 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1286 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1289 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1290 if(player[i-howmanyremoved].numclothes)
1292 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1295 funpackf(tfile, "Bi", &templength);
1296 for(l=0;l<templength;l++)
1297 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1298 player[i-howmanyremoved].clothes[k][templength]='\0';
1299 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1305 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1307 numplayers-=howmanyremoved;
1308 funpackf(tfile, "Bi", &numpathpoints);
1309 if(numpathpoints>30||numpathpoints<0)
1313 for(j=0;j<numpathpoints;j++)
1315 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1316 for(k=0;k<numpathpointconnect[j];k++){
1317 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1321 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1323 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1326 if(environment!=oldenvironment)Setenvironment(environment);
1327 oldenvironment=environment;
1331 j=objects.numobjects;
1332 objects.numobjects=0;
1335 //if(objects.type[i]!=spiketype)
1336 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1337 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1340 //if(skyboxtexture){
1341 terrain.DoShadows();
1342 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1343 objects.DoShadows();
1344 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1346 else terrain.DoLighting();
1352 oldlevel=whichlevel;
1355 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1356 for(i=0;i<numplayers;i++)
1358 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1362 if(i==0||player[i].scale<0)player[i].scale=.2;
1363 player[i].skeleton.free=0;
1364 player[i].skeleton.id=i;
1365 //if(Random()%2==0)player[i].creature=wolftype;
1366 //else player[i].creature=rabbittype;
1367 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1368 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);
1371 if(player[i].creature!=wolftype){
1372 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);
1373 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1375 if(player[i].creature==wolftype){
1376 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);
1382 texsize=512*512*3/texdetail/texdetail;
1383 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1384 //player[i].skeleton.skinText.resize(texsize);
1386 if(player[i].creature==rabbittype)
1388 if(player[i].whichskin==0){
1389 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1391 else if(player[i].whichskin==1){
1392 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1394 else if(player[i].whichskin==2){
1395 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1397 else if(player[i].whichskin==3){
1398 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1400 else if(player[i].whichskin==4){
1401 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1403 else if(player[i].whichskin==5){
1404 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1406 else if(player[i].whichskin==6){
1407 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1409 else if(player[i].whichskin==7){
1410 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1412 else if(player[i].whichskin==8){
1413 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1415 else if(player[i].whichskin==9){
1416 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1419 if(player[i].creature==wolftype)
1421 //k=abs(Random()%3);
1422 if(player[i].whichskin==0){
1423 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1425 else if(player[i].whichskin==1){
1426 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1428 else if(player[i].whichskin==2){
1429 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1433 if(player[i].numclothes)
1435 for(j=0;j<player[i].numclothes;j++)
1437 tintr=player[i].clothestintr[j];
1438 tintg=player[i].clothestintg[j];
1439 tintb=player[i].clothestintb[j];
1440 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1442 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1445 player[i].currentanimation=bounceidleanim;
1446 player[i].targetanimation=bounceidleanim;
1447 player[i].currentframe=0;
1448 player[i].targetframe=1;
1450 player[i].speed=1+(float)(Random()%100)/1000;
1451 if(difficulty==0)player[i].speed-=.2;
1452 if(difficulty==1)player[i].speed-=.1;
1454 player[i].velocity=0;
1455 player[i].oldcoords=player[i].coords;
1456 player[i].realoldcoords=player[i].coords;
1459 player[i].skeleton.id=i;
1460 player[i].updatedelay=0;
1461 player[i].normalsupdatedelay=0;
1463 player[i].aitype=passivetype;
1464 player[i].aitarget=0;
1465 player[i].madskills=0;
1469 player[i].proportionhead=1.2;
1470 player[i].proportionbody=1.05;
1471 player[i].proportionarms=1.00;
1472 player[i].proportionlegs=1.1;
1473 player[i].proportionlegs.y=1.05;
1475 player[i].headless=0;
1476 player[i].currentoffset=0;
1477 player[i].targetoffset=0;
1478 /*player[i].armorhead=1;
1479 player[i].armorhigh=1;
1480 player[i].armorlow=1;
1481 player[i].protectionhead=1;
1482 player[i].protectionhigh=1;
1483 player[i].protectionlow=1;
1484 player[i].metalhead=1;
1485 player[i].metalhigh=1;
1486 player[i].metallow=1;
1488 player[i].speedmult=1;*/
1490 player[i].damagetolerance=200;
1492 if(player[i].creature==wolftype)
1494 /*player[i].proportionhead=1.1;
1495 player[i].proportionbody=1.1;
1496 player[i].proportionarms=1.1;
1497 player[i].proportionlegs=1.1;
1498 player[i].proportionlegs.y=1.1;*/
1499 if(i==0||player[i].scale<0)player[i].scale=.23;
1501 player[i].damagetolerance=300;
1504 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1507 player[i].proportionhead.z=0;
1508 player[i].proportionbody.z=0;
1509 player[i].proportionarms.z=0;
1510 player[i].proportionlegs.z=0;
1513 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1515 player[i].headmorphness=0;
1516 player[i].targetheadmorphness=1;
1517 player[i].headmorphstart=0;
1518 player[i].headmorphend=0;
1520 player[i].pausetime=0;
1523 player[i].jumppower=5;
1525 player[i].permanentdamage=0;
1526 player[i].superpermanentdamage=0;
1528 player[i].forwardkeydown=0;
1529 player[i].leftkeydown=0;
1530 player[i].backkeydown=0;
1531 player[i].rightkeydown=0;
1532 player[i].jumpkeydown=0;
1533 player[i].crouchkeydown=0;
1534 player[i].throwkeydown=0;
1536 player[i].collided=-10;
1538 player[i].bloodloss=0;
1539 player[i].weaponactive=-1;
1540 player[i].weaponstuck=-1;
1541 player[i].bleeding=0;
1542 player[i].deathbleeding=0;
1543 player[i].stunned=0;
1544 player[i].hasvictim=0;
1545 player[i].wentforweapon=0;
1548 player[0].aitype=playercontrolled;
1549 player[0].weaponactive=-1;
1553 //player[0].speedmult=1/.9;
1554 player[0].power=1/.9;
1559 //player[0].speedmult=1/.8;
1560 player[0].power=1/.8;
1563 //player[0].weaponstuck=1;
1565 if(difficulty==1)player[0].damagetolerance=250;
1566 if(difficulty==0)player[0].damagetolerance=300;
1567 if(difficulty==0)player[0].armorhead*=1.5;
1568 if(difficulty==0)player[0].armorhigh*=1.5;
1569 if(difficulty==0)player[0].armorlow*=1.5;
1570 cameraloc=player[0].coords;
1572 rotation=player[0].rotation;
1574 hawkcoords=player[0].coords;
1577 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1578 //weapons.numweapons=numplayers;
1579 for(i=0;i<weapons.numweapons;i++)
1581 weapons.bloody[i]=0;
1582 weapons.blooddrip[i]=0;
1583 weapons.blooddripdelay[i]=0;
1584 weapons.onfire[i]=0;
1585 weapons.flamedelay[i]=0;
1586 weapons.damage[i]=0;
1587 //weapons.type[i]=sword;
1588 if(weapons.type[i]==sword){
1589 weapons.mass[i]=1.5;
1590 weapons.tipmass[i]=1;
1591 weapons.length[i]=.8;
1593 if(weapons.type[i]==staff){
1595 weapons.tipmass[i]=1;
1596 weapons.length[i]=1.5;
1598 if(weapons.type[i]==knife){
1600 weapons.tipmass[i]=1.2;
1601 weapons.length[i]=.25;
1603 weapons.position[i]=-1000;
1604 weapons.tippoint[i]=-1000;
1607 /* for(i=0;i<32;i++){
1609 OPENAL_StopSound(i);
1612 LOG("Starting background music...");
1614 OPENAL_StopSound(OPENAL_ALL);
1615 if(environment==snowyenvironment)
1619 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1620 OPENAL_SetPaused(channels[stream_wind], false);
1621 OPENAL_SetVolume(channels[stream_wind], 256);
1624 else if(environment==desertenvironment)
1628 //PlaySoundEx(desertambient,
1629 // samp[desertambient], NULL, true);
1630 PlayStreamEx(stream_desertambient,
1631 strm[stream_desertambient], NULL, true);
1632 OPENAL_SetPaused(channels[stream_desertambient], false);
1633 OPENAL_SetVolume(channels[stream_desertambient], 256);
1636 else if(environment==grassyenvironment)
1640 //PlaySoundEx(wind, samp[wind], NULL, true);
1641 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1642 OPENAL_SetPaused(channels[stream_wind], false);
1643 OPENAL_SetVolume(channels[stream_wind], 100);
1646 oldmusicvolume[0]=0;
1647 oldmusicvolume[1]=0;
1648 oldmusicvolume[2]=0;
1649 oldmusicvolume[3]=0;
1652 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1653 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1654 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1655 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1656 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1657 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1658 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1659 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1674 static int i,k,j,l,m;
1675 static XYZ facing,flatfacing,absflatfacing;
1676 static XYZ rotatetarget;
1678 static float oldtargetrotation;
1679 static int target, numgood;
1680 static XYZ tempcoords1,tempcoords2;
1683 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1684 static int whichhit;
1685 static bool donesomething;
1686 static bool oldjumpkeydown;
1690 float headprop,bodyprop,armprop,legprop;
1693 displaytime[i]+=multiplier;
1696 static unsigned char theKeyMap[16];
1697 GetKeys( theKeyMap );
1702 static bool mainmenutogglekeydown;
1704 if(mainmenu&&endgame==1)mainmenu=10;
1705 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1707 displaytext[0][j]=' ';
1712 mainmenutogglekeydown=1;
1714 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==13||mainmenu==17||mainmenu==10)){
1716 if(mainmenu==1||mainmenu==2||mainmenu==0){
1717 if(mainmenu==0&&!winfreeze)mainmenu=2;
1718 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1719 else if(mainmenu==0&&winfreeze){
1720 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1722 else stealthloading=0;
1724 if(!stealthloading){
1725 float gLoc[3]={0,0,0};
1726 float vel[3]={0,0,0};
1727 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1728 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1729 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1730 OPENAL_SetVolume(channels[firestartsound], 256);
1731 OPENAL_SetPaused(channels[firestartsound], false);
1732 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1743 for(i=0;i<campaignnumlevels;i++){
1745 levelhighlight[i]=0;
1750 if(accountcampaignchoicesmade[accountactive])
1751 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1752 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1753 levelvisible[levelorder[i+1]]=1;
1755 int whichlevelstart;
1756 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1757 if(whichlevelstart<0){
1758 campaignchoicenum=1;
1759 campaignchoicewhich[0]=0;
1763 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1764 if(campaignchoicenum)
1765 for(i=0;i<campaignchoicenum;i++){
1766 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1767 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1768 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1775 if(firstload)TickOnceAfter();
1776 if(!firstload)LoadStuff();
1793 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1794 //accountcampaignchoicesmade[accountactive]++;
1797 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1805 OPENAL_SetPaused(channels[music3], true);
1809 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1810 if(mainmenu&&musictoggle){
1811 if(mainmenu==1||mainmenu==2||mainmenu==100){
1812 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
1813 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1814 OPENAL_SetPaused(channels[stream_music3], false);
1815 OPENAL_SetVolume(channels[stream_music3], 256);
1816 OPENAL_SetPaused(channels[music1], true);
1820 OPENAL_SetPaused(channels[stream_music3], true);
1821 OPENAL_SetPaused(channels[music1], false);
1825 float gLoc[3]={0,0,0};
1826 float vel[3]={0,0,0};
1827 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1828 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1829 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1830 OPENAL_SetVolume(channels[fireendsound], 256);
1831 OPENAL_SetPaused(channels[fireendsound], false);
1832 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1840 if(newdetail>2)newdetail=detail;
1841 if(newdetail<0)newdetail=detail;
1842 if(newscreenwidth<0)newscreenwidth=screenwidth;
1843 if(newscreenheight<0)newscreenheight=screenheight;
1845 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1846 opstream << "Screenwidth:\n";
1847 opstream << newscreenwidth;
1848 opstream << "\nScreenheight:\n";
1849 opstream << newscreenheight;
1850 opstream << "\nMouse sensitivity:\n";
1851 opstream << usermousesensitivity;
1852 opstream << "\nBlur(0,1):\n";
1853 opstream << ismotionblur;
1854 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1855 opstream << newdetail;
1856 opstream << "\nFloating jump:\n";
1857 opstream << floatjump;
1858 opstream << "\nMouse jump:\n";
1859 opstream << mousejump;
1860 opstream << "\nAmbient sound:\n";
1861 opstream << ambientsound;
1862 opstream << "\nBlood (0,1,2):\n";
1863 opstream << bloodtoggle;
1864 opstream << "\nAuto slomo:\n";
1865 opstream << autoslomo;
1866 opstream << "\nFoliage:\n";
1867 opstream << foliage;
1868 opstream << "\nMusic:\n";
1869 opstream << musictoggle;
1870 opstream << "\nTrilinear:\n";
1871 opstream << trilinear;
1872 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1874 opstream << "\nInvert mouse:\n";
1875 opstream << invertmouse;
1876 opstream << "\nGamespeed:\n";
1877 if(oldgamespeed==0)oldgamespeed=1;
1878 opstream << oldgamespeed;
1879 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1880 opstream << difficulty;
1881 opstream << "\nDamage effects(blackout, doublevision):\n";
1882 opstream << damageeffects;
1883 opstream << "\nText:\n";
1884 opstream << texttoggle;
1885 opstream << "\nDebug:\n";
1886 opstream << debugmode;
1887 opstream << "\nVBL Sync:\n";
1888 opstream << vblsync;
1889 opstream << "\nShow Points:\n";
1890 opstream << showpoints;
1891 opstream << "\nAlways Blur:\n";
1892 opstream << alwaysblur;
1893 opstream << "\nImmediate mode (turn on on G5):\n";
1894 opstream << immediate;
1895 opstream << "\nVelocity blur:\n";
1896 opstream << velocityblur;
1897 opstream << "\nVolume:\n";
1899 opstream << "\nForward key:\n";
1900 opstream << KeyToChar(forwardkey);
1901 opstream << "\nBack key:\n";
1902 opstream << KeyToChar(backkey);
1903 opstream << "\nLeft key:\n";
1904 opstream << KeyToChar(leftkey);
1905 opstream << "\nRight key:\n";
1906 opstream << KeyToChar(rightkey);
1907 opstream << "\nJump key:\n";
1908 opstream << KeyToChar(jumpkey);
1909 opstream << "\nCrouch key:\n";
1910 opstream << KeyToChar(crouchkey);
1911 opstream << "\nDraw key:\n";
1912 opstream << KeyToChar(drawkey);
1913 opstream << "\nThrow key:\n";
1914 opstream << KeyToChar(throwkey);
1915 opstream << "\nAttack key:\n";
1916 opstream << KeyToChar(attackkey);
1917 opstream << "\nChat key:\n";
1918 opstream << KeyToChar(chatkey);
1921 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
1922 float gLoc[3]={0,0,0};
1923 float vel[3]={0,0,0};
1924 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1925 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1926 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1927 OPENAL_SetVolume(channels[fireendsound], 256);
1928 OPENAL_SetPaused(channels[fireendsound], false);
1929 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1937 if(mainmenu==3&&gameon)mainmenu=2;
1938 if(mainmenu==3&&!gameon)mainmenu=1;
1939 if(mainmenu==5&&gameon)mainmenu=2;
1940 if(mainmenu==5&&!gameon)mainmenu=1;
1941 if(mainmenu==4)mainmenu=3;
1942 if(mainmenu==6)mainmenu=5;
1943 if(mainmenu==7)mainmenu=1;
1944 if(mainmenu==9)mainmenu=5;
1945 if(mainmenu==11)mainmenu=5;
1946 if(mainmenu==13)mainmenu=12;
1947 if(mainmenu==10)mainmenu=5;
1953 mainmenutogglekeydown=1;
1955 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1956 mainmenutogglekeydown=0;
1960 /*static bool minimaptogglekeydown;
1961 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1963 minimaptogglekeydown=1;
1965 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1966 minimaptogglekeydown=0;
1970 static bool minimaptogglekeydown;
1971 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1972 if(tutorialstage!=51)
1973 tutorialstagetime=tutorialmaxtime;
1974 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
1975 OPENAL_SetVolume(channels[consolefailsound], 128);
1976 OPENAL_SetPaused(channels[consolefailsound], false);
1977 minimaptogglekeydown=1;
1979 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1980 minimaptogglekeydown=0;
1985 if(mainmenu==1||mainmenu==2){
1986 if(Button()&&!oldbutton&&selected==1){
1988 float gLoc[3]={0,0,0};
1989 float vel[3]={0,0,0};
1990 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1991 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1992 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1993 OPENAL_SetVolume(channels[firestartsound], 256);
1994 OPENAL_SetPaused(channels[firestartsound], false);
1995 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2004 if(accountactive!=-1)mainmenu=5;
2011 if(firstload)TickOnceAfter();
2012 if(!firstload)LoadStuff();
2018 OPENAL_SetPaused(channels[music3], true); */
2024 OPENAL_SetPaused(channels[stream_music3], true);
2025 OPENAL_SetPaused(channels[music1], false);
2029 if(Button()&&!oldbutton&&selected==2){
2030 float gLoc[3]={0,0,0};
2031 float vel[3]={0,0,0};
2032 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2033 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2034 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2035 OPENAL_SetVolume(channels[firestartsound], 256);
2036 OPENAL_SetPaused(channels[firestartsound], false);
2037 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2049 if(newdetail>2)newdetail=detail;
2050 if(newdetail<0)newdetail=detail;
2051 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2052 if(newscreenwidth<0)newscreenwidth=screenwidth;
2053 if(newscreenheight>3000)newscreenheight=screenheight;
2054 if(newscreenheight<0)newscreenheight=screenheight;
2057 if(Button()&&!oldbutton&&selected==3){
2058 float gLoc[3]={0,0,0};
2059 float vel[3]={0,0,0};
2060 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2061 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2062 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2063 OPENAL_SetVolume(channels[fireendsound], 256);
2064 OPENAL_SetPaused(channels[fireendsound], false);
2065 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2076 OPENAL_SetPaused(channels[stream_music3], true);
2084 if(Button())oldbutton=1;
2089 if(Button()&&!oldbutton&&selected!=-1){
2090 float gLoc[3]={0,0,0};
2091 float vel[3]={0,0,0};
2092 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2093 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2094 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2095 OPENAL_SetVolume(channels[firestartsound], 256);
2096 OPENAL_SetPaused(channels[firestartsound], false);
2097 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2099 if(Button()&&!oldbutton&&selected==0){
2101 extern SDL_Rect **resolutions;
2102 bool isCustomResolution = true;
2104 for (int i = 0; (!found) && (resolutions[i]); i++)
2106 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2107 isCustomResolution = false;
2109 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2112 if (resolutions[i] != NULL)
2114 newscreenwidth = (int) resolutions[i]->w;
2115 newscreenheight = (int) resolutions[i]->h;
2117 else if (isCustomResolution)
2119 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2121 newscreenwidth = (int) resolutions[0]->w;
2122 newscreenheight = (int) resolutions[0]->h;
2126 newscreenwidth = screenwidth;
2127 newscreenheight = screenheight;
2132 newscreenwidth = (int) resolutions[0]->w;
2133 newscreenheight = (int) resolutions[0]->h;
2141 newscreenwidth = (int) resolutions[0]->w;
2142 newscreenheight = (int) resolutions[0]->h;
2147 if(Button()&&!oldbutton&&selected==1){
2149 if(newdetail>2)newdetail=0;
2151 if(Button()&&!oldbutton&&selected==2){
2153 if(bloodtoggle>2)bloodtoggle=0;
2155 if(Button()&&!oldbutton&&selected==3){
2157 if(difficulty>2)difficulty=0;
2159 if(Button()&&!oldbutton&&selected==4){
2160 ismotionblur=1-ismotionblur;
2162 if(Button()&&!oldbutton&&selected==5){
2165 if(Button()&&!oldbutton&&selected==6){
2166 musictoggle=1-musictoggle;
2169 OPENAL_SetPaused(channels[music1], true);
2170 OPENAL_SetPaused(channels[stream_music2], true);
2171 OPENAL_SetPaused(channels[stream_music3], true);
2174 oldmusicvolume[i]=0;
2180 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2181 OPENAL_SetPaused(channels[stream_music3], false);
2182 OPENAL_SetVolume(channels[stream_music3], 256);
2185 if(Button()&&!oldbutton&&selected==9){
2186 invertmouse=1-invertmouse;
2188 if(Button()&&!oldbutton&&selected==10){
2189 usermousesensitivity+=.2;
2190 if(usermousesensitivity>2)usermousesensitivity=.2;
2192 if(Button()&&!oldbutton&&selected==11){
2194 if(volume>1.0001f)volume=0;
2195 OPENAL_SetSFXMasterVolume((int)(volume*255));
2197 if(Button()&&!oldbutton&&selected==7){
2198 /*float gLoc[3]={0,0,0};
2199 float vel[3]={0,0,0};
2200 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2201 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2202 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2203 OPENAL_SetVolume(channels[firestartsound], 256);
2204 OPENAL_SetPaused(channels[firestartsound], false);
2205 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2218 if(Button()&&!oldbutton&&selected==8){
2219 float gLoc[3]={0,0,0};
2220 float vel[3]={0,0,0};
2221 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2222 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2223 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2224 OPENAL_SetVolume(channels[fireendsound], 256);
2225 OPENAL_SetPaused(channels[fireendsound], false);
2226 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2234 if(newdetail>2)newdetail=detail;
2235 if(newdetail<0)newdetail=detail;
2236 if(newscreenwidth<0)newscreenwidth=screenwidth;
2237 if(newscreenheight<0)newscreenheight=screenheight;
2240 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2241 opstream << "Screenwidth:\n";
2242 opstream << newscreenwidth;
2243 opstream << "\nScreenheight:\n";
2244 opstream << newscreenheight;
2245 opstream << "\nMouse sensitivity:\n";
2246 opstream << usermousesensitivity;
2247 opstream << "\nBlur(0,1):\n";
2248 opstream << ismotionblur;
2249 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2250 opstream << newdetail;
2251 opstream << "\nFloating jump:\n";
2252 opstream << floatjump;
2253 opstream << "\nMouse jump:\n";
2254 opstream << mousejump;
2255 opstream << "\nAmbient sound:\n";
2256 opstream << ambientsound;
2257 opstream << "\nBlood (0,1,2):\n";
2258 opstream << bloodtoggle;
2259 opstream << "\nAuto slomo:\n";
2260 opstream << autoslomo;
2261 opstream << "\nFoliage:\n";
2262 opstream << foliage;
2263 opstream << "\nMusic:\n";
2264 opstream << musictoggle;
2265 opstream << "\nTrilinear:\n";
2266 opstream << trilinear;
2267 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2269 opstream << "\nInvert mouse:\n";
2270 opstream << invertmouse;
2271 opstream << "\nGamespeed:\n";
2272 if(oldgamespeed==0)oldgamespeed=1;
2273 opstream << oldgamespeed;
2274 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2275 opstream << difficulty;
2276 opstream << "\nDamage effects(blackout, doublevision):\n";
2277 opstream << damageeffects;
2278 opstream << "\nText:\n";
2279 opstream << texttoggle;
2280 opstream << "\nDebug:\n";
2281 opstream << debugmode;
2282 opstream << "\nVBL Sync:\n";
2283 opstream << vblsync;
2284 opstream << "\nShow Points:\n";
2285 opstream << showpoints;
2286 opstream << "\nAlways Blur:\n";
2287 opstream << alwaysblur;
2288 opstream << "\nImmediate mode (turn on on G5):\n";
2289 opstream << immediate;
2290 opstream << "\nVelocity blur:\n";
2291 opstream << velocityblur;
2292 opstream << "\nVolume:\n";
2294 opstream << "\nForward key:\n";
2295 opstream << KeyToChar(forwardkey);
2296 opstream << "\nBack key:\n";
2297 opstream << KeyToChar(backkey);
2298 opstream << "\nLeft key:\n";
2299 opstream << KeyToChar(leftkey);
2300 opstream << "\nRight key:\n";
2301 opstream << KeyToChar(rightkey);
2302 opstream << "\nJump key:\n";
2303 opstream << KeyToChar(jumpkey);
2304 opstream << "\nCrouch key:\n";
2305 opstream << KeyToChar(crouchkey);
2306 opstream << "\nDraw key:\n";
2307 opstream << KeyToChar(drawkey);
2308 opstream << "\nThrow key:\n";
2309 opstream << KeyToChar(throwkey);
2310 opstream << "\nAttack key:\n";
2311 opstream << KeyToChar(attackkey);
2312 opstream << "\nChat key:\n";
2313 opstream << KeyToChar(chatkey);
2316 if(mainmenu==3&&gameon)mainmenu=2;
2317 if(mainmenu==3&&!gameon)mainmenu=1;
2319 if(Button())oldbutton=1;
2323 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2324 float gLoc[3]={0,0,0};
2325 float vel[3]={0,0,0};
2326 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2327 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2328 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2329 OPENAL_SetVolume(channels[firestartsound], 256);
2330 OPENAL_SetPaused(channels[firestartsound], false);
2331 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2333 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2341 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2343 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2344 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2345 float gLoc[3]={0,0,0};
2346 float vel[3]={0,0,0};
2347 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2348 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2349 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2350 OPENAL_SetVolume(channels[fireendsound], 256);
2351 OPENAL_SetPaused(channels[fireendsound], false);
2352 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2356 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2357 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2361 if(keyselect==0)forwardkey=keynum;
2362 if(keyselect==1)backkey=keynum;
2363 if(keyselect==2)leftkey=keynum;
2364 if(keyselect==3)rightkey=keynum;
2365 if(keyselect==4)crouchkey=keynum;
2366 if(keyselect==5)jumpkey=keynum;
2367 if(keyselect==6)drawkey=keynum;
2368 if(keyselect==7)throwkey=keynum;
2369 if(keyselect==8)attackkey=keynum;
2374 if(Button()&&!oldbutton&&selected==9){
2375 float gLoc[3]={0,0,0};
2376 float vel[3]={0,0,0};
2377 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2378 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2379 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2380 OPENAL_SetVolume(channels[fireendsound], 256);
2381 OPENAL_SetPaused(channels[fireendsound], false);
2382 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2392 if(newdetail>2)newdetail=detail;
2393 if(newdetail<0)newdetail=detail;
2394 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2395 if(newscreenwidth<0)newscreenwidth=screenwidth;
2396 if(newscreenheight>3000)newscreenheight=screenheight;
2397 if(newscreenheight<0)newscreenheight=screenheight;
2404 accountcampaignchoicesmade[accountactive]=0;
2405 accountcampaignscore[accountactive]=0;
2406 accountcampaigntime[accountactive]=0;
2410 if(Button()&&!oldbutton&&selected==1){
2411 float gLoc[3]={0,0,0};
2412 float vel[3]={0,0,0};
2413 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2414 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2415 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2416 OPENAL_SetVolume(channels[firestartsound], 256);
2417 OPENAL_SetPaused(channels[firestartsound], false);
2418 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2431 if(firstload)TickOnceAfter();
2432 if(!firstload)LoadStuff();
2439 OPENAL_SetPaused(channels[stream_music3], true);
2441 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2442 float gLoc[3]={0,0,0};
2443 float vel[3]={0,0,0};
2444 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2445 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2446 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2447 OPENAL_SetVolume(channels[firestartsound], 256);
2448 OPENAL_SetPaused(channels[firestartsound], false);
2449 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2462 if(firstload)TickOnceAfter();
2463 if(!firstload)LoadStuff();
2479 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2480 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2484 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2489 OPENAL_SetPaused(channels[stream_music3], true);
2491 if(Button()&&!oldbutton&&selected==4){
2492 float gLoc[3]={0,0,0};
2493 float vel[3]={0,0,0};
2494 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2495 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2496 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2497 OPENAL_SetVolume(channels[fireendsound], 256);
2498 OPENAL_SetPaused(channels[fireendsound], false);
2499 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2507 if(mainmenu==5&&gameon)mainmenu=2;
2508 if(mainmenu==5&&!gameon)mainmenu=1;
2510 if(Button()&&!oldbutton&&selected==5){
2511 float gLoc[3]={0,0,0};
2512 float vel[3]={0,0,0};
2513 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2514 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2515 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2516 OPENAL_SetVolume(channels[fireendsound], 256);
2517 OPENAL_SetPaused(channels[fireendsound], false);
2518 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2528 if(Button()&&!oldbutton&&selected==3){
2529 float gLoc[3]={0,0,0};
2530 float vel[3]={0,0,0};
2531 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2532 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2533 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2534 OPENAL_SetVolume(channels[firestartsound], 256);
2535 OPENAL_SetPaused(channels[firestartsound], false);
2536 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2546 if(Button()&&!oldbutton&&selected==2){
2547 float gLoc[3]={0,0,0};
2548 float vel[3]={0,0,0};
2549 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2550 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2551 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2552 OPENAL_SetVolume(channels[firestartsound], 256);
2553 OPENAL_SetPaused(channels[firestartsound], false);
2554 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2564 if(Button())oldbutton=1;
2568 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2569 float gLoc[3]={0,0,0};
2570 float vel[3]={0,0,0};
2571 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2572 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2573 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2574 OPENAL_SetVolume(channels[firestartsound], 256);
2575 OPENAL_SetPaused(channels[firestartsound], false);
2576 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2588 targetlevel=selected;
2589 if(firstload)TickOnceAfter();
2590 if(!firstload)LoadStuff();
2592 Loadlevel(selected);
2598 OPENAL_SetPaused(channels[stream_music3], true);
2600 if(Button()&&!oldbutton&&selected==numchallengelevels){
2601 float gLoc[3]={0,0,0};
2602 float vel[3]={0,0,0};
2603 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2604 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2605 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2606 OPENAL_SetVolume(channels[fireendsound], 256);
2607 OPENAL_SetPaused(channels[fireendsound], false);
2608 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2618 if(Button())oldbutton=1;
2622 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2623 float gLoc[3]={0,0,0};
2624 float vel[3]={0,0,0};
2625 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2626 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2627 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2628 OPENAL_SetVolume(channels[firestartsound], 256);
2629 OPENAL_SetPaused(channels[firestartsound], false);
2630 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2642 targetlevel=selected;
2643 if(firstload)TickOnceAfter();
2644 if(!firstload)LoadStuff();
2646 Loadlevel(selected);
2652 OPENAL_SetPaused(channels[stream_music3], true);
2654 if(Button()&&!oldbutton&&selected==numchallengelevels){
2655 float gLoc[3]={0,0,0};
2656 float vel[3]={0,0,0};
2657 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2658 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2659 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2660 OPENAL_SetVolume(channels[fireendsound], 256);
2661 OPENAL_SetPaused(channels[fireendsound], false);
2662 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2672 if(Button())oldbutton=1;
2677 if(Button()&&!oldbutton&&selected==3){
2678 float gLoc[3]={0,0,0};
2679 float vel[3]={0,0,0};
2680 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2681 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2682 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2683 OPENAL_SetVolume(channels[fireendsound], 256);
2684 OPENAL_SetPaused(channels[fireendsound], false);
2685 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2695 if(Button())oldbutton=1;
2700 if(Button()&&!oldbutton&&selected!=-1){
2701 float gLoc[3]={0,0,0};
2702 float vel[3]={0,0,0};
2703 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2704 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2705 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2706 OPENAL_SetVolume(channels[firestartsound], 256);
2707 OPENAL_SetPaused(channels[firestartsound], false);
2708 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2710 if(Button()&&!oldbutton&&selected==1){
2711 float gLoc[3]={0,0,0};
2712 float vel[3]={0,0,0};
2713 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2714 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2715 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2716 OPENAL_SetVolume(channels[fireendsound], 256);
2717 OPENAL_SetPaused(channels[fireendsound], false);
2718 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2726 for(i=accountactive;i<numaccounts-1;i++){
2727 accountdifficulty[i]=accountdifficulty[i+1];
2728 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2729 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2730 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2732 accountpoints[i]=accountpoints[i+1];
2734 accounthighscore[i][j]=accounthighscore[i+1][j];
2735 accountfasttime[i][j]=accountfasttime[i+1][j];
2738 accountunlocked[i][j]=accountunlocked[i+1][j];
2741 accountname[i][j]=accountname[i+1][j];
2743 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2744 accountprogress[i]=accountprogress[i+1];
2745 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2746 accountcampaignscore[i]=accountcampaignscore[i+1];
2747 accountcampaigntime[i]=accountcampaigntime[i+1];
2756 if(Button()&&!oldbutton&&selected==2){
2757 float gLoc[3]={0,0,0};
2758 float vel[3]={0,0,0};
2759 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2760 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2761 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2762 OPENAL_SetVolume(channels[fireendsound], 256);
2763 OPENAL_SetPaused(channels[fireendsound], false);
2764 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2774 if(Button())oldbutton=1;
2778 if(Button()&&!oldbutton&&selected!=-1){
2779 float gLoc[3]={0,0,0};
2780 float vel[3]={0,0,0};
2781 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2782 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2783 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2784 OPENAL_SetVolume(channels[firestartsound], 256);
2785 OPENAL_SetPaused(channels[firestartsound], false);
2786 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2788 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2791 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2792 accountactive=selected-1;
2800 if(Button()&&!oldbutton&&selected==numaccounts+1){
2801 float gLoc[3]={0,0,0};
2802 float vel[3]={0,0,0};
2803 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2804 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2805 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2806 OPENAL_SetVolume(channels[fireendsound], 256);
2807 OPENAL_SetPaused(channels[fireendsound], false);
2808 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2819 displaytext[0][j]=' ';
2825 if(Button())oldbutton=1;
2829 if(Button()&&!oldbutton&&selected!=-1){
2830 float gLoc[3]={0,0,0};
2831 float vel[3]={0,0,0};
2832 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2833 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2834 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2835 OPENAL_SetVolume(channels[firestartsound], 256);
2836 OPENAL_SetPaused(channels[firestartsound], false);
2837 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2839 if(selected==0)accountdifficulty[accountactive]=0;
2840 if(selected==1)accountdifficulty[accountactive]=1;
2841 if(selected==2)accountdifficulty[accountactive]=2;
2852 if(Button())oldbutton=1;
2857 if(Button())oldbutton=1;
2860 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2863 if(newdetail>2)newdetail=detail;
2864 if(newdetail<0)newdetail=detail;
2865 if(newscreenwidth<0)newscreenwidth=screenwidth;
2866 if(newscreenheight<0)newscreenheight=screenheight;
2868 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2869 opstream << "Screenwidth:\n";
2870 opstream << newscreenwidth;
2871 opstream << "\nScreenheight:\n";
2872 opstream << newscreenheight;
2873 opstream << "\nMouse sensitivity:\n";
2874 opstream << usermousesensitivity;
2875 opstream << "\nBlur(0,1):\n";
2876 opstream << ismotionblur;
2877 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2878 opstream << newdetail;
2879 opstream << "\nFloating jump:\n";
2880 opstream << floatjump;
2881 opstream << "\nMouse jump:\n";
2882 opstream << mousejump;
2883 opstream << "\nAmbient sound:\n";
2884 opstream << ambientsound;
2885 opstream << "\nBlood (0,1,2):\n";
2886 opstream << bloodtoggle;
2887 opstream << "\nAuto slomo:\n";
2888 opstream << autoslomo;
2889 opstream << "\nFoliage:\n";
2890 opstream << foliage;
2891 opstream << "\nMusic:\n";
2892 opstream << musictoggle;
2893 opstream << "\nTrilinear:\n";
2894 opstream << trilinear;
2895 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2897 opstream << "\nInvert mouse:\n";
2898 opstream << invertmouse;
2899 opstream << "\nGamespeed:\n";
2900 if(oldgamespeed==0)oldgamespeed=1;
2901 opstream << oldgamespeed;
2902 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2903 opstream << difficulty;
2904 opstream << "\nDamage effects(blackout, doublevision):\n";
2905 opstream << damageeffects;
2906 opstream << "\nText:\n";
2907 opstream << texttoggle;
2908 opstream << "\nDebug:\n";
2909 opstream << debugmode;
2910 opstream << "\nVBL Sync:\n";
2911 opstream << vblsync;
2912 opstream << "\nShow Points:\n";
2913 opstream << showpoints;
2914 opstream << "\nAlways Blur:\n";
2915 opstream << alwaysblur;
2916 opstream << "\nImmediate mode (turn on on G5):\n";
2917 opstream << immediate;
2918 opstream << "\nVelocity blur:\n";
2919 opstream << velocityblur;
2920 opstream << "\nVolume:\n";
2922 opstream << "\nForward key:\n";
2923 opstream << KeyToChar(forwardkey);
2924 opstream << "\nBack key:\n";
2925 opstream << KeyToChar(backkey);
2926 opstream << "\nLeft key:\n";
2927 opstream << KeyToChar(leftkey);
2928 opstream << "\nRight key:\n";
2929 opstream << KeyToChar(rightkey);
2930 opstream << "\nJump key:\n";
2931 opstream << KeyToChar(jumpkey);
2932 opstream << "\nCrouch key:\n";
2933 opstream << KeyToChar(crouchkey);
2934 opstream << "\nDraw key:\n";
2935 opstream << KeyToChar(drawkey);
2936 opstream << "\nThrow key:\n";
2937 opstream << KeyToChar(throwkey);
2938 opstream << "\nAttack key:\n";
2939 opstream << KeyToChar(attackkey);
2940 opstream << "\nChat key:\n";
2941 opstream << KeyToChar(chatkey);
2946 if(mainmenu==1||mainmenu==2){
2947 if(loaddistrib>4)transition+=multiplier/8;
2955 OPENAL_SetFrequency(channels[stream_music3], 22050);
2959 if(IsKeyDown(theKeyMap, i)){
2960 togglekeydelay[i]+=multiplier;
2961 if(togglekeydelay[i]>.4){
2963 togglekeydelay[i]=.36;
2966 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
2967 for(j=255;j>=displayselected+1;j--){
2968 displaytext[0][j]=displaytext[0][j-1];
2970 displaytext[0][displayselected]=KeyToSingleChar(i);
2971 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
2975 if(i==MAC_DELETE_KEY&&displayselected!=0){
2976 for(j=displayselected-1;j<255;j++){
2977 displaytext[0][j]=displaytext[0][j+1];
2979 displaytext[0][255]=' ';
2983 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
2986 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
2989 if(i==MAC_RETURN_KEY&&entername){
2990 if(displaychars[0]){
2992 strcpy(accountname[numaccounts-1],displaytext[0]);
2993 accountactive=numaccounts-1;
2994 accountdifficulty[accountactive]=1;
2995 accountprogress[accountactive]=0;
2996 accountpoints[accountactive]=0;
2997 accountcampaigntime[accountactive]=0;
2998 accountcampaignscore[accountactive]=0;
2999 accountcampaignfasttime[accountactive]=0;
3000 accountcampaignhighscore[accountactive]=0;
3002 accounthighscore[accountactive][j]=0;
3003 accountfasttime[accountactive][j]=0;
3006 accountunlocked[accountactive][j]=0;
3008 accountcampaignchoicesmade[accountactive]=0;
3011 displaytext[0][j]=' ';
3025 float gLoc[3]={0,0,0};
3026 float vel[3]={0,0,0};
3027 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3028 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3029 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3030 OPENAL_SetVolume(channels[firestartsound], 256);
3031 OPENAL_SetPaused(channels[firestartsound], false);
3032 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3035 displaytext[0][j]=' ';
3043 if(i==MAC_RETURN_KEY&&mainmenu==13){
3044 if(displaychars[0]){
3045 sprintf (registrationname, "%s", displaytext[0]);
3046 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3056 float gLoc[3]={0,0,0};
3057 float vel[3]={0,0,0};
3058 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3059 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3060 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3061 OPENAL_SetVolume(channels[firestartsound], 256);
3062 OPENAL_SetPaused(channels[firestartsound], false);
3063 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3066 displaytext[0][j]=' ';
3077 togglekeydelay[i]=0;
3081 displayblinkdelay-=multiplier;
3082 if(displayblinkdelay<=0){
3083 displayblinkdelay=.3;
3084 displayblink=1-displayblink;
3090 if(hostile==1)hostiletime+=multiplier;
3092 if(!winfreeze)leveltime+=multiplier;
3093 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3100 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3102 chattogglekeydown=1;
3103 togglekey[chatkey]=1;
3104 togglekeydelay[chatkey]=-20;
3107 if(!IsKeyDown(theKeyMap, chatkey)){
3108 chattogglekeydown=0;
3113 if(IsKeyDown(theKeyMap, i)){
3114 togglekeydelay[i]+=multiplier;
3115 if(togglekeydelay[i]>.4){
3117 togglekeydelay[i]=.36;
3120 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3121 for(j=255;j>=displayselected+1;j--){
3122 displaytext[0][j]=displaytext[0][j-1];
3124 displaytext[0][displayselected]=KeyToSingleChar(i);
3125 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3129 if(i==MAC_DELETE_KEY&&displayselected!=0){
3130 for(j=displayselected-1;j<255;j++){
3131 displaytext[0][j]=displaytext[0][j+1];
3133 displaytext[0][255]=' ';
3137 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3140 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3143 if(i==MAC_RETURN_KEY){
3144 if(displaychars[0]){
3145 /*for(j=0;j<displaychars[0];j++){
3146 talkname[j]=displaytext[0][j];
3148 talkname[displaychars[0]]='\0';
3149 sprintf (chatname, "%s: %s",playerName,talkname);
3150 //NetworkSendInformation(chatname);
3153 displaytext[0][j]=' ';
3165 togglekeydelay[i]=0;
3169 displayblinkdelay-=multiplier;
3170 if(displayblinkdelay<=0){
3171 displayblinkdelay=.3;
3172 displayblink=1-displayblink;
3176 if(chatting)keyboardfrozen=1;
3178 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3181 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3183 freezetogglekeydown=1;
3186 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3187 freezetogglekeydown=0;
3190 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3192 if(!console)freeze=0;
3194 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3196 consoletogglekeydown=1;
3199 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3200 consoletogglekeydown=0;
3203 if(console)freeze=1;
3205 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3207 if(IsKeyDown(theKeyMap, i)){
3208 togglekeydelay[i]+=multiplier;
3209 if(togglekeydelay[i]>.4){
3211 togglekeydelay[i]=.36;
3214 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3215 for(j=255;j>=consoleselected+1;j--){
3216 consoletext[0][j]=consoletext[0][j-1];
3218 consoletext[0][consoleselected]=KeyToSingleChar(i);
3219 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3223 else if(i==MAC_ENTER_KEY){
3224 for(j=255;j>=consoleselected+1;j--){
3225 consoletext[0][j]=consoletext[0][j-1];
3227 consoletext[0][consoleselected]='\n';
3231 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3232 for(j=consoleselected-1;j<255;j++){
3233 consoletext[0][j]=consoletext[0][j+1];
3235 consoletext[0][255]=' ';
3239 if(i==MAC_ARROW_UP_KEY){
3240 if(archiveselected<14)archiveselected++;
3242 consolechars[0]=consolechars[archiveselected];
3243 consoletext[0][j]=consoletext[archiveselected][j];
3244 consoleselected=consolechars[0];
3247 if(i==MAC_ARROW_DOWN_KEY){
3248 if(archiveselected>0)archiveselected--;
3250 consolechars[0]=consolechars[archiveselected];
3251 consoletext[0][j]=consoletext[archiveselected][j];
3252 consoleselected=consolechars[0];
3255 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3258 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3261 if(i==MAC_RETURN_KEY){
3264 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3265 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3266 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3267 OPENAL_SetPaused(channels[consolesuccesssound], false);
3271 /*if(Compare(consoletext[0],"send ",0,4)){
3272 for(j=5;j<consolechars[0];j++){
3273 talkname[j-5]=consoletext[0][j];
3275 talkname[consolechars[0]-5]='\0';
3276 sprintf (chatname, "%s: %s",playerName,talkname);
3277 //NetworkSendInformation(chatname);
3280 if(Compare(consoletext[0],"name ",0,4)){
3282 numchars=consolechars[0]-5;
3283 if(numchars>32)numchars=32;
3284 for(j=5;j<numchars+5;j++){
3285 talkname[j-5]=consoletext[0][j];
3287 talkname[numchars]='\0';
3288 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3289 //NetworkSendInformation(chatname);
3290 sprintf (playerName, "%s",talkname);
3291 //NetworkSendName(playerName);
3294 if(Compare(consoletext[0],"map ",0,3)){
3306 for(j=4;j<consolechars[0];j++){
3307 mapname[j-4+11]=consoletext[0][j];
3309 mapname[consolechars[0]-4+11]='\0';
3315 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3317 unsigned char playerNameStr[32];
3318 char theIPAddress[256];
3320 NMUInt32 port = 25710;
3322 strcpy(playerName, "Client");
3323 GameC2PStr( playerName, playerNameStr );
3325 for(j=0;j<consolechars[0]-8;j++){
3326 theIPAddress[j]=consoletext[0][j+8];
3328 theIPAddress[consolechars[0]-8]='\0';
3330 sprintf( thePort, "%li", port );
3331 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3334 if(consolechars[0]>0){
3337 consoletext[k][j]=consoletext[k-1][j];
3339 consolechars[k]=consolechars[k-1];
3342 consoletext[0][j]=' ';
3344 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3345 else sprintf (consoletext[0], "Could not open connection");
3347 consolechars[0]=255;
3354 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3355 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3356 OPENAL_SetPaused(channels[consolesuccesssound], false);
3358 if(consolechars[0]>0){
3361 consoletext[k][j]=consoletext[k-1][j];
3363 consolechars[k]=consolechars[k-1];
3366 consoletext[0][j]=' ';
3368 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3370 consolechars[0]=255;
3376 if(Compare(consoletext[0],"host ",0,4)){
3377 unsigned char gameNameStr[32], playerNameStr[32];
3378 char gameName[32];//, playerName[32];
3386 strcpy(gameName, "Host's game");
3387 strcpy(playerName, "Host");
3388 GameC2PStr( gameName, gameNameStr );
3389 GameC2PStr( playerName, playerNameStr );
3391 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3394 if(consolechars[0]>0){
3397 consoletext[k][j]=consoletext[k-1][j];
3399 consolechars[k]=consolechars[k-1];
3402 consoletext[0][j]=' ';
3404 sprintf (consoletext[0], "Error #%d!!!",v);
3406 consolechars[0]=255;
3413 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3414 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3415 OPENAL_SetPaused(channels[consolesuccesssound], false);
3417 if(consolechars[0]>0){
3420 consoletext[k][j]=consoletext[k-1][j];
3422 consolechars[k]=consolechars[k-1];
3425 consoletext[0][j]=' ';
3427 sprintf (consoletext[0], "Game hosted");
3429 consolechars[0]=255;
3435 if(Compare(consoletext[0],"save ",0,4)){
3447 for(j=5;j<consolechars[0];j++){
3448 mapname[j-5+11]=consoletext[0][j];
3450 mapname[consolechars[0]-5+11]='\0';
3452 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3453 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3454 OPENAL_SetPaused(channels[consolesuccesssound], false);
3461 tfile=fopen( mapname, "wb" );
3462 fpackf(tfile, "Bi", mapvers);
3463 //fpackf(tfile, "Bi", indemo);
3464 fpackf(tfile, "Bi", maptype);
3465 fpackf(tfile, "Bi", hostile);
3466 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3467 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3468 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3469 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);
3470 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3471 for(j=0;j<player[0].num_weapons;j++){
3472 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3475 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3476 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3477 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3478 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3480 fpackf(tfile, "Bi", player[0].numclothes);
3482 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3484 fpackf(tfile, "Bi", numdialogues);
3486 for(k=0;k<numdialogues;k++){
3487 fpackf(tfile, "Bi", numdialogueboxes[k]);
3488 fpackf(tfile, "Bi", dialoguetype[k]);
3490 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3491 fpackf(tfile, "Bf", participantrotation[k][l]);
3493 if(numdialogueboxes)
3494 for(l=0;l<numdialogueboxes[k];l++){
3495 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3496 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3497 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3498 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3499 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3501 templength=strlen(dialoguetext[k][l]);
3502 fpackf(tfile, "Bi",(templength));
3503 for(m=0;m<templength;m++){
3504 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3505 if(dialoguetext[k][l][m]=='\0')break;
3508 templength=strlen(dialoguename[k][l]);
3509 fpackf(tfile, "Bi",templength);
3510 for(m=0;m<templength;m++){
3511 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3512 if(dialoguename[k][l][m]=='\0')break;
3515 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3516 fpackf(tfile, "Bi", participantfocus[k][l]);
3517 fpackf(tfile, "Bi", participantaction[k][l]);
3520 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3522 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3526 if(player[0].numclothes)
3527 for(k=0;k<player[0].numclothes;k++){
3528 templength=strlen(player[0].clothes[k]);
3529 fpackf(tfile, "Bi", templength);
3530 for(l=0;l<templength;l++)
3531 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3532 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3535 fpackf(tfile, "Bi", environment);
3537 fpackf(tfile, "Bi", objects.numobjects);
3539 if(objects.numobjects)
3540 for(k=0;k<objects.numobjects;k++){
3541 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]);
3544 fpackf(tfile, "Bi", numhotspots);
3546 for(i=0;i<numhotspots;i++){
3547 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3548 templength=strlen(hotspottext[i]);
3549 fpackf(tfile, "Bi",templength);
3550 for(l=0;l<templength;l++)
3551 fpackf(tfile, "Bb", hotspottext[i][l]);
3554 fpackf(tfile, "Bi", numplayers);
3555 if(numplayers>1&&numplayers<maxplayers)
3556 for(j=1;j<numplayers;j++){
3557 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);
3558 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3559 for(k=0;k<player[j].num_weapons;k++){
3560 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3562 if(player[j].numwaypoints<30){
3563 fpackf(tfile, "Bi", player[j].numwaypoints);
3564 for(k=0;k<player[j].numwaypoints;k++){
3565 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3566 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3567 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3568 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3570 fpackf(tfile, "Bi", player[j].waypoint);
3573 player[j].numwaypoints=0;
3574 player[j].waypoint=0;
3575 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3578 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3579 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3580 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3581 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3583 if(player[j].creature==wolftype){
3584 headprop=player[j].proportionhead.x/1.1;
3585 bodyprop=player[j].proportionbody.x/1.1;
3586 armprop=player[j].proportionarms.x/1.1;
3587 legprop=player[j].proportionlegs.x/1.1;
3590 if(player[j].creature==rabbittype){
3591 headprop=player[j].proportionhead.x/1.2;
3592 bodyprop=player[j].proportionbody.x/1.05;
3593 armprop=player[j].proportionarms.x/1.00;
3594 legprop=player[j].proportionlegs.x/1.1;
3597 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3601 fpackf(tfile, "Bi", player[j].numclothes);
3602 if(player[j].numclothes)
3603 for(k=0;k<player[j].numclothes;k++){
3605 templength=strlen(player[j].clothes[k]);
3606 fpackf(tfile, "Bi", templength);
3607 for(l=0;l<templength;l++)
3608 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3609 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3613 fpackf(tfile, "Bi", numpathpoints);
3615 for(j=0;j<numpathpoints;j++){
3616 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3617 for(k=0;k<numpathpointconnect[j];k++){
3618 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3622 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3630 tfile=fopen( mapname, "wb" );
3631 fwrite( &mapvers, 1, sizeof(int), tfile );
3632 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3633 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3634 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3635 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3636 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3637 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3638 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3639 for(j=0;j<player[0].num_weapons;j++){
3640 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3643 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3644 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3645 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3646 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3647 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3648 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3649 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3650 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3651 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3652 fwrite( &player[0].power, 1, sizeof(int), tfile );
3653 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3655 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3656 if(player[0].numclothes)
3657 for(k=0;k<player[0].numclothes;k++){
3659 templength=strlen(player[0].clothes[k]);
3660 fwrite( &templength,1,sizeof(int),tfile);
3661 for(l=0;l<templength;l++)
3662 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3663 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3664 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3665 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3668 fwrite( &environment, 1, sizeof(int), tfile );
3670 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3672 for(k=0;k<objects.numobjects;k++){
3673 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3674 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3675 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3676 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3677 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3678 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3679 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3682 fwrite( &numplayers, 1, sizeof(int), tfile );
3683 if(numplayers>1&&numplayers<maxplayers)
3684 for(j=1;j<numplayers;j++){
3685 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3686 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3687 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3688 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3689 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3690 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3691 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3692 for(k=0;k<player[j].num_weapons;k++){
3693 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3695 if(player[j].numwaypoints<30){
3696 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3697 for(k=0;k<player[j].numwaypoints;k++){
3698 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3699 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3700 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3702 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3703 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3706 player[j].numwaypoints=0;
3707 player[j].waypoint=0;
3708 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3709 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3710 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3712 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3713 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3714 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3715 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3716 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3717 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3718 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3719 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3720 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3721 fwrite( &player[j].power, 1, sizeof(int), tfile );
3722 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3724 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3725 if(player[j].numclothes)
3726 for(k=0;k<player[j].numclothes;k++){
3728 templength=strlen(player[j].clothes[k]);
3729 fwrite( &templength,1,sizeof(int),tfile);
3730 for(l=0;l<templength;l++)
3731 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3732 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3733 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3734 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3737 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3739 for(j=0;j<numpathpoints;j++){
3740 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3741 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3742 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3743 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3744 for(k=0;k<numpathpointconnect[j];k++){
3745 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3749 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3750 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3751 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3753 fwrite( &mapradius, 1, sizeof(float), tfile );
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 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3778 OPENAL_SetPaused(channels[consolesuccesssound], false);
3781 tfile=fopen( mapname, "wb" );
3782 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
3783 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3784 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3785 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3786 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3787 for(j=0;j<player[0].num_weapons;j++){
3788 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3790 fwrite( &environment, 1, sizeof(int), tfile );
3792 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3793 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
3794 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
3795 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
3796 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
3798 fwrite( &numplayers, 1, sizeof(int), tfile );
3799 if(numplayers>1&&numplayers<maxplayers)
3800 for(j=1;j<numplayers;j++){
3801 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
3802 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3803 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3804 for(k=0;k<player[j].num_weapons;k++){
3805 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3807 if(player[j].numwaypoints<30){
3808 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3809 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
3810 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3811 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3814 player[j].numwaypoints=0;
3815 player[j].waypoint=0;
3816 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3817 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3818 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3821 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3823 for(j=0;j<numpathpoints;j++){
3824 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
3825 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3826 for(k=0;k<numpathpointconnect[j];k++){
3827 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3833 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
3834 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
3837 /*if(Compare(consoletext[0],"Pants ",0,5)){
3838 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
3839 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
3843 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
3844 for(j=6;j<consolechars[0];j++){
3845 mapname[j-6]=consoletext[0][j];
3848 tintr=atof(mapname);
3853 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
3854 for(j=6;j<consolechars[0];j++){
3855 mapname[j-6]=consoletext[0][j];
3858 player[0].speedmult=atof(mapname);
3863 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
3864 for(j=9;j<consolechars[0];j++){
3865 mapname[j-9]=consoletext[0][j];
3868 player[0].power=atof(mapname);
3873 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
3874 for(j=13;j<consolechars[0];j++){
3875 mapname[j-13]=consoletext[0][j];
3878 viewdistance=atof(mapname)*100;
3883 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
3884 for(j=10;j<consolechars[0];j++){
3885 mapname[j-10]=consoletext[0][j];
3888 fadestart=atof(mapname);
3893 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
3894 for(j=6;j<consolechars[0];j++){
3895 mapname[j-6]=consoletext[0][j];
3898 player[0].power=atof(mapname);
3903 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
3904 for(j=6;j<consolechars[0];j++){
3905 mapname[j-6]=consoletext[0][j];
3908 slomospeed=atof(mapname);
3915 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
3916 for(j=8;j<consolechars[0];j++){
3917 mapname[j-8]=consoletext[0][j];
3920 slomofreq=atoi(mapname);
3925 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
3926 for(j=5;j<consolechars[0];j++){
3927 mapname[j-5]=consoletext[0][j];
3930 player[0].scale=atof(mapname)*.2;
3935 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
3937 float closestdist=-1;
3940 for(i=1;i<numplayers;i++){
3941 distance=findDistancefast(&player[i].coords,&player[0].coords);
3942 if(closestdist==-1||distance<closestdist){
3943 closestdist=distance;
3948 for(j=9;j<consolechars[0];j++){
3949 mapname[j-9]=consoletext[0][j];
3952 player[closest].scale=atof(mapname)*.2;
3957 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
3962 float closestdist=-1;
3965 for(i=1;i<numplayers;i++){
3966 distance=findDistancefast(&player[i].coords,&player[0].coords);
3967 if(closestdist==-1||distance<closestdist){
3968 closestdist=distance;
3976 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3977 mapname[j-startpoint]=consoletext[0][j];
3979 if(consoletext[0][j]=='\0')alldone=1;
3981 mapname[j-startpoint]='\0';
3983 headprop=atof(mapname);
3987 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3988 mapname[j-startpoint]=consoletext[0][j];
3990 if(consoletext[0][j]=='\0')alldone=1;
3992 mapname[j-startpoint]='\0';
3994 bodyprop=atof(mapname);
3998 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3999 mapname[j-startpoint]=consoletext[0][j];
4001 if(consoletext[0][j]=='\0')alldone=1;
4003 mapname[j-startpoint]='\0';
4005 armprop=atof(mapname);
4009 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4010 mapname[j-startpoint]=consoletext[0][j];
4012 if(consoletext[0][j]=='\0')alldone=1;
4014 mapname[j-startpoint]='\0';
4016 legprop=atof(mapname);
4018 if(player[closest].creature==wolftype){
4019 player[closest].proportionhead=1.1*headprop;
4020 player[closest].proportionbody=1.1*bodyprop;
4021 player[closest].proportionarms=1.1*armprop;
4022 player[closest].proportionlegs=1.1*legprop;
4025 if(player[closest].creature==rabbittype){
4026 player[closest].proportionhead=1.2*headprop;
4027 player[closest].proportionbody=1.05*bodyprop;
4028 player[closest].proportionarms=1.00*armprop;
4029 player[closest].proportionlegs=1.1*legprop;
4030 player[closest].proportionlegs.y=1.05*legprop;
4037 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4038 for(i=1;i<numplayers;i++){
4039 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4045 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4046 for(j=9;j<consolechars[0];j++){
4047 mapname[j-9]=consoletext[0][j];
4050 tutoriallevel=atoi(mapname);
4056 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4057 for(j=6;j<consolechars[0];j++){
4058 mapname[j-6]=consoletext[0][j];
4061 tintg=atof(mapname);
4066 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4067 for(j=6;j<consolechars[0];j++){
4068 mapname[j-6]=consoletext[0][j];
4071 tintb=atof(mapname);
4076 if(Compare(consoletext[0],"hostile ",0,7)){
4077 for(j=8;j<consolechars[0];j++){
4078 mapname[j-8]=consoletext[0][j];
4081 hostile=atoi(mapname);
4087 if(Compare(consoletext[0],"type active ",0,11)){
4088 editoractive=typeactive;
4093 if(Compare(consoletext[0],"indemo ",0,6)){
4095 hotspot[numhotspots]=player[0].coords;
4096 hotspotsize[numhotspots]=0;
4097 hotspottype[numhotspots]=-111;
4099 strcpy(hotspottext[numhotspots],"mapname");
4105 if(Compare(consoletext[0],"notindemo ",0,9)){
4112 if(Compare(consoletext[0],"type sitting ",0,12)){
4113 editoractive=typesitting;
4118 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4119 editoractive=typesittingwall;
4124 if(Compare(consoletext[0],"type sleeping ",0,13)){
4125 editoractive=typesleeping;
4129 if(Compare(consoletext[0],"type dead1 ",0,10)){
4130 editoractive=typedead1;
4134 if(Compare(consoletext[0],"type dead2 ",0,10)){
4135 editoractive=typedead2;
4139 if(Compare(consoletext[0],"type dead3 ",0,10)){
4140 editoractive=typedead3;
4143 if(Compare(consoletext[0],"type dead4 ",0,10)){
4144 editoractive=typedead4;
4149 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4150 editorpathtype=wpkeepwalking;
4155 if(Compare(consoletext[0],"path pause ",0,10)){
4156 editorpathtype=wppause;
4161 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4162 maptype=mapkilleveryone;
4167 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4168 maptype=mapgosomewhere;
4173 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4174 maptype=mapkillsomeone;
4180 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4181 maptype=mapkillmost;
4187 if(Compare(consoletext[0],"hs ",0,2)){
4191 hotspot[numhotspots]=player[0].coords;
4196 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4197 mapname[j-startpoint]=consoletext[0][j];
4199 if(consoletext[0][j]=='\0')alldone=1;
4201 mapname[j-startpoint]='\0';
4203 hotspotsize[numhotspots]=atof(mapname);
4207 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4208 mapname[j-startpoint]=consoletext[0][j];
4210 if(consoletext[0][j]=='\0')alldone=1;
4212 mapname[j-startpoint]='\0';
4214 hotspottype[numhotspots]=atoi(mapname);
4218 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4219 mapname[j-startpoint]=consoletext[0][j];
4221 if(consoletext[0][j]=='\0')alldone=1;
4223 mapname[j-startpoint]='\n';
4224 mapname[j-startpoint+1]='\0';
4226 strcpy(hotspottext[numhotspots],mapname);
4233 if(Compare(consoletext[0],"dialogue ",0,8)){
4240 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4241 mapname[j-startpoint]=consoletext[0][j];
4243 if(consoletext[0][j]=='\0')alldone=1;
4245 mapname[j-startpoint]='\0';
4248 dialoguetype[numdialogues]=atoi(mapname);
4266 for(j=startpoint;j<consolechars[0];j++){
4267 mapname[j-startpoint+16]=consoletext[0][j];
4269 mapname[consolechars[0]-startpoint+16]='.';
4270 mapname[consolechars[0]-startpoint+17]='t';
4271 mapname[consolechars[0]-startpoint+18]='x';
4272 mapname[consolechars[0]-startpoint+19]='t';
4273 mapname[consolechars[0]-startpoint+20]='\0';
4275 for(j=0;j<max_dialoguelength;j++){
4277 dialoguetext[numdialogues][j][k]='\0';
4280 dialoguename[numdialogues][j][k]='\0';
4284 ifstream ipstream(ConvertFileName(mapname));
4285 ipstream.ignore(256,':');
4286 ipstream >> numdialogueboxes[numdialogues];
4287 for(i=0;i<numdialogueboxes[numdialogues];i++){
4288 ipstream.ignore(256,':');
4289 ipstream.ignore(256,':');
4290 ipstream.ignore(256,' ');
4291 ipstream >> dialogueboxlocation[numdialogues][i];
4292 ipstream.ignore(256,':');
4293 ipstream >> dialogueboxcolor[numdialogues][i][0];
4294 ipstream >> dialogueboxcolor[numdialogues][i][1];
4295 ipstream >> dialogueboxcolor[numdialogues][i][2];
4296 ipstream.ignore(256,':');
4297 ipstream.getline(dialoguename[numdialogues][i],64);
4298 ipstream.ignore(256,':');
4299 ipstream.ignore(256,' ');
4300 ipstream.getline(dialoguetext[numdialogues][i],128);
4302 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4304 ipstream.ignore(256,':');
4305 ipstream >> dialogueboxsound[numdialogues][i];
4308 for(i=0;i<numdialogueboxes[numdialogues];i++){
4309 for(j=0;j<numplayers;j++){
4310 participantfacing[numdialogues][i][j]=player[j].facing;
4317 whichdialogue=numdialogues;
4325 if(Compare(consoletext[0],"fixdialogue ",0,11)){
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';
4341 whichdi=atoi(mapname);
4359 for(j=startpoint;j<consolechars[0];j++){
4360 mapname[j-startpoint+16]=consoletext[0][j];
4362 mapname[consolechars[0]-startpoint+16]='.';
4363 mapname[consolechars[0]-startpoint+17]='t';
4364 mapname[consolechars[0]-startpoint+18]='x';
4365 mapname[consolechars[0]-startpoint+19]='t';
4366 mapname[consolechars[0]-startpoint+20]='\0';
4368 for(j=0;j<max_dialoguelength;j++){
4370 dialoguetext[whichdi][j][k]='\0';
4373 dialoguename[whichdi][j][k]='\0';
4377 ifstream ipstream(ConvertFileName(mapname));
4378 ipstream.ignore(256,':');
4379 ipstream >> numdialogueboxes[whichdi];
4380 for(i=0;i<numdialogueboxes[whichdi];i++){
4381 ipstream.ignore(256,':');
4382 ipstream.ignore(256,':');
4383 ipstream.ignore(256,' ');
4384 ipstream >> dialogueboxlocation[whichdi][i];
4385 ipstream.ignore(256,':');
4386 ipstream >> dialogueboxcolor[whichdi][i][0];
4387 ipstream >> dialogueboxcolor[whichdi][i][1];
4388 ipstream >> dialogueboxcolor[whichdi][i][2];
4389 ipstream.ignore(256,':');
4390 ipstream.getline(dialoguename[whichdi][i],64);
4391 ipstream.ignore(256,':');
4392 ipstream.ignore(256,' ');
4393 ipstream.getline(dialoguetext[whichdi][i],128);
4395 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4397 ipstream.ignore(256,':');
4398 ipstream >> dialogueboxsound[whichdi][i];
4406 if(Compare(consoletext[0],"fixtype ",0,7)){
4414 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4415 mapname[j-startpoint]=consoletext[0][j];
4417 if(consoletext[0][j]=='\0')alldone=1;
4419 mapname[j-startpoint]='\0';
4420 dialoguetype[0]=atoi(mapname);
4428 if(Compare(consoletext[0],"fixrotation ",0,11)){
4429 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4434 if(Compare(consoletext[0],"ddialogue ",0,9)){
4436 if(numdialogues<0)numdialogues=0;
4441 if(Compare(consoletext[0],"immobile ",0,8)){
4442 player[0].immobile=1;
4446 if(Compare(consoletext[0],"mobile ",0,6)){
4447 player[0].immobile=0;
4451 if(Compare(consoletext[0],"play ",0,4)){
4458 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4459 mapname[j-startpoint]=consoletext[0][j];
4461 if(consoletext[0][j]=='\0')alldone=1;
4463 mapname[j-startpoint]='\0';
4466 whichdialogue=atoi(mapname);
4468 if(numdialogues>whichdialogue){
4469 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4470 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4471 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4472 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4473 player[participantfocus[whichdialogue][i]].velocity=0;
4474 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4475 player[participantfocus[whichdialogue][i]].targetframe=0;
4483 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4487 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4488 temppos=temppos-viewer;
4489 Normalise(&temppos);
4499 whichsoundplay=rabbitchitter;
4500 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4501 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4502 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4503 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4504 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4505 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4506 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4507 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4508 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4509 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4510 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4511 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4512 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4513 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4514 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4515 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4516 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4517 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4518 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4519 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4520 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4521 OPENAL_SetVolume(channels[whichsoundplay], 256);
4522 OPENAL_SetPaused(channels[whichsoundplay], false);
4530 if(Compare(consoletext[0],"dhs ",0,3)){
4532 if(numhotspots<0)numhotspots=0;
4537 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4544 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4545 mapname[j-startpoint]=consoletext[0][j];
4547 if(consoletext[0][j]=='\0')alldone=1;
4549 mapname[j-startpoint]='\0';
4551 headprop=atof(mapname);
4555 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4556 mapname[j-startpoint]=consoletext[0][j];
4558 if(consoletext[0][j]=='\0')alldone=1;
4560 mapname[j-startpoint]='\0';
4562 bodyprop=atof(mapname);
4566 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4567 mapname[j-startpoint]=consoletext[0][j];
4569 if(consoletext[0][j]=='\0')alldone=1;
4571 mapname[j-startpoint]='\0';
4573 armprop=atof(mapname);
4577 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4578 mapname[j-startpoint]=consoletext[0][j];
4580 if(consoletext[0][j]=='\0')alldone=1;
4582 mapname[j-startpoint]='\0';
4584 legprop=atof(mapname);
4586 if(player[0].creature==wolftype){
4587 player[0].proportionhead=1.1*headprop;
4588 player[0].proportionbody=1.1*bodyprop;
4589 player[0].proportionarms=1.1*armprop;
4590 player[0].proportionlegs=1.1*legprop;
4593 if(player[0].creature==rabbittype){
4594 player[0].proportionhead=1.2*headprop;
4595 player[0].proportionbody=1.05*bodyprop;
4596 player[0].proportionarms=1.00*armprop;
4597 player[0].proportionlegs=1.1*legprop;
4598 player[0].proportionlegs.y=1.05*legprop;
4604 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4605 for(i=0;i<numplayers;i++){
4606 if(i>0)player[i].immobile=1;
4612 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4613 player[0].armorhead=1;
4614 player[0].armorhigh=1;
4615 player[0].armorlow=1;
4616 player[0].protectionhead=1;
4617 player[0].protectionhigh=1;
4618 player[0].protectionlow=1;
4619 player[0].metalhead=1;
4620 player[0].metalhigh=1;
4621 player[0].metallow=1;
4623 player[0].speedmult=1;
4626 if(player[0].creature==wolftype){
4627 player[0].proportionhead=1.1;
4628 player[0].proportionbody=1.1;
4629 player[0].proportionarms=1.1;
4630 player[0].proportionlegs=1.1;
4633 if(player[0].creature==rabbittype){
4634 player[0].proportionhead=1.2;
4635 player[0].proportionbody=1.05;
4636 player[0].proportionarms=1.00;
4637 player[0].proportionlegs=1.1;
4638 player[0].proportionlegs.y=1.05;
4641 player[0].numclothes=0;
4642 if(player[0].whichskin==0){
4643 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4645 else if(player[0].whichskin==1){
4646 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4648 else if(player[0].whichskin==2){
4649 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4651 else if(player[0].whichskin==3){
4652 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4654 else if(player[0].whichskin==4){
4655 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4657 else if(player[0].whichskin==5){
4658 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4660 else if(player[0].whichskin==6){
4661 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4663 else if(player[0].whichskin==7){
4664 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4666 else if(player[0].whichskin==8){
4667 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4669 else if(player[0].whichskin==9){
4670 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4673 editoractive=typeactive;
4674 player[0].immobile=0;
4681 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4687 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4688 mapname[j-startpoint]=consoletext[0][j];
4690 if(consoletext[0][j]=='\0')alldone=1;
4692 mapname[j-startpoint]='\0';
4694 tintr=atof(mapname);
4698 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4699 mapname[j-startpoint]=consoletext[0][j];
4701 if(consoletext[0][j]=='\0')alldone=1;
4703 mapname[j-startpoint]='\0';
4705 tintg=atof(mapname);
4709 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4710 mapname[j-startpoint]=consoletext[0][j];
4712 if(consoletext[0][j]=='\0')alldone=1;
4714 mapname[j-startpoint]='\0';
4716 tintb=atof(mapname);
4721 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4727 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4728 mapname[j-startpoint]=consoletext[0][j];
4730 if(consoletext[0][j]=='\0')alldone=1;
4732 mapname[j-startpoint]='\0';
4734 skyboxr=atof(mapname);
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';
4745 skyboxg=atof(mapname);
4749 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4750 mapname[j-startpoint]=consoletext[0][j];
4752 if(consoletext[0][j]=='\0')alldone=1;
4754 mapname[j-startpoint]='\0';
4756 skyboxb=atof(mapname);
4758 skyboxlightr=skyboxr;
4759 skyboxlightg=skyboxg;
4760 skyboxlightb=skyboxb;
4764 //if(skyboxtexture){
4765 terrain.DoShadows();
4766 objects.DoShadows();
4768 else terrain.DoLighting();
4773 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
4779 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4780 mapname[j-startpoint]=consoletext[0][j];
4782 if(consoletext[0][j]=='\0')alldone=1;
4784 mapname[j-startpoint]='\0';
4786 skyboxlightr=atof(mapname);
4790 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4791 mapname[j-startpoint]=consoletext[0][j];
4793 if(consoletext[0][j]=='\0')alldone=1;
4795 mapname[j-startpoint]='\0';
4797 skyboxlightg=atof(mapname);
4801 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4802 mapname[j-startpoint]=consoletext[0][j];
4804 if(consoletext[0][j]=='\0')alldone=1;
4806 mapname[j-startpoint]='\0';
4808 skyboxlightb=atof(mapname);
4812 //if(skyboxtexture){
4813 terrain.DoShadows();
4814 objects.DoShadows();
4816 else terrain.DoLighting();
4821 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
4822 skyboxtexture=1-skyboxtexture;
4825 //if(skyboxtexture){
4826 terrain.DoShadows();
4827 objects.DoShadows();
4829 else terrain.DoLighting();
4834 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
4840 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4841 mapname[j-startpoint]=consoletext[0][j];
4843 if(consoletext[0][j]=='\0')alldone=1;
4845 mapname[j-startpoint]='\0';
4847 player[0].protectionhead=atof(mapname);
4851 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4852 mapname[j-startpoint]=consoletext[0][j];
4854 if(consoletext[0][j]=='\0')alldone=1;
4856 mapname[j-startpoint]='\0';
4858 player[0].protectionhigh=atof(mapname);
4862 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4863 mapname[j-startpoint]=consoletext[0][j];
4865 if(consoletext[0][j]=='\0')alldone=1;
4867 mapname[j-startpoint]='\0';
4869 player[0].protectionlow=atof(mapname);
4874 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
4880 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4881 mapname[j-startpoint]=consoletext[0][j];
4883 if(consoletext[0][j]=='\0')alldone=1;
4885 mapname[j-startpoint]='\0';
4887 player[0].armorhead=atof(mapname);
4891 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4892 mapname[j-startpoint]=consoletext[0][j];
4894 if(consoletext[0][j]=='\0')alldone=1;
4896 mapname[j-startpoint]='\0';
4898 player[0].armorhigh=atof(mapname);
4902 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4903 mapname[j-startpoint]=consoletext[0][j];
4905 if(consoletext[0][j]=='\0')alldone=1;
4907 mapname[j-startpoint]='\0';
4909 player[0].armorlow=atof(mapname);
4914 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
4915 for(i=0;i<numplayers;i++){
4916 player[i].protectionhead=1.0;
4917 player[i].protectionhigh=1.0;
4918 player[i].protectionlow=1.0;
4919 player[i].armorhead=1.0;
4920 player[i].armorhigh=1.0;
4921 player[i].armorlow=1.0;
4927 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
4929 float closestdist=-1;
4932 for(i=1;i<numplayers;i++){
4933 distance=findDistancefast(&player[i].coords,&player[0].coords);
4934 if(closestdist==-1||distance<closestdist){
4935 closestdist=distance;
4945 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4946 mapname[j-startpoint]=consoletext[0][j];
4948 if(consoletext[0][j]=='\0')alldone=1;
4950 mapname[j-startpoint]='\0';
4952 player[closest].protectionhead=atof(mapname);
4956 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4957 mapname[j-startpoint]=consoletext[0][j];
4959 if(consoletext[0][j]=='\0')alldone=1;
4961 mapname[j-startpoint]='\0';
4963 player[closest].protectionhigh=atof(mapname);
4967 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4968 mapname[j-startpoint]=consoletext[0][j];
4970 if(consoletext[0][j]=='\0')alldone=1;
4972 mapname[j-startpoint]='\0';
4974 player[closest].protectionlow=atof(mapname);
4979 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
4981 float closestdist=-1;
4984 for(i=1;i<numplayers;i++){
4985 distance=findDistancefast(&player[i].coords,&player[0].coords);
4986 if(closestdist==-1||distance<closestdist){
4987 closestdist=distance;
4996 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4997 mapname[j-startpoint]=consoletext[0][j];
4999 if(consoletext[0][j]=='\0')alldone=1;
5001 mapname[j-startpoint]='\0';
5003 player[closest].armorhead=atof(mapname);
5007 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5008 mapname[j-startpoint]=consoletext[0][j];
5010 if(consoletext[0][j]=='\0')alldone=1;
5012 mapname[j-startpoint]='\0';
5014 player[closest].armorhigh=atof(mapname);
5018 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5019 mapname[j-startpoint]=consoletext[0][j];
5021 if(consoletext[0][j]=='\0')alldone=1;
5023 mapname[j-startpoint]='\0';
5025 player[closest].armorlow=atof(mapname);
5031 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5037 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5038 mapname[j-startpoint]=consoletext[0][j];
5040 if(consoletext[0][j]=='\0')alldone=1;
5042 mapname[j-startpoint]='\0';
5044 player[0].metalhead=atof(mapname);
5048 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5049 mapname[j-startpoint]=consoletext[0][j];
5051 if(consoletext[0][j]=='\0')alldone=1;
5053 mapname[j-startpoint]='\0';
5055 player[0].metalhigh=atof(mapname);
5059 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5060 mapname[j-startpoint]=consoletext[0][j];
5062 if(consoletext[0][j]=='\0')alldone=1;
5065 mapname[j-startpoint]='\0';
5067 player[0].metallow=atof(mapname);
5072 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5074 float closestdist=-1;
5077 for(i=1;i<numplayers;i++){
5078 distance=findDistancefast(&player[i].coords,&player[0].coords);
5079 if(closestdist==-1||distance<closestdist){
5080 closestdist=distance;
5084 player[closest].numclothes=0;
5085 if(player[closest].whichskin==0){
5086 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5088 else if(player[closest].whichskin==1){
5089 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5091 else if(player[closest].whichskin==2){
5092 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5094 else if(player[closest].whichskin==3){
5095 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5097 else if(player[closest].whichskin==4){
5098 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5100 else if(player[closest].whichskin==5){
5101 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5103 else if(player[closest].whichskin==6){
5104 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5106 else if(player[closest].whichskin==7){
5107 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5109 else if(player[closest].whichskin==8){
5110 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5112 else if(player[closest].whichskin==9){
5113 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5119 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5122 player[closest].numclothes=0;
5123 if(player[closest].whichskin==0){
5124 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5126 else if(player[closest].whichskin==1){
5127 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5129 else if(player[closest].whichskin==2){
5130 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5132 else if(player[closest].whichskin==3){
5133 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5135 else if(player[closest].whichskin==4){
5136 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5138 else if(player[closest].whichskin==5){
5139 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5141 else if(player[closest].whichskin==6){
5142 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5144 else if(player[closest].whichskin==7){
5145 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5147 else if(player[closest].whichskin==8){
5148 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5150 else if(player[closest].whichskin==9){
5151 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5157 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5173 for(j=8;j<consolechars[0];j++){
5174 mapname[j-8+15]=consoletext[0][j];
5176 mapname[consolechars[0]-8+15]='.';
5177 mapname[consolechars[0]-8+16]='p';
5178 mapname[consolechars[0]-8+17]='n';
5179 mapname[consolechars[0]-8+18]='g';
5180 mapname[consolechars[0]-8+19]='\0';
5182 //:Data:Textures:Pants.png
5184 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5185 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5186 strcpy(player[0].clothes[player[0].numclothes],mapname);
5187 player[0].clothestintr[player[0].numclothes]=tintr;
5188 player[0].clothestintg[player[0].numclothes]=tintg;
5189 player[0].clothestintb[player[0].numclothes]=tintb;
5190 player[0].numclothes++;
5196 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5197 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5202 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5203 cellophane=1-cellophane;
5206 for(i=0;i<numplayers;i++){
5207 player[i].proportionhead.z=0;
5208 player[i].proportionbody.z=0;
5209 player[i].proportionarms.z=0;
5210 player[i].proportionlegs.z=0;
5215 for(i=0;i<numplayers;i++){
5216 player[i].proportionhead.z=player[i].proportionhead.x;
5217 player[i].proportionbody.z=player[i].proportionbody.x;
5218 player[i].proportionarms.z=player[i].proportionarms.x;
5219 player[i].proportionlegs.z=player[i].proportionlegs.x;
5226 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5242 for(j=12;j<consolechars[0];j++){
5243 mapname[j-12+15]=consoletext[0][j];
5245 mapname[consolechars[0]-12+15]='.';
5246 mapname[consolechars[0]-12+16]='p';
5247 mapname[consolechars[0]-12+17]='n';
5248 mapname[consolechars[0]-12+18]='g';
5249 mapname[consolechars[0]-12+19]='\0';
5251 //:Data:Textures:Pants.png
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;
5264 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5265 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5266 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5267 player[closest].clothestintr[player[closest].numclothes]=tintr;
5268 player[closest].clothestintg[player[closest].numclothes]=tintg;
5269 player[closest].clothestintb[player[closest].numclothes]=tintb;
5270 player[closest].numclothes++;
5276 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5277 player[0].skeleton.id=0;
5278 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);
5279 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5280 player[0].creature=rabbittype;
5283 player[0].proportionhead=1.2;
5284 player[0].proportionbody=1.05;
5285 player[0].proportionarms=1.00;
5286 player[0].proportionlegs=1.1;
5287 player[0].proportionlegs.y=1.05;
5288 player[0].headless=0;
5290 player[0].damagetolerance=200;
5294 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5295 player[0].skeleton.id=0;
5296 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);
5297 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5298 player[0].creature=wolftype;
5300 player[0].proportionhead=1.1;
5301 player[0].proportionbody=1.1;
5302 player[0].proportionarms=1.1;
5303 player[0].proportionlegs=1.1;
5304 player[0].proportionlegs.y=1.1;
5305 player[0].scale=.23;
5307 player[0].damagetolerance=300;
5311 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5312 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5315 if(Compare(consoletext[0],"rambo ",0,5)){
5316 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5319 if(Compare(consoletext[0],"david ",0,5)){
5320 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5323 if(Compare(consoletext[0],"wolf ",0,4)){
5324 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5327 if(Compare(consoletext[0],"darkwolf ",0,8)){
5328 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5331 if(Compare(consoletext[0],"snowwolf ",0,8)){
5332 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5335 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5336 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5339 if(Compare(consoletext[0],"white ",0,5)){
5340 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5343 if(Compare(consoletext[0],"brown ",0,5)){
5344 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5347 if(Compare(consoletext[0],"black ",0,5)){
5348 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5351 if(consolechars[0]>0){
5354 consoletext[k][j]=consoletext[k-1][j];
5356 consolechars[k]=consolechars[k-1];
5359 consoletext[0][j]=' ';
5365 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5366 OPENAL_SetVolume(channels[consolefailsound], 256);
5367 OPENAL_SetPaused(channels[consolefailsound], false);
5376 togglekeydelay[i]=0;
5380 consoleblinkdelay-=multiplier;
5381 if(consoleblinkdelay<=0){
5382 consoleblinkdelay=.3;
5383 consoleblink=1-consoleblink;
5387 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5390 if(newdetail>2)newdetail=detail;
5391 if(newdetail<0)newdetail=detail;
5392 if(newscreenwidth<0)newscreenwidth=screenwidth;
5393 if(newscreenheight<0)newscreenheight=screenheight;
5395 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5396 opstream << "Screenwidth:\n";
5397 opstream << newscreenwidth;
5398 opstream << "\nScreenheight:\n";
5399 opstream << newscreenheight;
5400 opstream << "\nMouse sensitivity:\n";
5401 opstream << usermousesensitivity;
5402 opstream << "\nBlur(0,1):\n";
5403 opstream << ismotionblur;
5404 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5405 opstream << newdetail;
5406 opstream << "\nFloating jump:\n";
5407 opstream << floatjump;
5408 opstream << "\nMouse jump:\n";
5409 opstream << mousejump;
5410 opstream << "\nAmbient sound:\n";
5411 opstream << ambientsound;
5412 opstream << "\nBlood (0,1,2):\n";
5413 opstream << bloodtoggle;
5414 opstream << "\nAuto slomo:\n";
5415 opstream << autoslomo;
5416 opstream << "\nFoliage:\n";
5417 opstream << foliage;
5418 opstream << "\nMusic:\n";
5419 opstream << musictoggle;
5420 opstream << "\nTrilinear:\n";
5421 opstream << trilinear;
5422 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5424 opstream << "\nInvert mouse:\n";
5425 opstream << invertmouse;
5426 opstream << "\nGamespeed:\n";
5427 if(oldgamespeed==0)oldgamespeed=1;
5428 opstream << oldgamespeed;
5429 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5430 opstream << difficulty;
5431 opstream << "\nDamage effects(blackout, doublevision):\n";
5432 opstream << damageeffects;
5433 opstream << "\nText:\n";
5434 opstream << texttoggle;
5435 opstream << "\nDebug:\n";
5436 opstream << debugmode;
5437 opstream << "\nVBL Sync:\n";
5438 opstream << vblsync;
5439 opstream << "\nShow Points:\n";
5440 opstream << showpoints;
5441 opstream << "\nAlways Blur:\n";
5442 opstream << alwaysblur;
5443 opstream << "\nImmediate mode (turn on on G5):\n";
5444 opstream << immediate;
5445 opstream << "\nVelocity blur:\n";
5446 opstream << velocityblur;
5447 opstream << "\nVolume:\n";
5449 opstream << "\nForward key:\n";
5450 opstream << KeyToChar(forwardkey);
5451 opstream << "\nBack key:\n";
5452 opstream << KeyToChar(backkey);
5453 opstream << "\nLeft key:\n";
5454 opstream << KeyToChar(leftkey);
5455 opstream << "\nRight key:\n";
5456 opstream << KeyToChar(rightkey);
5457 opstream << "\nJump key:\n";
5458 opstream << KeyToChar(jumpkey);
5459 opstream << "\nCrouch key:\n";
5460 opstream << KeyToChar(crouchkey);
5461 opstream << "\nDraw key:\n";
5462 opstream << KeyToChar(drawkey);
5463 opstream << "\nThrow key:\n";
5464 opstream << KeyToChar(throwkey);
5465 opstream << "\nAttack key:\n";
5466 opstream << KeyToChar(attackkey);
5467 opstream << "\nChat key:\n";
5468 opstream << KeyToChar(chatkey);
5473 static int oldwinfreeze;
5474 if(winfreeze&&!oldwinfreeze){
5475 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
5476 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5477 OPENAL_SetVolume(channels[consolesuccesssound], 256);
5478 OPENAL_SetPaused(channels[consolesuccesssound], false);
5480 if(winfreeze==0)oldwinfreeze=winfreeze;
5481 else oldwinfreeze++;
5483 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5484 if(winfreeze)winfreeze=0;
5487 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5493 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5496 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5498 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5500 static bool oldbuttondialogue;
5502 if(indialogue!=-1)talkdelay=1;
5503 talkdelay-=multiplier;
5506 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5507 for(i=0;i<numdialogues;i++){
5508 int realdialoguetype;
5510 if(dialoguetype[i]>49){
5511 realdialoguetype=dialoguetype[i]-50;
5514 else if(dialoguetype[i]>39){
5515 realdialoguetype=dialoguetype[i]-40;
5518 else if(dialoguetype[i]>29){
5519 realdialoguetype=dialoguetype[i]-30;
5522 else if(dialoguetype[i]>19){
5523 realdialoguetype=dialoguetype[i]-20;
5526 else if(dialoguetype[i]>9){
5527 realdialoguetype=dialoguetype[i]-10;
5531 realdialoguetype=dialoguetype[i];
5534 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5535 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5537 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5538 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5539 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5540 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5541 player[participantfocus[whichdialogue][j]].velocity=0;
5542 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5543 player[participantfocus[whichdialogue][j]].targetframe=0;
5548 dialoguegonethrough[i]++;
5549 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5550 static float gLoc[3];
5551 static float vel[3];
5553 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5554 temppos=temppos-viewer;
5555 Normalise(&temppos);
5560 gLoc[2]=temppos.z;vel[0]=0;
5564 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5565 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5566 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5567 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5568 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5569 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5570 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5571 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5572 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5573 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5574 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5575 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5576 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5577 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5578 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5579 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5580 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5581 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5582 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5583 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5584 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5585 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5586 OPENAL_SetVolume(channels[whichsoundplay], 256);
5587 OPENAL_SetPaused(channels[whichsoundplay], false);
5589 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5594 windvar+=multiplier;
5595 smoketex+=multiplier;
5596 tutorialstagetime+=multiplier;
5598 static float hotspotvisual[40];
5602 for(i=0;i<numhotspots;i++)
5603 hotspotvisual[i]-=multiplier/320;
5605 for(i=0;i<numhotspots;i++){
5606 //if(hotspottype[i]<=10)
5607 while(hotspotvisual[i]<0){
5609 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5610 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5611 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5612 hotspotsprite+=hotspot[i];
5613 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5614 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5618 for(i=0;i<numhotspots;i++){
5619 if(hotspottype[i]<=10&&hotspottype[i]>0){
5620 hotspot[i]=player[hotspottype[i]].coords;
5626 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5629 if(tutorialstage<=1){
5634 if(tutorialstage==1){
5637 if(tutorialstage==2){
5640 if(tutorialstage==3){
5641 tutorialmaxtime=600;
5643 if(tutorialstage==4){
5644 tutorialmaxtime=1000;
5646 if(tutorialstage==5){
5647 tutorialmaxtime=600;
5649 if(tutorialstage==6){
5650 tutorialmaxtime=600;
5652 if(tutorialstage==7){
5653 tutorialmaxtime=600;
5655 if(tutorialstage==8){
5656 tutorialmaxtime=600;
5658 if(tutorialstage==9){
5659 tutorialmaxtime=600;
5661 if(tutorialstage==10){
5664 if(tutorialstage==11){
5665 tutorialmaxtime=1000;
5667 if(tutorialstage==12){
5668 tutorialmaxtime=1000;
5670 if(tutorialstage==13){
5673 if(tutorialstage==14){
5685 player[1].coords=(temp+temp2)/2;
5689 gLoc[0]=player[1].coords.x;
5690 gLoc[1]=player[1].coords.y;
5691 gLoc[2]=player[1].coords.z;
5695 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5696 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5697 OPENAL_SetVolume(channels[fireendsound], 256);
5698 OPENAL_SetPaused(channels[fireendsound], false);
5700 for(i=0;i<player[1].skeleton.num_joints;i++){
5702 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5703 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5704 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;
5705 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5706 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5711 if(tutorialstage==15){
5712 tutorialmaxtime=500;
5714 if(tutorialstage==16){
5715 tutorialmaxtime=500;
5717 if(tutorialstage==17){
5718 tutorialmaxtime=500;
5720 if(tutorialstage==18){
5721 tutorialmaxtime=500;
5723 if(tutorialstage==19){
5725 //tutorialmaxtime=500;
5727 if(tutorialstage==20){
5728 tutorialmaxtime=500;
5730 if(tutorialstage==21){
5731 tutorialmaxtime=500;
5738 if(tutorialstage==22){
5739 tutorialmaxtime=500;
5741 if(tutorialstage==23){
5742 tutorialmaxtime=500;
5744 if(tutorialstage==24){
5745 tutorialmaxtime=500;
5747 if(tutorialstage==25){
5748 tutorialmaxtime=500;
5750 if(tutorialstage==26){
5753 if(tutorialstage==27){
5757 player[1].aitype=attacktypecutoff;
5759 if(tutorialstage==28){
5760 tutorialmaxtime=400;
5762 if(tutorialstage==29){
5763 tutorialmaxtime=400;
5764 player[0].escapednum=0;
5766 if(tutorialstage==30){
5770 player[1].aitype=passivetype;
5772 if(tutorialstage==31){
5775 if(tutorialstage==32){
5778 if(tutorialstage==33){
5779 tutorialmaxtime=400;
5782 player[1].aitype=attacktypecutoff;
5784 if(tutorialstage==34){
5785 tutorialmaxtime=400;
5787 if(tutorialstage==35){
5788 tutorialmaxtime=400;
5790 if(tutorialstage==36){
5794 player[1].aitype=passivetype;
5796 if(tutorialstage==37){
5802 player[1].aitype=attacktypecutoff;
5804 if(tutorialstage==38){
5808 player[1].aitype=passivetype;
5810 if(tutorialstage==39){
5821 weapons.owner[weapons.numweapons]=-1;
5822 weapons.type[weapons.numweapons]=knife;
5823 weapons.damage[weapons.numweapons]=0;
5824 weapons.mass[weapons.numweapons]=1;
5825 weapons.tipmass[weapons.numweapons]=1.2;
5826 weapons.length[weapons.numweapons]=.25;
5827 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5828 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5830 weapons.velocity[weapons.numweapons]=0.1;
5831 weapons.tipvelocity[weapons.numweapons]=0.1;
5832 weapons.missed[weapons.numweapons]=1;
5833 weapons.hitsomething[weapons.numweapons]=0;
5834 weapons.freetime[weapons.numweapons]=0;
5835 weapons.firstfree[weapons.numweapons]=1;
5836 weapons.physics[weapons.numweapons]=1;
5838 weapons.numweapons++;
5840 if(tutorialstage==40){
5841 tutorialmaxtime=300;
5843 if(tutorialstage==41){
5844 tutorialmaxtime=300;
5846 if(tutorialstage==42){
5849 if(tutorialstage==43){
5850 tutorialmaxtime=300;
5852 if(tutorialstage==44){
5854 player[0].weaponactive=-1;
5855 player[0].num_weapons=0;
5856 player[1].weaponactive=0;
5857 player[1].num_weapons=1;
5858 player[1].weaponids[0]=0;
5862 player[1].aitype=attacktypecutoff;
5864 tutorialmaxtime=300;
5866 if(tutorialstage==45){
5868 player[0].weaponactive=-1;
5869 player[0].num_weapons=0;
5870 player[1].weaponactive=0;
5871 player[1].num_weapons=1;
5872 player[1].weaponids[0]=0;
5874 tutorialmaxtime=300;
5876 if(tutorialstage==46){
5878 player[0].weaponactive=-1;
5879 player[0].num_weapons=0;
5880 player[1].weaponactive=0;
5881 player[1].num_weapons=1;
5882 player[1].weaponids[0]=0;
5884 weapons.type[0]=sword;
5886 tutorialmaxtime=300;
5889 if(tutorialstage==47){
5901 weapons.owner[weapons.numweapons]=-1;
5902 weapons.type[weapons.numweapons]=sword;
5903 weapons.damage[weapons.numweapons]=0;
5904 weapons.mass[weapons.numweapons]=1;
5905 weapons.tipmass[weapons.numweapons]=1.2;
5906 weapons.length[weapons.numweapons]=.25;
5907 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5908 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5910 weapons.velocity[weapons.numweapons]=0.1;
5911 weapons.tipvelocity[weapons.numweapons]=0.1;
5912 weapons.missed[weapons.numweapons]=1;
5913 weapons.hitsomething[weapons.numweapons]=0;
5914 weapons.freetime[weapons.numweapons]=0;
5915 weapons.firstfree[weapons.numweapons]=1;
5916 weapons.physics[weapons.numweapons]=1;
5920 player[0].weaponactive=0;
5921 player[0].num_weapons=1;
5922 player[0].weaponids[0]=1;
5923 player[1].weaponactive=0;
5924 player[1].num_weapons=1;
5925 player[1].weaponids[0]=0;
5927 weapons.numweapons++;
5929 if(tutorialstage==48){
5932 player[1].aitype=passivetype;
5938 player[0].weaponactive=0;
5939 player[0].num_weapons=1;
5940 player[0].weaponids[0]=1;
5941 player[1].weaponactive=0;
5942 player[1].num_weapons=1;
5943 player[1].weaponids[0]=0;
5945 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
5946 else weapons.type[0]=staff;
5948 weapons.numweapons++;
5950 if(tutorialstage==49){
5953 player[1].aitype=passivetype;
5955 tutorialmaxtime=200;
5957 weapons.position[1]=1000;
5958 weapons.tippoint[1]=1000;
5960 weapons.numweapons=1;
5962 player[1].weaponactive=-1;
5963 player[1].num_weapons=0;
5964 player[0].weaponactive=0;
5965 player[0].num_weapons=1;
5966 player[0].weaponids[0]=0;
5968 weapons.type[0]=knife;
5970 weapons.numweapons++;
5972 if(tutorialstage==50){
5978 gLoc[0]=player[1].coords.x;
5979 gLoc[1]=player[1].coords.y;
5980 gLoc[2]=player[1].coords.z;
5984 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5985 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5986 OPENAL_SetVolume(channels[fireendsound], 256);
5987 OPENAL_SetPaused(channels[fireendsound], false);
5989 for(i=0;i<player[1].skeleton.num_joints;i++){
5991 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5992 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5993 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;
5994 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5995 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5999 player[1].num_weapons=0;
6000 player[1].weaponstuck=-1;
6001 player[1].weaponactive=-1;
6003 weapons.numweapons=0;
6005 weapons.owner[0]=-1;
6006 weapons.velocity[0]=0.1;
6007 weapons.tipvelocity[0]=-0.1;
6008 weapons.missed[0]=1;
6009 weapons.hitsomething[0]=0;
6010 weapons.freetime[0]=0;
6011 weapons.firstfree[0]=1;
6012 weapons.physics[0]=1;
6014 if(tutorialstage==51){
6015 tutorialmaxtime=80000;
6017 if(tutorialstage<=51)tutorialstagetime=0;
6021 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6022 if(tutorialstage==3){
6023 if(deltah||deltav)tutorialsuccess+=multiplier;
6025 if(tutorialstage==4){
6026 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6028 if(tutorialstage==5){
6029 if(player[0].jumpkeydown)tutorialsuccess=1;
6031 if(tutorialstage==6){
6032 if(player[0].isCrouch())tutorialsuccess=1;
6034 if(tutorialstage==7){
6035 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6037 if(tutorialstage==8){
6038 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6040 if(tutorialstage==9){
6041 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6043 if(tutorialstage==11){
6044 if(player[0].isWallJump())tutorialsuccess=1;
6046 if(tutorialstage==12){
6047 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6049 if(tutorialstage==15){
6050 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6052 if(tutorialstage==16){
6053 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6055 if(tutorialstage==17){
6056 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6058 if(tutorialstage==18){
6059 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6061 if(tutorialstage==19){
6062 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6064 if(tutorialstage==20){
6065 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6067 if(tutorialstage==21){
6068 if(bonus==cannon)tutorialsuccess=1;
6070 if(tutorialstage==22){
6071 if(bonus==spinecrusher)tutorialsuccess=1;
6073 if(tutorialstage==23){
6074 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6076 if(tutorialstage==24){
6077 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6079 if(tutorialstage==25){
6080 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6082 if(tutorialstage==28){
6083 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6085 if(tutorialstage==29){
6086 if(player[0].escapednum==2){
6090 player[1].aitype=passivetype;
6093 if(tutorialstage==33){
6094 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6096 if(tutorialstage==34){
6097 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6099 if(tutorialstage==35){
6100 if(animation[player[0].targetanimation].attack==reversal){
6104 player[1].aitype=passivetype;
6107 if(tutorialstage==40){
6108 if(player[0].num_weapons>0)tutorialsuccess=1;
6110 if(tutorialstage==41){
6111 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6113 if(tutorialstage==43){
6114 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6116 if(tutorialstage==44){
6117 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6119 if(tutorialstage==45){
6120 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6122 if(tutorialstage==46){
6123 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6125 if(tutorialstage==49){
6126 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6128 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6131 if(tutorialstagetime==tutorialmaxtime-3){
6132 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6133 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6134 OPENAL_SetPaused(channels[consolesuccesssound], false);
6137 if(tutorialsuccess>=1){
6138 if(tutorialstage==34||tutorialstage==35)
6139 tutorialstagetime=tutorialmaxtime-1;
6144 if(tutorialstage<14||tutorialstage>=50){
6145 player[1].coords.y=300;
6146 player[1].velocity=0;
6150 if(tutoriallevel!=1){
6151 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6152 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6153 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6154 OPENAL_SetPaused(channels[consolesuccesssound], false);
6159 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6160 OPENAL_SetVolume(channels[fireendsound], 256);
6161 OPENAL_SetPaused(channels[fireendsound], false);
6164 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6165 else bonusnum[bonus]+=0.15;
6166 if(tutoriallevel)bonusvalue=0;
6167 bonusvalue/=bonusnum[bonus];
6168 bonustotal+=bonusvalue;
6170 bonustime+=multiplier;
6172 if(environment==snowyenvironment){
6173 precipdelay-=multiplier;
6174 while(precipdelay<0){
6176 if(!detail)precipdelay+=.04;
6177 XYZ footvel,footpoint;
6180 footpoint=viewer+viewerfacing*6;
6181 footpoint.y+=((float)abs(Random()%1200))/100-6;
6182 footpoint.x+=((float)abs(Random()%1200))/100-6;
6183 footpoint.z+=((float)abs(Random()%1200))/100-6;
6184 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6187 for(k=0;k<numplayers;k++){
6188 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6189 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6191 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){
6192 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6193 else if(player[k].rotation>player[k].targetrotation){
6194 player[k].rotation-=multiplier*player[k].turnspeed;
6196 else if(player[k].rotation<player[k].targetrotation){
6197 player[k].rotation+=multiplier*player[k].turnspeed;
6202 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))){
6203 player[k].turnspeed*=2;
6204 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6205 else if(player[k].rotation>player[k].targetrotation){
6206 player[k].rotation-=multiplier*player[k].turnspeed;
6208 else if(player[k].rotation<player[k].targetrotation){
6209 player[k].rotation+=multiplier*player[k].turnspeed;
6211 player[k].turnspeed/=2;
6214 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6215 player[k].turnspeed*=4;
6216 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6217 else if(player[k].rotation>player[k].targetrotation){
6218 player[k].rotation-=multiplier*player[k].turnspeed;
6220 else if(player[k].rotation<player[k].targetrotation){
6221 player[k].rotation+=multiplier*player[k].turnspeed;
6223 player[k].turnspeed/=4;
6226 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6227 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6229 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6230 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6233 if(player[k].collide<-.3)player[k].collide=-.3;
6234 if(player[k].collide>1)player[k].collide=1;
6235 player[k].collide-=multiplier*30;
6237 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6238 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6240 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6241 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6242 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6243 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6244 lowpoint=player[k].coords;
6245 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6246 else lowpoint.y+=1.3;
6247 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){
6248 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6250 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6251 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6253 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6254 flatfacing=lowpoint-player[k].coords;
6255 player[k].coords=lowpoint;
6256 player[k].coords.y-=1.3;
6257 player[k].collide=1;
6259 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6260 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6261 tempcoords1=lowpoint;
6262 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6263 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6265 player[k].targetanimation=walljumpleftanim;
6266 player[k].targetframe=0;
6269 gLoc[0]=player[k].coords.x;
6270 gLoc[1]=player[k].coords.y;
6271 gLoc[2]=player[k].coords.z;
6275 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6276 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6277 OPENAL_SetVolume(channels[movewhooshsound], 256);
6278 OPENAL_SetPaused(channels[movewhooshsound], false);
6279 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6281 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6282 player[k].rotation=-asin(0-lowpointtarget.x);
6283 player[k].rotation*=360/6.28;
6284 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6285 player[k].targetrotation=player[k].rotation;
6286 player[k].lowrotation=player[k].rotation;
6287 if(k==0)numwallflipped++;
6291 lowpoint=tempcoords1;
6292 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6293 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6294 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6296 player[k].targetanimation=walljumprightanim;
6297 player[k].targetframe=0;
6300 gLoc[0]=player[k].coords.x;
6301 gLoc[1]=player[k].coords.y;
6302 gLoc[2]=player[k].coords.z;
6306 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6307 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6308 OPENAL_SetVolume(channels[movewhooshsound], 256);
6309 OPENAL_SetPaused(channels[movewhooshsound], false);
6310 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6312 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6313 player[k].rotation=-asin(0-lowpointtarget.x);
6314 player[k].rotation*=360/6.28;
6315 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6316 player[k].targetrotation=player[k].rotation;
6317 player[k].lowrotation=player[k].rotation;
6318 if(k==0)numwallflipped++;
6322 lowpoint=tempcoords1;
6323 lowpointtarget=lowpoint+player[k].facing*2;
6324 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6325 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6327 player[k].targetanimation=walljumpbackanim;
6328 player[k].targetframe=0;
6331 gLoc[0]=player[k].coords.x;
6332 gLoc[1]=player[k].coords.y;
6333 gLoc[2]=player[k].coords.z;
6337 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6338 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6339 OPENAL_SetVolume(channels[movewhooshsound], 256);
6340 OPENAL_SetPaused(channels[movewhooshsound], false);
6341 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6343 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6344 player[k].rotation=-asin(0-lowpointtarget.x);
6345 player[k].rotation*=360/6.28;
6346 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6347 player[k].targetrotation=player[k].rotation;
6348 player[k].lowrotation=player[k].rotation;
6349 if(k==0)numwallflipped++;
6353 lowpoint=tempcoords1;
6354 lowpointtarget=lowpoint-player[k].facing*2;
6355 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6356 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6358 player[k].targetanimation=walljumpfrontanim;
6359 player[k].targetframe=0;
6362 gLoc[0]=player[k].coords.x;
6363 gLoc[1]=player[k].coords.y;
6364 gLoc[2]=player[k].coords.z;
6368 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6369 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6370 OPENAL_SetVolume(channels[movewhooshsound], 256);
6371 OPENAL_SetPaused(channels[movewhooshsound], false);
6372 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6374 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6375 player[k].rotation=-asin(0-lowpointtarget.x);
6376 player[k].rotation*=360/6.28;
6377 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6378 player[k].rotation+=180;
6379 player[k].targetrotation=player[k].rotation;
6380 player[k].lowrotation=player[k].rotation;
6381 if(k==0)numwallflipped++;
6389 else if(objects.type[i]==rocktype){
6390 lowpoint2=player[k].coords;
6391 lowpoint=player[k].coords;
6393 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6394 player[k].coords=colpoint;
6395 player[k].collide=1;
6398 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6399 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6401 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6403 player[k].targetframe=0;
6404 player[k].onterrain=1;
6406 if(player[k].id==0){
6407 OPENAL_SetPaused(channels[whooshsound], true);
6408 OPENAL_SetVolume(channels[whooshsound], 0);
6411 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6412 if(player[k].isFlip())player[k].jumppower=-4;
6413 player[k].targetanimation=player[k].getLanding();
6416 gLoc[0]=player[k].coords.x;
6417 gLoc[1]=player[k].coords.y;
6418 gLoc[2]=player[k].coords.z;
6419 vel[0]=player[k].velocity.x;
6420 vel[1]=player[k].velocity.y;
6421 vel[2]=player[k].velocity.z;
6422 PlaySoundEx( landsound, samp[landsound], NULL, true);
6423 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6424 OPENAL_SetVolume(channels[landsound], 128);
6425 OPENAL_SetPaused(channels[landsound], false);
6427 envsound[numenvsounds]=player[k].coords;
6428 envsoundvol[numenvsounds]=16;
6429 envsoundlife[numenvsounds]=.4;
6438 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6439 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6440 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6441 lowpoint=player[k].coords;
6443 if(objects.type[i]!=rocktype)
6444 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6445 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6446 player[k].coords=lowpoint;
6447 player[k].coords.y-=1.35;
6448 player[k].collide=1;
6450 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)){
6451 lowpoint=player[k].coords;
6452 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6453 lowpoint=player[k].coords;
6457 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6458 lowpointtarget=lowpoint+facing*1.4;
6459 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6461 lowpoint=player[k].coords;
6463 lowpointtarget=lowpoint+facing*1.4;
6465 lowpointtarget2=lowpointtarget;
6467 lowpointtarget3=lowpointtarget;
6469 lowpointtarget4=lowpointtarget;
6471 lowpointtarget5=lowpointtarget;
6473 lowpointtarget6=lowpointtarget;
6475 lowpointtarget7=lowpoint;
6477 lowpointtarget2.x+=.1;
6479 lowpointtarget3.z+=.1;
6481 lowpointtarget4.x-=.1;
6483 lowpointtarget5.z-=.1;
6485 lowpointtarget6.y+=45/13;
6486 lowpointtarget6+=facing*.6;
6487 lowpointtarget7.y+=90/13;
6488 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6489 if(objects.friction[i]>.5)
6492 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6493 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6494 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6495 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)
6497 lowpoint=player[k].coords;
6498 lowpoint.y+=(float)j/13;
6499 lowpointtarget=lowpoint+facing*1.4;
6500 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6504 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6507 if(j<=25&&player[k].targetanimation==jumpdownanim){
6510 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6511 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6512 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)*/){
6513 lowpoint=player[k].coords;
6514 lowpoint.y+=(float)j/13;
6515 lowpointtarget=lowpoint+facing*1.3;
6516 flatfacing=player[k].coords;
6517 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6518 player[k].coords.y=lowpointtarget.y-.07;
6519 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6521 if(j>10||!player[k].isRun()){
6522 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6523 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6527 gLoc[0]=player[k].coords.x;
6528 gLoc[1]=player[k].coords.y;
6529 gLoc[2]=player[k].coords.z;
6530 vel[0]=player[k].velocity.x;
6531 vel[1]=player[k].velocity.y;
6532 vel[2]=player[k].velocity.z;
6533 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6534 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6535 OPENAL_SetVolume(channels[jumpsound], 128);
6536 OPENAL_SetPaused(channels[jumpsound], false);
6538 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6539 player[k].rotation=-asin(0-lowpointtarget.x);
6540 player[k].rotation*=360/6.28;
6541 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6542 player[k].targetrotation=player[k].rotation;
6543 player[k].lowrotation=player[k].rotation;
6545 //player[k].velocity=lowpointtarget*.03;
6546 player[k].velocity=0;
6548 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6549 //player[k].currentanimation=climbanim;
6550 player[k].targetanimation=climbanim;
6551 player[k].jumppower=0;
6552 player[k].jumpclimb=1;
6554 player[k].transspeed=6;
6557 //player[k].currentframe=1;
6558 player[k].targetframe=1;
6560 //player[k].currentframe=0;
6561 player[k].targetframe=0;
6562 //player[k].currentanimation=hanganim;
6563 player[k].targetanimation=hanganim;
6564 player[k].jumppower=0;
6578 if(player[k].collide<=0){
6579 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()){
6580 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)){
6581 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6582 player[k].targetanimation=jumpdownanim;
6583 player[k].targetframe=0;
6588 gLoc[0]=player[k].coords.x;
6589 gLoc[1]=player[k].coords.y;
6590 gLoc[2]=player[k].coords.z;
6591 vel[0]=player[k].velocity.x;
6592 vel[1]=player[k].velocity.y;
6593 vel[2]=player[k].velocity.z;
6595 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6596 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6597 OPENAL_SetVolume(channels[whooshsound], 128);
6598 OPENAL_SetPaused(channels[whooshsound], false);
6601 player[k].velocity.y+=gravity;
6606 player[k].realoldcoords=player[k].coords;
6609 static XYZ oldviewer;
6612 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6613 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6614 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6615 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6616 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6617 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6618 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6619 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6623 player[0].forwardkeydown=0;
6624 player[0].leftkeydown=0;
6625 player[0].backkeydown=0;
6626 player[0].rightkeydown=0;
6627 player[0].jumpkeydown=0;
6628 player[0].crouchkeydown=0;
6629 player[0].drawkeydown=0;
6630 player[0].throwkeydown=0;
6633 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6636 static bool endkeydown;
6643 facing=DoRotation(facing,-rotation2,0,0);
6644 facing=DoRotation(facing,0,0-rotation,0);
6649 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6651 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6652 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6653 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6654 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6655 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6656 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6657 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)
6658 ||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)
6659 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6661 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6662 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6663 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6664 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6665 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6666 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6667 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6668 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6669 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6670 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6671 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6673 participantfocus[whichdialogue][indialogue]=whichend;
6674 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6675 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6678 participantfocus[whichdialogue][indialogue]=-1;
6680 if(player[participantfocus[whichdialogue][indialogue]].dead){
6685 dialoguecamera[whichdialogue][indialogue]=viewer;
6686 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6687 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6689 if(indialogue<numdialogueboxes[whichdialogue]){
6690 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6691 static float gLoc[3];
6692 static float vel[3];
6694 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6695 temppos=temppos-viewer;
6696 Normalise(&temppos);
6701 gLoc[2]=temppos.z;vel[0]=0;
6705 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6706 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6707 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6708 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6709 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6710 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6711 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6712 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6713 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6714 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6715 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6716 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6717 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6718 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6719 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6720 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6721 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6722 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6723 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6724 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6725 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6726 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6727 OPENAL_SetVolume(channels[whichsoundplay], 256);
6728 OPENAL_SetPaused(channels[whichsoundplay], false);
6732 for(j=0;j<numplayers;j++){
6733 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6738 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)
6739 ||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)
6742 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6743 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6744 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6745 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6746 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6747 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6748 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6749 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6750 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6751 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6752 participantfacing[whichdialogue][indialogue][whichend]=facing;
6754 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)
6755 &&!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)
6756 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6759 if(indialogue>=numdialogueboxes[whichdialogue]){
6766 OPENAL_SetPaused(channels[whooshsound], true);
6767 viewer=dialoguecamera[whichdialogue][indialogue];
6768 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
6769 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
6771 rotation=dialoguecamerarotation[whichdialogue][indialogue];
6772 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
6773 if(dialoguetime>0.5)
6774 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)
6775 ||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)
6776 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
6779 if(indialogue<numdialogueboxes[whichdialogue]){
6780 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6781 static float gLoc[3];
6782 static float vel[3];
6784 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6785 temppos=temppos-viewer;
6786 Normalise(&temppos);
6791 gLoc[2]=temppos.z;vel[0]=0;
6795 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6796 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6797 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6798 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6799 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6800 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6801 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6802 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6803 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6804 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6805 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6806 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6807 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6808 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6809 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6810 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6811 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6812 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6813 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6814 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6815 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
6816 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
6817 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6818 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6819 OPENAL_SetVolume(channels[whichsoundplay], 256);
6820 OPENAL_SetPaused(channels[whichsoundplay], false);
6822 if(dialogueboxsound[whichdialogue][indialogue]==-5){
6823 hotspot[numhotspots]=player[0].coords;
6824 hotspotsize[numhotspots]=10;
6825 hotspottype[numhotspots]=-1;
6829 if(dialogueboxsound[whichdialogue][indialogue]==-6){
6833 if(player[participantfocus[whichdialogue][indialogue]].dead){
6841 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)
6842 &&!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)
6843 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6846 if(indialogue>=numdialogueboxes[whichdialogue]){
6850 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
6853 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
6856 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
6858 for(i=1;i<numplayers;i++){
6859 player[i].aitype = attacktypecutoff;
6866 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
6867 else oldbuttondialogue=1;
6869 static float keyrefreshdelay=0,bigrefreshdelay=0;
6873 /*keyrefreshdelay-=multiplier;
6874 bigrefreshdelay-=multiplier;
6876 if(keyrefreshdelay<=0){
6877 static int concat[4];
6879 concat[0]=player[0].forwardkeydown;
6880 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
6881 concat[0]=concat[0]*2+player[0].rightkeydown;
6882 concat[0]=concat[0]*2+player[0].leftkeydown;
6883 concat[0]=concat[0]*2+player[0].backkeydown;
6884 concat[0]=concat[0]*2+player[0].jumpkeydown;
6885 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
6886 concat[0]=concat[0]*2+player[0].crouchkeydown;
6888 concat[1]=player[0].crouchtogglekeydown;
6889 concat[1]=concat[1]*2+player[0].drawkeydown;
6890 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
6891 concat[1]=concat[1]*2+player[0].throwkeydown;
6892 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
6893 concat[1]=concat[1]*2+player[0].attackkeydown;
6895 //concat[2]=(char)((int)(rotation/2)%180);
6897 //concat[3]=(char)((int)(rotation2/2)%180);
6899 chatname[0]=concat[0]-128;
6900 chatname[1]=concat[1]-128;
6901 //chatname[2]=concat[2]-128;
6902 //chatname[3]=concat[3]-128;
6904 memcpy(chatname+temppoint,&rotation,sizeof(float));
6905 temppoint+=sizeof(float);
6906 memcpy(chatname+temppoint,&rotation2,sizeof(float));
6907 temppoint+=sizeof(float);
6909 chatname[temppoint]='\0';
6911 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
6912 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
6913 //keyrefreshdelay=.01;
6914 keyrefreshdelay=.03;
6917 if(bigrefreshdelay<=0){
6920 memcpy(chatname+temppoint,&i,sizeof(int));
6921 temppoint+=sizeof(int);
6922 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
6923 temppoint+=sizeof(float);
6924 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
6925 temppoint+=sizeof(float);
6926 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
6927 temppoint+=sizeof(float);
6928 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
6929 temppoint+=sizeof(float);
6930 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
6931 temppoint+=sizeof(float);
6932 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
6933 temppoint+=sizeof(int);
6934 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
6935 temppoint+=sizeof(int);
6936 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
6937 temppoint+=sizeof(float);
6938 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
6939 temppoint+=sizeof(float);
6940 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
6941 temppoint+=sizeof(float);
6942 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
6943 temppoint+=sizeof(int);
6944 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
6945 temppoint+=sizeof(int);
6946 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
6947 temppoint+=sizeof(float);
6948 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
6949 temppoint+=sizeof(float);
6950 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
6951 temppoint+=sizeof(float);
6952 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
6953 temppoint+=sizeof(int);
6954 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
6955 temppoint+=sizeof(int);
6956 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
6957 temppoint+=sizeof(int);
6958 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
6959 temppoint+=sizeof(int);
6960 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
6961 temppoint+=sizeof(int);
6962 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
6963 temppoint+=sizeof(int);
6964 chatname[temppoint]='\0';
6966 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);
6967 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
6968 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
6970 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);
6972 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
6973 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
6975 //bigrefreshdelay=.02;
6980 if(!player[0].jumpkeydown){
6981 player[0].jumptogglekeydown=0;
6983 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
6986 dialoguetime+=multiplier;
6987 skybox.cloudmove+=multiplier;
6988 hawkrotation+=multiplier*25;
6990 realhawkcoords.x=25;
6991 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
6992 hawkcalldelay-=multiplier/2;
6994 if(hawkcalldelay<=0)
6996 static float gLoc[3];
6997 static float vel[3];
6998 gLoc[0]=realhawkcoords.x;
6999 gLoc[1]=realhawkcoords.y;
7000 gLoc[2]=realhawkcoords.z;
7004 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
7005 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
7006 OPENAL_SetVolume(channels[hawksound], 128);
7007 OPENAL_SetPaused(channels[hawksound], false);
7009 hawkcalldelay=16+abs(Random()%8);
7011 static float temptexdetail;
7014 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7015 player[0].damagetolerance=200000;
7018 player[0].permanentdamage=0;
7019 player[0].superpermanentdamage=0;
7022 whichchar = abs(Random()%7);
7023 registrationname[whichchar]+=1;
7027 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7029 if(environment>2)environment=0;
7030 Setenvironment(environment);
7036 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7040 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7041 cameramode=1-cameramode;
7042 cameratogglekeydown=1;
7045 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7046 cameratogglekeydown=0;
7049 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7050 if(player[0].num_weapons>0){
7051 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7052 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7053 else weapons.type[player[0].weaponids[0]]=sword;
7054 if(weapons.type[player[0].weaponids[0]]==sword){
7055 weapons.mass[player[0].weaponids[0]]=1.5;
7056 weapons.tipmass[player[0].weaponids[0]]=1;
7057 weapons.length[player[0].weaponids[0]]=.8;
7059 if(weapons.type[player[0].weaponids[0]]==staff){
7060 weapons.mass[player[0].weaponids[0]]=2;
7061 weapons.tipmass[player[0].weaponids[0]]=1;
7062 weapons.length[player[0].weaponids[0]]=1.5;
7065 if(weapons.type[player[0].weaponids[0]]==knife){
7066 weapons.mass[player[0].weaponids[0]]=1;
7067 weapons.tipmass[player[0].weaponids[0]]=1.2;
7068 weapons.length[player[0].weaponids[0]]=.25;
7072 /*for(i=0;i<objects.numobjects;i++){
7073 if(objects.type[i]==treeleavestype){
7074 for(j=0;j<objects.numobjects;j++){
7075 if(objects.type[j]==treetrunktype)
7076 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7077 objects.scale[i]=objects.scale[j];
7081 detailtogglekeydown=1;
7084 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7086 float closestdist=-1;
7089 for(i=1;i<numplayers;i++){
7090 distance=findDistancefast(&player[i].coords,&player[0].coords);
7091 if(closestdist==-1||distance<closestdist){
7092 closestdist=distance;
7097 if(player[closest].num_weapons)
7099 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7100 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7101 else weapons.type[player[closest].weaponids[0]]=sword;
7102 if(weapons.type[player[closest].weaponids[0]]==sword){
7103 weapons.mass[player[closest].weaponids[0]]=1.5;
7104 weapons.tipmass[player[closest].weaponids[0]]=1;
7105 weapons.length[player[closest].weaponids[0]]=.8;
7107 if(weapons.type[player[0].weaponids[0]]==staff){
7108 weapons.mass[player[0].weaponids[0]]=2;
7109 weapons.tipmass[player[0].weaponids[0]]=1;
7110 weapons.length[player[0].weaponids[0]]=1.5;
7112 if(weapons.type[player[closest].weaponids[0]]==knife){
7113 weapons.mass[player[closest].weaponids[0]]=1;
7114 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7115 weapons.length[player[closest].weaponids[0]]=.25;
7118 if(!player[closest].num_weapons)
7120 player[closest].weaponids[0]=weapons.numweapons;
7121 weapons.owner[weapons.numweapons]=closest;
7122 weapons.type[weapons.numweapons]=knife;
7123 weapons.damage[weapons.numweapons]=0;
7124 weapons.numweapons++;
7125 player[closest].num_weapons=1;
7126 if(weapons.type[player[closest].weaponids[0]]==sword){
7127 weapons.mass[player[closest].weaponids[0]]=1.5;
7128 weapons.tipmass[player[closest].weaponids[0]]=1;
7129 weapons.length[player[closest].weaponids[0]]=.8;
7131 if(weapons.type[player[closest].weaponids[0]]==knife){
7132 weapons.mass[player[closest].weaponids[0]]=1;
7133 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7134 weapons.length[player[closest].weaponids[0]]=.25;
7138 detailtogglekeydown=1;
7141 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7143 float closestdist=-1;
7146 for(i=1;i<numplayers;i++){
7147 distance=findDistancefast(&player[i].coords,&player[0].coords);
7148 if(closestdist==-1||distance<closestdist){
7149 closestdist=distance;
7154 player[closest].rotation+=multiplier*50;
7155 player[closest].targetrotation=player[closest].rotation;
7159 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7161 float closestdist=-1;
7164 for(i=1;i<numplayers;i++){
7165 distance=findDistancefast(&player[i].coords,&player[0].coords);
7166 if(closestdist==-1||distance<closestdist){
7167 closestdist=distance;
7171 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7174 player[closest].whichskin++;
7175 if(player[closest].whichskin>9)player[closest].whichskin=0;
7176 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7178 if(player[closest].creature==rabbittype){
7179 if(player[closest].whichskin==0){
7180 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7182 else if(player[closest].whichskin==1){
7183 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7185 else if(player[closest].whichskin==2){
7186 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7188 else if(player[closest].whichskin==3){
7189 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7191 else if(player[closest].whichskin==4){
7192 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7194 else if(player[closest].whichskin==5){
7195 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7197 else if(player[closest].whichskin==6){
7198 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7200 else if(player[closest].whichskin==7){
7201 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7203 else if(player[closest].whichskin==8){
7204 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7206 else if(player[closest].whichskin==9){
7207 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7210 if(player[closest].creature==wolftype){
7212 if(player[closest].whichskin==0){
7213 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7215 else if(player[closest].whichskin==1){
7216 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7218 else if(player[closest].whichskin==2){
7219 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7224 if(player[closest].numclothes){
7225 for(i=0;i<player[closest].numclothes;i++){
7226 tintr=player[closest].clothestintr[i];
7227 tintg=player[closest].clothestintg[i];
7228 tintb=player[closest].clothestintb[i];
7229 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7231 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7234 detailtogglekeydown=1;
7237 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7239 float closestdist=-1;
7242 for(i=1;i<numplayers;i++){
7243 distance=findDistancefast(&player[i].coords,&player[0].coords);
7244 if(closestdist==-1||distance<closestdist){
7245 closestdist=distance;
7250 if(player[closest].creature==wolftype){
7251 headprop=player[closest].proportionhead.x/1.1;
7252 bodyprop=player[closest].proportionbody.x/1.1;
7253 armprop=player[closest].proportionarms.x/1.1;
7254 legprop=player[closest].proportionlegs.x/1.1;
7257 if(player[closest].creature==rabbittype){
7258 headprop=player[closest].proportionhead.x/1.2;
7259 bodyprop=player[closest].proportionbody.x/1.05;
7260 armprop=player[closest].proportionarms.x/1.00;
7261 legprop=player[closest].proportionlegs.x/1.1;
7265 if(player[closest].creature==rabbittype){
7266 player[closest].skeleton.id=closest;
7267 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);
7268 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7269 player[closest].whichskin=0;
7270 player[closest].creature=wolftype;
7272 player[closest].proportionhead=1.1;
7273 player[closest].proportionbody=1.1;
7274 player[closest].proportionarms=1.1;
7275 player[closest].proportionlegs=1.1;
7276 player[closest].proportionlegs.y=1.1;
7277 player[closest].scale=.23*5*player[0].scale;
7279 player[closest].damagetolerance=300;
7283 player[closest].skeleton.id=closest;
7284 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);
7285 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7286 player[closest].whichskin=0;
7287 player[closest].creature=rabbittype;
7289 player[closest].proportionhead=1.2;
7290 player[closest].proportionbody=1.05;
7291 player[closest].proportionarms=1.00;
7292 player[closest].proportionlegs=1.1;
7293 player[closest].proportionlegs.y=1.05;
7294 player[closest].scale=.2*5*player[0].scale;
7296 player[closest].damagetolerance=200;
7299 if(player[closest].creature==wolftype){
7300 player[closest].proportionhead=1.1*headprop;
7301 player[closest].proportionbody=1.1*bodyprop;
7302 player[closest].proportionarms=1.1*armprop;
7303 player[closest].proportionlegs=1.1*legprop;
7306 if(player[closest].creature==rabbittype){
7307 player[closest].proportionhead=1.2*headprop;
7308 player[closest].proportionbody=1.05*bodyprop;
7309 player[closest].proportionarms=1.00*armprop;
7310 player[closest].proportionlegs=1.1*legprop;
7311 player[closest].proportionlegs.y=1.05*legprop;
7315 detailtogglekeydown=1;
7318 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7319 detailtogglekeydown=0;
7322 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7325 slomotogglekeydown=1;
7329 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7331 float closestdist=-1;
7333 XYZ flatfacing2,flatvelocity2;
7336 for(i=1;i<numplayers;i++){
7337 distance=findDistancefast(&player[i].coords,&player[0].coords);
7338 if(distance<144&&!player[i].headless)
7339 if(closestdist==-1||distance<closestdist){
7340 closestdist=distance;
7342 blah = player[i].coords;
7347 XYZ headspurtdirection;
7348 int i = player[closest].skeleton.jointlabels[head];
7349 for(k=0;k<player[closest].skeleton.num_joints; k++){
7350 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7351 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7352 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;
7353 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7354 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7355 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7356 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7357 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7358 Normalise(&headspurtdirection);
7359 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7360 flatvelocity2+=headspurtdirection*8;
7361 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7363 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7373 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7374 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7375 OPENAL_SetVolume(channels[splattersound], 256);
7376 OPENAL_SetPaused(channels[splattersound], false);
7378 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7379 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7380 OPENAL_SetVolume(channels[breaksound2], 100);
7381 OPENAL_SetPaused(channels[breaksound2], false);
7383 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7384 player[closest].RagDoll(0);
7385 player[closest].dead=2;
7386 player[closest].headless=1;
7387 player[closest].DoBloodBig(3,165);
7392 explodetogglekeydown=1;
7395 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7397 float closestdist=-1;
7399 XYZ flatfacing2,flatvelocity2;
7402 for(i=1;i<numplayers;i++){
7403 distance=findDistancefast(&player[i].coords,&player[0].coords);
7405 if(closestdist==-1||distance<closestdist){
7406 closestdist=distance;
7408 blah=player[i].coords;
7422 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7423 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7424 OPENAL_SetVolume(channels[splattersound], 256);
7425 OPENAL_SetPaused(channels[splattersound], false);
7427 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7428 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7429 OPENAL_SetVolume(channels[breaksound2], 600);
7430 OPENAL_SetPaused(channels[breaksound2], false);
7432 for(i=0;i<player[closest].skeleton.num_joints; i++){
7433 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7434 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7435 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;
7436 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7437 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7438 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7439 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7440 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7441 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7442 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7445 for(i=0;i<player[closest].skeleton.num_joints; i++){
7446 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7447 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7448 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;
7449 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7450 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7451 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7452 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7453 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7454 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7457 for(i=0;i<player[closest].skeleton.num_joints; i++){
7458 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7459 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7460 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;
7461 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7462 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7463 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7464 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7465 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7466 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7469 for(i=0;i<player[closest].skeleton.num_joints; i++){
7470 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7471 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7472 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;
7473 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7474 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7475 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7476 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7477 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7478 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7482 for(j=0;j<numplayers; j++){
7484 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7485 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7486 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7487 player[j].skeleton.longdead=0;
7488 player[j].RagDoll(0);
7489 for(i=0;i<player[j].skeleton.num_joints; i++){
7490 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7491 if(findDistancefast(&temppos,&player[closest].coords)<25){
7492 flatvelocity2=temppos-player[closest].coords;
7493 Normalise(&flatvelocity2);
7494 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7501 player[closest].DoDamage(10000);
7502 player[closest].RagDoll(0);
7503 player[closest].dead=2;
7504 player[closest].coords=20;
7505 player[closest].skeleton.free=2;
7511 explodetogglekeydown=1;
7514 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7515 explodetogglekeydown=0;
7519 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7521 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7522 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7523 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7524 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7525 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7526 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7527 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7529 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7530 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7531 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7532 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7533 for(j=0;j<player[0].num_weapons;j++){
7534 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7536 fwrite( &environment, 1, sizeof(int), tfile );
7538 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7539 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7540 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7541 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7542 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7544 fwrite( &numplayers, 1, sizeof(int), tfile );
7545 if(numplayers>1&&numplayers<maxplayers)
7546 for(i=1;i<numplayers;i++){
7547 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7548 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7549 for(j=0;j<player[i].num_weapons;j++){
7550 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7552 if(player[i].numwaypoints<30){
7553 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7554 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7555 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7556 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7559 player[i].numwaypoints=0;
7560 player[i].waypoint=0;
7561 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7562 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7563 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7569 slomotogglekeydown=1;
7572 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7573 slomotogglekeydown=0;
7577 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7578 player[0].onfire=1-player[0].onfire;
7579 if(player[0].onfire){
7580 player[0].CatchFire();
7582 if(!player[0].onfire){
7585 gLoc[0]=player[0].coords.x;
7586 gLoc[1]=player[0].coords.y;
7587 gLoc[2]=player[0].coords.z;
7591 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7592 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7593 OPENAL_SetVolume(channels[fireendsound], 256);
7594 OPENAL_SetPaused(channels[fireendsound], false);
7595 OPENAL_SetPaused(channels[stream_firesound], true);
7597 slomotogglekeydown=1;
7600 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7601 if(player[0].bleeding<=0)
7602 player[0].DoBlood(1,255);
7606 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7608 float closestdist=-1;
7611 for(i=1;i<numplayers;i++){
7612 distance=findDistancefast(&player[i].coords,&player[0].coords);
7613 if(closestdist==-1||distance<closestdist){
7614 closestdist=distance;
7618 if(closestdist>0&&closest>=0){
7619 //player[closest]=player[numplayers-1];
7620 //player[closest].skeleton=player[numplayers-1].skeleton;
7623 drawmodetogglekeydown=1;
7626 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7628 float closestdist=-1;
7631 for(i=1;i<max_objects;i++){
7632 distance=findDistancefast(&objects.position[i],&player[0].coords);
7633 if(closestdist==-1||distance<closestdist){
7634 closestdist=distance;
7638 if(closestdist>0&&closest>=0){
7639 objects.position[closest].y-=500;
7641 drawmodetogglekeydown=1;
7644 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7646 //if(drawmode>2)drawmode=0;
7647 if(objects.numobjects<max_objects-1){
7649 boxcoords.x=player[0].coords.x;
7650 boxcoords.z=player[0].coords.z;
7651 boxcoords.y=player[0].coords.y-3;
7652 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7653 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7654 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7655 float temprotat,temprotat2;
7656 temprotat=editorrotation;
7657 temprotat2=editorrotation2;
7658 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7659 if(temprotat2<0)temprotat2=Random()%360;
7661 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7662 if(editortype==treetrunktype)
7663 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7666 drawmodetogglekeydown=1;
7669 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7670 if(numplayers<maxplayers-1){
7671 player[numplayers].scale=.2*5*player[0].scale;
7672 player[numplayers].creature=rabbittype;
7673 player[numplayers].howactive=editoractive;
7674 player[numplayers].skeleton.id=numplayers;
7675 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);
7677 //texsize=512*512*3/texdetail/texdetail;
7678 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7679 //player[numplayers].skeleton.skinText.resize(texsize);
7681 k=abs(Random()%2)+1;
7683 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7684 player[numplayers].whichskin=0;
7687 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7688 player[numplayers].whichskin=1;
7691 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7692 player[numplayers].whichskin=2;
7695 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7696 player[numplayers].power=1;
7697 player[numplayers].speedmult=1;
7698 player[numplayers].currentanimation=bounceidleanim;
7699 player[numplayers].targetanimation=bounceidleanim;
7700 player[numplayers].currentframe=0;
7701 player[numplayers].targetframe=1;
7702 player[numplayers].target=0;
7703 player[numplayers].bled=0;
7704 player[numplayers].speed=1+(float)(Random()%100)/1000;
7706 player[numplayers].targetrotation=player[0].targetrotation;
7707 player[numplayers].rotation=player[0].rotation;
7709 player[numplayers].velocity=0;
7710 player[numplayers].coords=player[0].coords;
7711 player[numplayers].oldcoords=player[numplayers].coords;
7712 player[numplayers].realoldcoords=player[numplayers].coords;
7714 player[numplayers].id=numplayers;
7715 player[numplayers].skeleton.id=numplayers;
7716 player[numplayers].updatedelay=0;
7717 player[numplayers].normalsupdatedelay=0;
7719 player[numplayers].aitype=passivetype;
7720 player[numplayers].aitarget=0;
7722 if(player[0].creature==wolftype){
7723 headprop=player[0].proportionhead.x/1.1;
7724 bodyprop=player[0].proportionbody.x/1.1;
7725 armprop=player[0].proportionarms.x/1.1;
7726 legprop=player[0].proportionlegs.x/1.1;
7729 if(player[0].creature==rabbittype){
7730 headprop=player[0].proportionhead.x/1.2;
7731 bodyprop=player[0].proportionbody.x/1.05;
7732 armprop=player[0].proportionarms.x/1.00;
7733 legprop=player[0].proportionlegs.x/1.1;
7736 if(player[numplayers].creature==wolftype){
7737 player[numplayers].proportionhead=1.1*headprop;
7738 player[numplayers].proportionbody=1.1*bodyprop;
7739 player[numplayers].proportionarms=1.1*armprop;
7740 player[numplayers].proportionlegs=1.1*legprop;
7743 if(player[numplayers].creature==rabbittype){
7744 player[numplayers].proportionhead=1.2*headprop;
7745 player[numplayers].proportionbody=1.05*bodyprop;
7746 player[numplayers].proportionarms=1.00*armprop;
7747 player[numplayers].proportionlegs=1.1*legprop;
7748 player[numplayers].proportionlegs.y=1.05*legprop;
7751 player[numplayers].headless=0;
7752 player[numplayers].onfire=0;
7755 player[numplayers].proportionhead.z=0;
7756 player[numplayers].proportionbody.z=0;
7757 player[numplayers].proportionarms.z=0;
7758 player[numplayers].proportionlegs.z=0;
7761 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7763 player[numplayers].damagetolerance=200;
7765 player[numplayers].protectionhead=player[0].protectionhead;
7766 player[numplayers].protectionhigh=player[0].protectionhigh;
7767 player[numplayers].protectionlow=player[0].protectionlow;
7768 player[numplayers].armorhead=player[0].armorhead;
7769 player[numplayers].armorhigh=player[0].armorhigh;
7770 player[numplayers].armorlow=player[0].armorlow;
7771 player[numplayers].metalhead=player[0].metalhead;
7772 player[numplayers].metalhigh=player[0].metalhigh;
7773 player[numplayers].metallow=player[0].metallow;
7775 player[numplayers].immobile=player[0].immobile;
7777 player[numplayers].numclothes=player[0].numclothes;
7778 if(player[numplayers].numclothes)
7779 for(i=0;i<player[numplayers].numclothes;i++){
7780 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
7781 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
7782 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
7783 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
7784 tintr=player[numplayers].clothestintr[i];
7785 tintg=player[numplayers].clothestintg[i];
7786 tintb=player[numplayers].clothestintb[i];
7787 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7789 if(player[numplayers].numclothes){
7790 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
7793 player[numplayers].power=player[0].power;
7794 player[numplayers].speedmult=player[0].speedmult;
7796 player[numplayers].damage=0;
7797 player[numplayers].permanentdamage=0;
7798 player[numplayers].superpermanentdamage=0;
7799 player[numplayers].deathbleeding=0;
7800 player[numplayers].bleeding=0;
7801 player[numplayers].numwaypoints=0;
7802 player[numplayers].waypoint=0;
7803 player[numplayers].jumppath=0;
7804 player[numplayers].weaponstuck=-1;
7805 player[numplayers].weaponactive=-1;
7806 player[numplayers].num_weapons=0;
7807 player[numplayers].bloodloss=0;
7808 player[numplayers].dead=0;
7810 player[numplayers].loaded=1;
7814 drawmodetogglekeydown=1;
7817 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
7818 if(player[numplayers-1].numwaypoints<90){
7819 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
7820 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
7821 player[numplayers-1].numwaypoints++;
7823 drawmodetogglekeydown=1;
7826 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7827 if(numpathpoints<30){
7828 bool connected,alreadyconnected;
7831 for(i=0;i<numpathpoints;i++){
7832 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
7834 for(j=0;j<numpathpointconnect[pathpointselected];j++){
7835 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
7837 if(!alreadyconnected){
7838 numpathpointconnect[pathpointselected]++;
7840 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
7846 pathpoint[numpathpoints-1]=player[0].coords;
7847 numpathpointconnect[numpathpoints-1]=0;
7848 if(numpathpoints>1&&pathpointselected!=-1){
7849 numpathpointconnect[pathpointselected]++;
7850 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
7852 pathpointselected=numpathpoints-1;
7855 drawmodetogglekeydown=1;
7858 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
7859 pathpointselected++;
7860 if(pathpointselected>=numpathpoints)pathpointselected=-1;
7861 drawmodetogglekeydown=1;
7863 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7864 pathpointselected--;
7865 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
7866 drawmodetogglekeydown=1;
7868 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7869 if(pathpointselected!=-1){
7871 pathpoint[pathpointselected]=pathpoint[numpathpoints];
7872 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
7873 for(i=0;i<numpathpointconnect[pathpointselected];i++){
7874 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
7876 for(i=0;i<numpathpoints;i++){
7877 for(j=0;j<numpathpointconnect[i];j++){
7878 if(pathpointconnect[i][j]==pathpointselected){
7879 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
7880 numpathpointconnect[i]--;
7882 if(pathpointconnect[i][j]==numpathpoints){
7883 pathpointconnect[i][j]=pathpointselected;
7887 pathpointselected=numpathpoints-1;
7889 drawmodetogglekeydown=1;
7892 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7893 editorenabled=1-editorenabled;
7895 player[0].damagetolerance=100000;
7897 player[0].superpermanentdamage=0;
7898 player[0].bloodloss=0;
7899 player[0].deathbleeding=0;
7902 player[0].damagetolerance=200;
7904 player[0].permanentdamage=0;
7905 player[0].superpermanentdamage=0;
7906 player[0].bloodloss=0;
7907 player[0].deathbleeding=0;
7909 drawmodetogglekeydown=1;
7912 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7914 if(editortype==treeleavestype||editortype==10)editortype--;
7915 if(editortype<0)editortype=firetype;
7916 drawmodetogglekeydown=1;
7919 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7921 if(editortype==treeleavestype||editortype==10)editortype++;
7922 if(editortype>firetype)editortype=0;
7923 drawmodetogglekeydown=1;
7926 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7927 editorrotation-=multiplier*100;
7928 if(editorrotation<-.01)editorrotation=-.01;
7929 drawmodetogglekeydown=1;
7932 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7933 editorrotation+=multiplier*100;
7934 drawmodetogglekeydown=1;
7937 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7938 editorsize+=multiplier;
7939 drawmodetogglekeydown=1;
7942 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7943 editorsize-=multiplier;
7944 if(editorsize<.1)editorsize=.1;
7945 drawmodetogglekeydown=1;
7949 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7950 mapradius-=multiplier*10;
7953 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7954 mapradius+=multiplier*10;
7957 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7958 mapcenter.x+=multiplier*20;
7961 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7962 mapcenter.x-=multiplier*20;
7965 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7966 mapcenter.z+=multiplier*20;
7969 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7970 mapcenter.z-=multiplier*20;
7973 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7974 editorrotation2+=multiplier*100;
7977 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7978 editorrotation2-=multiplier*100;
7979 if(editorrotation2<-.01)editorrotation2=-.01;
7981 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7983 float closestdist=-1;
7985 for(i=0;i<objects.numobjects;i++){
7986 distance=findDistancefast(&objects.position[i],&player[0].coords);
7987 if(closestdist==-1||distance<closestdist){
7988 closestdist=distance;
7992 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
7993 drawmodetogglekeydown=1;
7997 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)){
7998 drawmodetogglekeydown=0;
8001 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8002 //if(!player[0].skeleton.free)player[0].damage+=500;
8003 player[0].RagDoll(0);
8004 //player[0].spurt=1;
8005 //player[0].DoDamage(1000);
8009 gLoc[0]=player[0].coords.x;
8010 gLoc[1]=player[0].coords.y;
8011 gLoc[2]=player[0].coords.z;
8012 vel[0]=player[0].velocity.x;
8013 vel[1]=player[0].velocity.y;
8014 vel[2]=player[0].velocity.z;
8015 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
8016 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8017 OPENAL_SetVolume(channels[whooshsound], 128);
8018 OPENAL_SetPaused(channels[whooshsound], false);
8019 //OPENAL_SetPaused(channels[whooshsound], true);
8021 texturesizetogglekeydown=1;
8024 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8027 float closestdist=-1;
8029 for(i=0;i<objects.numobjects;i++){
8030 if(objects.type[i]==treeleavestype){
8031 objects.scale[i]*=.9;
8034 texturesizetogglekeydown=1;
8037 static XYZ relative;
8038 static int randattack;
8040 static bool playerrealattackkeydown=0;
8042 if(!buttons[0])oldbutton=0;
8043 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8044 if(oldattackkey)player[0].attackkeydown=0;
8045 if(oldattackkey)playerrealattackkeydown=0;
8046 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8047 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);
8048 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8049 for(k=0;k<numplayers;k++){
8050 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8051 player[k].Reverse();
8055 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8057 for(k=0;k<numplayers;k++){
8058 if(indialogue!=-1)player[k].attackkeydown=0;
8059 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8060 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8061 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)){
8062 player[k].jumppower-=2;
8064 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)){
8065 for(i=0;i<numplayers;i++){
8067 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8068 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8069 player[k].targetanimation=dodgebackanim;
8071 player[k].targetframe=0;
8072 rotatetarget=player[i].coords-player[k].coords;
8073 Normalise(&rotatetarget);
8074 player[k].targetrotation=-asin(0-rotatetarget.x);
8075 player[k].targetrotation*=360/6.28;
8076 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8078 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8081 if(player[k].targetanimation!=dodgebackanim){
8082 if(k==0)numflipped++;
8083 player[k].targetanimation=backhandspringanim;
8085 player[k].targetframe=0;
8086 player[k].targetrotation=-rotation+180;
8087 if(player[k].leftkeydown)player[k].targetrotation-=45;
8088 if(player[k].rightkeydown)player[k].targetrotation+=45;
8089 player[k].rotation=player[k].targetrotation;
8090 player[k].jumppower-=2;
8093 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())){
8094 player[k].hasvictim=0;
8096 for(i=0;i<numplayers;i++){
8098 if(!player[k].hasvictim)
8099 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8100 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){
8101 player[k].victim=&player[i];
8102 player[k].hasvictim=1;
8103 if(player[k].aitype==playercontrolled){
8104 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;
8105 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;
8106 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;
8107 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;
8108 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;
8109 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;
8110 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;
8111 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;
8112 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;
8113 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;
8116 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8117 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8118 else randattack=abs(Random()%5);
8119 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8120 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8121 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8122 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8123 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8125 if(player[k].weaponactive!=-1){
8126 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;
8127 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;
8128 //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;
8129 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;
8130 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;
8131 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;
8132 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;
8133 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;
8137 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8139 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)){
8140 if(player[k].weaponactive==-1){
8141 player[i].targetanimation=sneakattackedanim;
8142 player[i].currentanimation=sneakattackedanim;
8143 player[k].currentanimation=sneakattackanim;
8144 player[k].targetanimation=sneakattackanim;
8145 player[k].oldcoords=player[k].coords;
8146 player[k].coords=player[i].coords;
8148 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8149 player[i].targetanimation=knifesneakattackedanim;
8150 player[i].currentanimation=knifesneakattackedanim;
8151 player[k].currentanimation=knifesneakattackanim;
8152 player[k].targetanimation=knifesneakattackanim;
8153 player[i].oldcoords=player[i].coords;
8154 player[i].coords=player[k].coords;
8156 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8157 player[i].targetanimation=swordsneakattackedanim;
8158 player[i].currentanimation=swordsneakattackedanim;
8159 player[k].currentanimation=swordsneakattackanim;
8160 player[k].targetanimation=swordsneakattackanim;
8161 player[i].oldcoords=player[i].coords;
8162 player[i].coords=player[k].coords;
8164 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8165 player[k].victim=&player[i];
8166 player[k].hasvictim=1;
8167 player[i].targettilt2=0;
8168 player[i].targetframe=1;
8169 player[i].currentframe=0;
8171 player[i].velocity=0;
8172 player[k].targettilt2=player[i].targettilt2;
8173 player[k].currentframe=player[i].currentframe;
8174 player[k].targetframe=player[i].targetframe;
8175 player[k].target=player[i].target;
8176 player[k].velocity=0;
8177 player[k].targetrotation=player[i].rotation;
8178 player[k].rotation=player[i].rotation;
8179 player[i].targetrotation=player[i].rotation;
8182 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8184 player[k].targetframe=0;
8186 //player[k].velocity=0;
8188 rotatetarget=player[i].coords-player[k].coords;
8189 Normalise(&rotatetarget);
8190 player[k].targetrotation=-asin(0-rotatetarget.x);
8191 player[k].targetrotation*=360/6.28;
8192 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8194 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8196 player[k].lastattack3=player[k].lastattack2;
8197 player[k].lastattack2=player[k].lastattack;
8198 player[k].lastattack=player[k].targetanimation;
8199 //player[k].targettilt2=0;
8203 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8204 rotatetarget=player[i].coords-player[k].coords;
8205 Normalise(&rotatetarget);
8206 player[k].targetrotation=-asin(0-rotatetarget.x);
8207 player[k].targetrotation*=360/6.28;
8208 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8209 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8211 player[k].victim=&player[i];
8212 player[k].hasvictim=1;
8213 player[i].targetanimation=knifefollowedanim;
8214 player[i].currentanimation=knifefollowedanim;
8215 player[i].targettilt2=0;
8216 player[i].targettilt2=player[k].targettilt2;
8217 player[i].targetframe=1;
8218 player[i].currentframe=0;
8220 player[i].velocity=0;
8221 player[k].currentanimation=knifefollowanim;
8222 player[k].targetanimation=knifefollowanim;
8223 player[k].targettilt2=player[i].targettilt2;
8224 player[k].currentframe=player[i].currentframe;
8225 player[k].targetframe=player[i].targetframe;
8226 player[k].target=player[i].target;
8227 player[k].velocity=0;
8228 player[k].oldcoords=player[k].coords;
8229 player[i].coords=player[k].coords;
8230 player[i].targetrotation=player[k].targetrotation;
8231 player[i].rotation=player[k].targetrotation;
8232 player[k].rotation=player[k].targetrotation;
8233 player[i].rotation=player[k].targetrotation;
8238 if(player[k].weaponactive!=-1){
8239 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8242 for(i=0;i<numplayers;i++){
8244 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8245 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8246 if(player[i].skeleton.free)
8247 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)))){
8248 player[k].victim=&player[i];
8249 player[k].hasvictim=1;
8250 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8251 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;
8252 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;
8253 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;
8255 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){
8256 player[k].targetanimation=killanim;
8257 for(j=0;j<terrain.numdecals;j++){
8258 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8259 terrain.DeleteDecal(j);
8262 for(l=0;l<objects.numobjects;l++){
8263 if(objects.model[l].type==decalstype)
8264 for(j=0;j<objects.model[l].numdecals;j++){
8265 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8266 objects.model[l].DeleteDecal(j);
8271 if(!player[i].dead||musictype!=2)
8272 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)){
8273 player[k].targetanimation=dropkickanim;
8274 for(j=0;j<terrain.numdecals;j++){
8275 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8276 terrain.DeleteDecal(j);
8279 for(l=0;l<objects.numobjects;l++){
8280 if(objects.model[l].type==decalstype)
8281 for(j=0;j<objects.model[l].numdecals;j++){
8282 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8283 objects.model[l].DeleteDecal(j);
8289 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)){
8291 player[k].targetframe=0;
8293 //player[k].velocity=0;
8295 rotatetarget=player[i].coords-player[k].coords;
8296 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8297 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;
8299 Normalise(&rotatetarget);
8300 player[k].targetrotation=-asin(0-rotatetarget.x);
8301 player[k].targetrotation*=360/6.28;
8302 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8304 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8305 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8308 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8309 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8311 player[k].lastattack3=player[k].lastattack2;
8312 player[k].lastattack2=player[k].lastattack;
8313 player[k].lastattack=player[k].targetanimation;
8315 if(player[k].targetanimation==swordgroundstabanim){
8316 player[k].targetrotation+=30;
8318 //player[k].targettilt2=0;
8324 if(!player[k].hasvictim){
8325 for(i=0;i<numplayers;i++){
8326 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8327 player[k].victim=&player[i];
8328 player[k].hasvictim=1;
8330 if(player[k].hasvictim&&!player[i].skeleton.free)
8331 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8332 player[k].victim=&player[i];
8336 if(player[k].aitype==playercontrolled)
8337 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)){
8339 player[k].targetanimation=rabbitkickanim;
8340 player[k].targetframe=0;
8343 if(animation[player[k].targetanimation].attack&&k==0){
8346 if(player[k].weaponactive!=-1){
8347 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8350 if(player[k].weaponactive!=-1){
8351 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8354 if(player[k].weaponactive!=-1){
8355 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8357 if(armedstaff)numstaffattack++;
8358 else if(armedsword)numswordattack++;
8359 else if(armedknife)numknifeattack++;
8360 else numunarmedattack++;
8367 static float collisionradius;
8369 for(k=0;k<numplayers;k++){
8370 for(i=k;i<numplayers;i++){
8373 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))
8374 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))
8375 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8376 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8377 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)
8378 if(player[i].coords.y>player[k].coords.y-3)
8379 if(player[i].coords.y<player[k].coords.y+3)
8380 if(player[i].coords.x>player[k].coords.x-3)
8381 if(player[i].coords.x<player[k].coords.x+3)
8382 if(player[i].coords.z>player[k].coords.z-3)
8383 if(player[i].coords.z<player[k].coords.z+3){
8384 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)){
8385 if(player[i].onfire||player[k].onfire){
8386 if(!player[i].onfire)player[i].CatchFire();
8387 if(!player[k].onfire)player[k].CatchFire();
8391 tempcoords1=player[i].coords;
8392 tempcoords2=player[k].coords;
8393 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8394 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8395 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8396 if(player[0].hasvictim)
8397 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8398 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8400 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)){
8401 player[k].coords.y=player[i].coords.y;
8402 player[i].velocity=player[k].velocity;
8403 player[i].skeleton.free=0;
8404 player[i].rotation=0;
8405 player[i].RagDoll(0);
8406 player[i].DoDamage(20);
8407 if(k==0)camerashake+=.3;
8408 player[i].skeleton.longdead=0;
8409 player[k].lastcollide=1;
8412 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)){
8413 player[i].coords.y=player[k].coords.y;
8414 player[k].velocity=player[i].velocity;
8415 player[k].skeleton.free=0;
8416 player[k].rotation=0;
8417 player[k].RagDoll(0);
8418 player[k].DoDamage(20);
8419 if(i==0)camerashake+=.3;
8420 player[k].skeleton.longdead=0;
8421 player[i].lastcollide=1;
8424 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)){
8425 rotatetarget=player[k].velocity-player[i].velocity;
8426 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))
8427 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))){
8429 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)){
8430 static float gLoc[3];
8431 static float vel[3];
8432 gLoc[0]=player[i].coords.x;
8433 gLoc[1]=player[i].coords.y;
8434 gLoc[2]=player[i].coords.z;
8435 vel[0]=player[i].velocity.x;
8436 vel[1]=player[i].velocity.y;
8437 vel[2]=player[i].velocity.z;
8438 if(tutoriallevel!=1){
8439 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8440 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8441 OPENAL_SetVolume(channels[heavyimpactsound], 256);
8442 OPENAL_SetPaused(channels[heavyimpactsound], false);
8444 //player[i].velocity=player[k].velocity;
8445 //player[k].velocity=player[i].velocity;
8447 player[i].RagDoll(0);
8448 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8453 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8454 player[k].RagDoll(0);
8455 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8460 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8462 //if(player[i].skeleton.oldfree){
8463 for(j=0;j<player[i].skeleton.num_joints;j++){
8464 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8467 //if(player[k].skeleton.oldfree){
8468 for(j=0;j<player[k].skeleton.num_joints;j++){
8469 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8475 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)){
8477 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8478 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)){
8479 rotatetarget=player[k].coords-player[i].coords;
8480 Normalise(&rotatetarget);
8481 player[k].coords=(player[k].coords+player[i].coords)/2;
8482 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);
8483 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8484 if(player[k].howactive==typeactive||hostile)
8485 if(player[k].isIdle()){
8486 if(player[k].howactive<typesleeping){
8487 player[k].targetanimation=player[k].getStop();
8488 player[k].targetframe=0;
8491 else if(player[k].howactive==typesleeping)
8493 player[k].targetanimation=getupfromfrontanim;
8494 player[k].targetframe=0;
8497 if(!editorenabled)player[k].howactive=typeactive;
8499 if(player[i].howactive==typeactive||hostile)
8500 if(player[i].isIdle()){
8501 if(player[i].howactive<typesleeping){
8502 player[i].targetanimation=player[i].getStop();
8503 player[i].targetframe=0;
8508 player[i].targetanimation=getupfromfrontanim;
8509 player[i].targetframe=0;
8512 if(!editorenabled)player[i].howactive=typeactive;
8516 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){
8517 player[i].velocity=player[k].velocity;
8518 player[k].velocity=player[k].velocity*-.5;
8519 //player[i].velocity.y-=10;
8520 player[k].velocity.y=player[i].velocity.y;
8521 player[i].DoDamage(20);
8522 player[i].RagDoll(0);
8523 player[k].lastcollide=1;
8530 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){
8531 player[k].velocity=player[i].velocity;
8532 player[i].velocity=player[i].velocity*-.3;
8533 //player[k].velocity.y-=10;
8534 player[i].velocity.y=player[k].velocity.y;
8535 player[k].DoDamage(20);
8536 player[k].RagDoll(0);
8537 player[i].lastcollide=1;
8548 player[i].CheckKick();
8549 player[k].CheckKick();
8555 for(k=0;k<numplayers;k++){
8556 for(i=k;i<numplayers;i++){
8558 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))){
8559 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)){
8560 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)){
8561 player[i].victim=&player[k];
8562 player[i].targetanimation=jumpreversedanim;
8563 player[i].currentanimation=jumpreversedanim;
8564 player[k].currentanimation=jumpreversalanim;
8565 player[k].targetanimation=jumpreversalanim;
8566 player[i].targettilt2=0;
8567 player[i].currentframe=0;
8568 player[i].targetframe=1;
8569 player[k].currentframe=0;
8570 player[k].targetframe=1;
8571 if(player[i].coords.y<player[k].coords.y+1){
8572 player[i].targetanimation=rabbitkickreversedanim;
8573 player[i].currentanimation=rabbitkickreversedanim;
8574 player[k].currentanimation=rabbitkickreversalanim;
8575 player[k].targetanimation=rabbitkickreversalanim;
8576 player[k].currentframe=1;
8577 player[k].targetframe=2;
8578 player[i].currentframe=1;
8579 player[i].targetframe=2;
8581 player[k].targettilt2=0;
8583 player[i].velocity=0;
8584 player[k].velocity=0;
8585 player[k].oldcoords=player[k].coords;
8586 player[i].coords=player[k].coords;
8587 player[k].targetrotation=player[i].targetrotation;
8588 player[k].rotation=player[i].targetrotation;
8589 player[k].victim=&player[i];
8590 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8592 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)){
8593 player[k].victim=&player[i];
8594 player[k].targetanimation=jumpreversedanim;
8595 player[k].currentanimation=jumpreversedanim;
8596 player[i].currentanimation=jumpreversalanim;
8597 player[i].targetanimation=jumpreversalanim;
8598 player[k].targettilt2=0;
8599 player[i].targettilt2=0;
8600 player[k].currentframe=0;
8601 player[k].targetframe=1;
8602 player[i].currentframe=0;
8603 player[i].targetframe=1;
8604 if(player[k].coords.y<player[i].coords.y+1){
8605 player[k].targetanimation=rabbitkickreversedanim;
8606 player[k].currentanimation=rabbitkickreversedanim;
8607 player[i].currentanimation=rabbitkickreversalanim;
8608 player[i].targetanimation=rabbitkickreversalanim;
8609 player[k].currentframe=1;
8610 player[k].targetframe=2;
8611 player[i].currentframe=1;
8612 player[i].targetframe=2;
8615 player[k].velocity=0;
8616 player[i].velocity=0;
8617 player[i].oldcoords=player[i].coords;
8618 player[k].coords=player[i].coords;
8619 player[i].targetrotation=player[k].targetrotation;
8620 player[i].rotation=player[k].targetrotation;
8621 player[i].victim=&player[k];
8622 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8629 for(k=0;k<numplayers;k++)
8630 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8639 static float checkdelay;
8640 checkdelay-=multiplier;
8642 static bool checkedcoll[maxplayers][maxplayers];
8643 static bool above[maxplayers];
8645 for(i=0;i<maxplayers;i++){
8646 for(j=0;j<maxplayers;j++){
8647 checkedcoll[i][j]=0;
8651 if(numplayers>1&&checkdelay<=0){
8653 for(k=0;k<numplayers;k++){
8654 if(player[k].skeleton.free!=2)above[k]=-1;
8656 for(i=k;i<numplayers;i++){
8659 if(!checkedcoll[i][k]){
8660 checkedcoll[i][k]=1;
8661 checkedcoll[k][i]=1;
8662 if(player[i].skeleton.free&&player[k].skeleton.free)
8663 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8664 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8665 if(player[i].coords.y>player[k].coords.y-3)
8666 if(player[i].coords.y<player[k].coords.y+3)
8667 if(player[i].coords.x>player[k].coords.x-3)
8668 if(player[i].coords.x<player[k].coords.x+3)
8669 if(player[i].coords.z>player[k].coords.z-3)
8670 if(player[i].coords.z<player[k].coords.z+3)
8671 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)){
8673 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8685 above[moving]=stuck;
8686 for(l=0;l<player[moving].skeleton.num_joints;l++){
8687 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8688 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8690 player[moving].skeleton.joints[l].position.y+=.003;
8691 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8705 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8706 texturesizetogglekeydown=0;
8709 for(k=0;k<numplayers;k++){
8710 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8711 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8712 player[k].DoDamage(1000);
8717 static bool respawnkeydown;
8718 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8719 targetlevel=whichlevel;
8723 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8724 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8729 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8731 if(targetlevel>numchallengelevels-1)targetlevel=0;
8734 slomotogglekeydown=1;
8738 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8740 OPENAL_SetPaused(channels[whooshsound], true);
8742 for(k=0;k<numplayers;k++){
8745 player[k].permanentdamage=0;
8746 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8747 player[k].aitype=passivetype;
8749 player[0].aitype=playercontrolled;
8753 static bool movekey;
8754 static bool connected;
8755 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8756 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8757 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8758 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8759 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8760 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8762 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
8764 for(int i=0;i<numplayers;i++){
8765 if(!player[i].skeleton.free){
8766 oldtargetrotation=player[i].targetrotation;
8767 if(i==0&&indialogue==-1){
8768 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){
8769 if(!cameramode)player[0].targetrotation=-rotation+180;
8770 if(cameramode)player[0].targetrotation=0;
8776 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8777 if(cameramode){facing=flatfacing;}
8779 facing=DoRotation(facing,-rotation2,0,0);
8780 facing=DoRotation(facing,0,0-rotation,0);
8783 player[0].lookrotation=-rotation;
8785 player[i].targetheadrotation=rotation;
8786 player[i].targetheadrotation2=rotation2;
8788 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
8789 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){
8790 player[i].targetrotation=-player[i].lookrotation+180;
8796 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8798 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
8799 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
8801 player[i].targetheadrotation=player[i].lookrotation;
8802 player[i].targetheadrotation2=player[i].lookrotation2;
8805 rotatetarget=participantfacing[whichdialogue][indialogue][i];
8806 Normalise(&rotatetarget);
8807 player[i].targetheadrotation=-asin(0-rotatetarget.x);
8808 player[i].targetheadrotation*=360/6.28;
8809 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
8811 player[i].targetheadrotation*=-1;
8812 player[i].targetheadrotation+=180;
8813 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
8821 player[i].avoidsomething=0;
8823 for(j=0;j<objects.numobjects;j++){
8824 if(objects.onfire[j]){
8825 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
8827 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
8828 player[i].collided=0;
8829 player[i].avoidcollided=1;
8830 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8831 player[i].avoidwhere=objects.position[j];
8837 //Add avoidwhere to players
8839 for(j=0;j<numplayers;j++){
8840 if(player[j].onfire){
8841 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
8843 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
8844 player[i].collided=0;
8845 player[i].avoidcollided=1;
8846 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8847 player[i].avoidwhere=objects.position[j];
8853 if(player[i].collided>.8)player[i].avoidcollided=0;
8854 if(player[i].aitype!=playercontrolled&&indialogue==-1){
8855 player[i].jumpclimb=0;
8857 if(editorenabled)player[i].stunned=1;
8860 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
8861 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;
8863 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
8864 player[i].forwardkeydown=0;
8865 player[i].leftkeydown=0;
8866 player[i].backkeydown=0;
8867 player[i].rightkeydown=0;
8868 player[i].crouchkeydown=0;
8869 player[i].attackkeydown=0;
8870 player[i].jumpkeydown=0;
8871 player[i].throwkeydown=0;
8874 if(player[i].aitype==pathfindtype){
8875 if(player[i].finalpathfindpoint==-1){
8876 float closestdistance;
8882 for(j=0;j<numpathpoints;j++){
8883 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
8884 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
8886 player[i].finaltarget=pathpoint[j];
8889 player[i].finalpathfindpoint=closest;
8890 for(j=0;j<numpathpoints;j++){
8891 if(numpathpointconnect[j])
8892 for(k=0;k<numpathpointconnect[j];k++){
8893 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8894 if(tempdist*tempdist<closestdistance){
8895 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8896 closestdistance=tempdist*tempdist;
8898 player[i].finaltarget=colpoint;
8903 player[i].finalpathfindpoint=closest;
8906 if(player[i].targetpathfindpoint==-1){
8907 float closestdistance;
8913 if(player[i].lastpathfindpoint==-1){
8914 for(j=0;j<numpathpoints;j++){
8915 if(j!=player[i].lastpathfindpoint)
8916 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
8917 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
8921 player[i].targetpathfindpoint=closest;
8922 for(j=0;j<numpathpoints;j++){
8923 if(j!=player[i].lastpathfindpoint)
8924 if(numpathpointconnect[j])
8925 for(k=0;k<numpathpointconnect[j];k++){
8926 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8927 if(tempdist*tempdist<closestdistance){
8928 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8929 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
8930 closestdistance=tempdist*tempdist;
8937 player[i].targetpathfindpoint=closest;
8941 for(j=0;j<numpathpoints;j++){
8942 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
8945 if(numpathpointconnect[j])
8946 for(k=0;k<numpathpointconnect[j];k++){
8947 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
8950 if(numpathpointconnect[player[i].lastpathfindpoint])
8951 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
8952 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
8955 tempdist=findPathDist(j,player[i].finalpathfindpoint);
8956 if(closest==-1||tempdist<closestdistance){
8957 closestdistance=tempdist;
8963 player[i].targetpathfindpoint=closest;
8966 player[i].losupdatedelay-=multiplier;
8968 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
8969 Normalise(&rotatetarget);
8970 player[i].targetrotation=-asin(0-rotatetarget.x);
8971 player[i].targetrotation*=360/6.28;
8972 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8973 player[i].lookrotation=player[i].targetrotation;
8974 //player[i].aiupdatedelay=.05;
8976 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
8977 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8978 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8979 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8980 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
8981 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8982 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8983 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8984 player[i].targetpathfindpoint=-1;
8986 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){
8987 player[i].aitype=passivetype;
8990 player[i].forwardkeydown=1;
8991 player[i].leftkeydown=0;
8992 player[i].backkeydown=0;
8993 player[i].rightkeydown=0;
8994 player[i].crouchkeydown=0;
8995 player[i].attackkeydown=0;
8996 player[i].throwkeydown=0;
8998 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9000 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9001 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9003 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9004 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))
9005 player[i].aitype=attacktypecutoff;
9006 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9007 player[i].aitype=attacktypecutoff;
9009 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9010 player[i].losupdatedelay=.2;
9011 for(j=0;j<numplayers;j++){
9012 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9013 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9014 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9015 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9016 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9017 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)){
9018 player[i].aitype=searchtype;
9019 player[i].lastchecktime=12;
9020 player[i].lastseen=player[j].coords;
9021 player[i].lastseentime=12;
9027 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9028 if(player[i].creature!=wolftype){
9029 player[i].stunned=.6;
9030 player[i].surprised=.6;
9035 if(player[i].aitype!=passivetype&&leveltime>.5){
9036 player[i].howactive=typeactive;
9039 if(player[i].aitype==passivetype){
9040 player[i].aiupdatedelay-=multiplier;
9041 player[i].losupdatedelay-=multiplier;
9042 player[i].lastseentime+=multiplier;
9043 player[i].pausetime-=multiplier;
9044 if(player[i].lastseentime>1)player[i].lastseentime=1;
9046 if(player[i].aiupdatedelay<0){
9047 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9048 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9049 Normalise(&rotatetarget);
9050 player[i].targetrotation=-asin(0-rotatetarget.x);
9051 player[i].targetrotation*=360/6.28;
9052 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9053 player[i].lookrotation=player[i].targetrotation;
9054 player[i].aiupdatedelay=.05;
9056 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9057 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9058 player[i].waypoint++;
9059 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9064 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9065 else player[i].forwardkeydown=0;
9066 player[i].leftkeydown=0;
9067 player[i].backkeydown=0;
9068 player[i].rightkeydown=0;
9069 player[i].crouchkeydown=0;
9070 player[i].attackkeydown=0;
9071 player[i].throwkeydown=0;
9073 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9074 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9076 XYZ leftpos,rightpos;
9077 float leftdist,rightdist;
9078 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9079 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9080 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9081 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9082 if(leftdist<rightdist)player[i].targetrotation+=90;
9083 else player[i].targetrotation-=90;
9087 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9088 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9092 if(player[i].howactive<typesleeping)
9093 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9094 for(j=0;j<numenvsounds;j++){
9095 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9096 player[i].aitype=attacktypecutoff;
9100 if(player[i].howactive==typesleeping)
9101 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9102 for(j=0;j<numenvsounds;j++){
9103 if(envsoundvol[j]>14)
9104 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9105 player[i].aitype=attacktypecutoff;
9109 if(player[i].aitype!=passivetype){
9110 if(player[i].howactive==typesleeping){
9111 player[i].targetanimation=getupfromfrontanim;
9112 player[i].targetframe=0;
9116 player[i].howactive=typeactive;
9120 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9121 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9122 player[i].aitype=attacktypecutoff;
9123 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9124 player[i].aitype=attacktypecutoff;
9126 if(player[i].creature==wolftype){
9128 float smelldistance;
9130 for(j=0;j<numplayers;j++){
9131 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9132 if(j==0&&player[j].num_weapons>0){
9133 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9134 if(player[j].num_weapons==2)
9135 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9140 windsmell=windvector;
9141 Normalise(&windsmell);
9142 windsmell=windsmell*2+player[j].coords;
9143 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9144 player[i].aitype=attacktypecutoff;
9149 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9150 player[i].losupdatedelay=.2;
9151 for(j=0;j<numplayers;j++){
9152 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9153 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9154 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9155 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9156 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)){
9157 player[i].lastseentime-=.2;
9158 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9159 else player[i].lastseentime-=.6;
9161 if(player[i].lastseentime<=0){
9162 player[i].aitype=searchtype;
9163 player[i].lastchecktime=12;
9164 player[i].lastseen=player[j].coords;
9165 player[i].lastseentime=12;
9171 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9172 if(player[i].creature!=wolftype){
9173 player[i].stunned=.6;
9174 player[i].surprised=.6;
9176 if(player[i].creature==wolftype){
9177 player[i].stunned=.47;
9178 player[i].surprised=.47;
9184 if(player[i].aitype==searchtype){
9185 player[i].aiupdatedelay-=multiplier;
9186 player[i].losupdatedelay-=multiplier;
9187 if(!player[i].pause)player[i].lastseentime-=multiplier;
9188 player[i].lastchecktime-=multiplier;
9190 if(player[i].isRun()&&!player[i].onground){
9191 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9192 test2=player[i].coords+player[i].facing;
9194 test=player[i].coords+player[i].facing;
9196 j=checkcollide(test2,test,player[i].laststanding);
9197 if(j==-1)j=checkcollide(test2,test);
9199 player[i].velocity=0;
9200 player[i].targetanimation=player[i].getStop();
9201 player[i].targetframe=0;
9203 player[i].targetrotation+=180;
9204 player[i].stunned=.5;
9205 //player[i].aitype=passivetype;
9206 player[i].aitype=pathfindtype;
9207 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9208 player[i].finalpathfindpoint=-1;
9209 player[i].targetpathfindpoint=-1;
9210 player[i].lastpathfindpoint=-1;
9211 player[i].lastpathfindpoint2=-1;
9212 player[i].lastpathfindpoint3=-1;
9213 player[i].lastpathfindpoint4=-1;
9215 else player[i].laststanding=j;
9218 if(player[i].aiupdatedelay<0){
9219 rotatetarget=player[i].lastseen-player[i].coords;
9220 Normalise(&rotatetarget);
9221 player[i].targetrotation=-asin(0-rotatetarget.x);
9222 player[i].targetrotation*=360/6.28;
9223 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9224 player[i].lookrotation=player[i].targetrotation;
9225 player[i].aiupdatedelay=.05;
9226 player[i].forwardkeydown=1;
9228 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9229 player[i].forwardkeydown=0;
9230 player[i].aiupdatedelay=1;
9231 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9232 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9233 player[i].lastchecktime=3;
9236 player[i].leftkeydown=0;
9237 player[i].backkeydown=0;
9238 player[i].rightkeydown=0;
9239 player[i].crouchkeydown=0;
9240 player[i].attackkeydown=0;
9241 player[i].throwkeydown=0;
9243 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9244 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9246 XYZ leftpos,rightpos;
9247 float leftdist,rightdist;
9248 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9249 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9250 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9251 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9252 if(leftdist<rightdist)player[i].targetrotation+=90;
9253 else player[i].targetrotation-=90;
9257 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9258 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9260 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9261 for(j=0;j<numenvsounds;j++){
9262 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9263 player[i].aitype=attacktypecutoff;
9267 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9268 player[i].losupdatedelay=.2;
9269 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9270 {player[i].aitype=attacktypecutoff;
9271 player[i].lastseentime=1;}
9272 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9273 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9274 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9275 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)){
9276 player[i].aitype=attacktypecutoff;
9277 player[i].lastseentime=1;
9280 if(player[i].lastseentime<0){
9281 //player[i].aitype=passivetype;
9283 player[i].aitype=pathfindtype;
9284 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9285 player[i].finalpathfindpoint=-1;
9286 player[i].targetpathfindpoint=-1;
9287 player[i].lastpathfindpoint=-1;
9288 player[i].lastpathfindpoint2=-1;
9289 player[i].lastpathfindpoint3=-1;
9290 player[i].lastpathfindpoint4=-1;
9294 if(player[i].aitype!=gethelptype){
9295 player[i].runninghowlong=0;
9298 if(player[i].aitype==gethelptype){
9299 player[i].runninghowlong+=multiplier;
9300 player[i].aiupdatedelay-=multiplier;
9302 if(player[i].aiupdatedelay<0||player[i].ally==0){
9303 player[i].aiupdatedelay=.2;
9311 if(!player[i].ally){
9312 for(j=0;j<numplayers;j++){
9313 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9314 distance=findDistancefast(&player[i].coords,&player[j].coords);
9315 if(closestdist==-1||distance<closestdist){
9316 closestdist=distance;
9322 if(closest!=-1)player[i].ally=closest;
9323 else player[i].ally=0;
9324 player[i].lastseen=player[0].coords;
9325 player[i].lastseentime=12;
9329 player[i].lastchecktime=12;
9330 //player[i].lastseentime-=.5;
9332 facing=player[i].coords;
9333 flatfacing=player[player[i].ally].coords;
9334 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9335 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9336 if(-1!=checkcollide(facing,flatfacing))
9337 player[i].lastseentime-=.1;
9339 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9340 player[i].aitype=searchtype;
9341 player[i].lastseentime=12;
9344 if(player[i].ally>0){
9345 rotatetarget=player[player[i].ally].coords-player[i].coords;
9346 Normalise(&rotatetarget);
9347 player[i].targetrotation=-asin(0-rotatetarget.x);
9348 player[i].targetrotation*=360/6.28;
9349 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9350 player[i].lookrotation=player[i].targetrotation;
9351 player[i].aiupdatedelay=.05;
9352 player[i].forwardkeydown=1;
9354 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9355 player[i].aitype=searchtype;
9356 player[i].lastseentime=12;
9357 player[player[i].ally].aitype=searchtype;
9358 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9359 player[player[i].ally].lastseen=player[i].lastseen;
9360 player[player[i].ally].lastseentime=player[i].lastseentime;
9361 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9365 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9366 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9368 XYZ leftpos,rightpos;
9369 float leftdist,rightdist;
9370 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9371 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9372 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9373 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9374 if(leftdist<rightdist)player[i].targetrotation+=90;
9375 else player[i].targetrotation-=90;
9380 player[i].leftkeydown=0;
9381 player[i].backkeydown=0;
9382 player[i].rightkeydown=0;
9383 player[i].crouchkeydown=0;
9384 player[i].attackkeydown=0;
9386 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9387 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9390 if(player[i].aitype==getweapontype){
9391 player[i].aiupdatedelay-=multiplier;
9392 player[i].lastchecktime-=multiplier;
9394 if(player[i].aiupdatedelay<0){
9395 player[i].aiupdatedelay=.2;
9403 if(player[i].ally<0){
9404 for(j=0;j<weapons.numweapons;j++){
9405 if(weapons.owner[j]==-1){
9406 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9407 if(closestdist==-1||distance<closestdist){
9408 closestdist=distance;
9414 if(closest!=-1)player[i].ally=closest;
9415 else player[i].ally=-1;
9418 player[i].lastseentime=12;
9420 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9421 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9422 player[i].aitype=attacktypecutoff;
9423 player[i].lastseentime=1;
9426 if(player[i].ally>=0){
9427 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9428 player[i].aitype=attacktypecutoff;
9429 player[i].lastseentime=1;
9431 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9432 Normalise(&rotatetarget);
9433 player[i].targetrotation=-asin(0-rotatetarget.x);
9434 player[i].targetrotation*=360/6.28;
9435 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9436 player[i].lookrotation=player[i].targetrotation;
9437 player[i].aiupdatedelay=.05;
9438 player[i].forwardkeydown=1;
9441 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9442 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9444 XYZ leftpos,rightpos;
9445 float leftdist,rightdist;
9446 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9447 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9448 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9449 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9450 if(leftdist<rightdist)player[i].targetrotation+=90;
9451 else player[i].targetrotation-=90;
9454 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9455 if(abs(Random()%6)){
9456 player[i].crouchkeydown=1;
9457 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9458 if(player[i].isRun()){
9459 player[i].targetframe=0;
9461 player[i].targetanimation=sneakanim;
9464 else player[i].forwardkeydown=0;
9466 else player[i].crouchkeydown=0;
9468 else player[i].crouchkeydown=0;*/
9471 player[i].leftkeydown=0;
9472 player[i].backkeydown=0;
9473 player[i].rightkeydown=0;
9474 player[i].attackkeydown=0;
9475 player[i].throwkeydown=1;
9476 player[i].crouchkeydown=0;
9477 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9478 player[i].drawkeydown=0;
9480 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9481 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9484 if(player[i].aitype==attacktypecutoff){
9485 player[i].aiupdatedelay-=multiplier;
9486 if(player[i].damage<player[i].damagetolerance*2/3)
9487 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)){
9488 player[i].attackkeydown=0;
9489 if(player[i].isIdle())player[i].crouchkeydown=1;
9490 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9491 if(weapons.type[player[0].weaponids[0]]==knife){
9492 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9493 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9494 else player[i].targetanimation=rollanim;
9496 player[i].targetframe=0;
9497 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9498 player[i].wentforweapon=0;
9500 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9501 player[i].targetanimation=flipanim;
9503 player[i].targetframe=0;
9507 player[i].forwardkeydown=0;
9508 player[i].aiupdatedelay=.02;
9510 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9511 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9512 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9514 if(player[i].wentforweapon<3)
9515 for(j=0;j<weapons.numweapons;j++){
9516 if(player[i].creature!=wolftype)
9517 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){
9518 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9519 player[i].wentforweapon++;
9520 player[i].lastchecktime=6;
9521 player[i].aitype=getweapontype;
9526 if(player[i].damage<player[i].damagetolerance/2)
9527 if(animation[player[i].targetanimation].height!=highheight)
9528 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)))){
9529 player[i].crouchkeydown=1;
9531 if(player[i].isRun()&&!player[i].onground){
9532 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9533 test2=player[i].coords+player[i].facing;
9535 test=player[i].coords+player[i].facing;
9537 j=checkcollide(test2,test,player[i].laststanding);
9538 if(j==-1)j=checkcollide(test2,test);
9540 player[i].velocity=0;
9541 player[i].targetanimation=player[i].getStop();
9542 player[i].targetframe=0;
9544 player[i].targetrotation+=180;
9545 player[i].stunned=.5;
9546 //player[i].aitype=passivetype;
9547 player[i].aitype=pathfindtype;
9548 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9549 player[i].finalpathfindpoint=-1;
9550 player[i].targetpathfindpoint=-1;
9551 player[i].lastpathfindpoint=-1;
9552 player[i].lastpathfindpoint2=-1;
9553 player[i].lastpathfindpoint3=-1;
9554 player[i].lastpathfindpoint4=-1;
9556 else player[i].laststanding=j;
9559 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9560 player[i].aitype=pathfindtype;
9561 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9562 player[i].finalpathfindpoint=-1;
9563 player[i].targetpathfindpoint=-1;
9564 player[i].lastpathfindpoint=-1;
9565 player[i].lastpathfindpoint2=-1;
9566 player[i].lastpathfindpoint3=-1;
9567 player[i].lastpathfindpoint4=-1;
9569 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){
9570 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9571 else player[i].drawkeydown=0;
9572 player[i].rabbitkickenabled=Random()%2;
9573 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9574 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9575 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;
9576 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9577 Normalise(&rotatetarget);
9578 player[i].targetrotation=-asin(0-rotatetarget.x);
9579 player[i].targetrotation*=360/6.28;
9580 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9581 player[i].lookrotation=player[i].targetrotation;
9582 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9584 oldkey=player[i].forwardkeydown;
9585 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9586 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;
9587 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9588 else player[i].forwardkeydown=0;
9590 player[i].forwardkeydown=0;
9591 if(Random()%10==0)player[i].forwardkeydown=1;
9592 if(Random()%100==0){
9593 player[i].aitype=pathfindtype;
9594 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9595 player[i].finalpathfindpoint=-1;
9596 player[i].targetpathfindpoint=-1;
9597 player[i].lastpathfindpoint=-1;
9598 player[i].lastpathfindpoint2=-1;
9599 player[i].lastpathfindpoint3=-1;
9600 player[i].lastpathfindpoint4=-1;
9603 player[i].leftkeydown=0;
9604 player[i].backkeydown=0;
9605 player[i].rightkeydown=0;
9606 player[i].crouchkeydown=0;
9607 player[i].throwkeydown=0;
9609 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9610 /*for(j=0;j<numplayers;j++){
9611 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9612 player[i].crouchkeydown=1;
9615 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9616 else player[i].attackkeydown=0;
9617 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9618 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9619 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9620 player[i].attackkeydown=0;
9621 if(player[i].isIdle())player[i].crouchkeydown=1;
9622 player[i].forwardkeydown=0;
9623 player[i].aiupdatedelay=.02;
9626 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9628 for(j=0;j<numplayers;j++){
9629 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)){
9630 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))))){
9631 if(target>=0)target=-1;
9636 if(target>=0)player[target].Reverse();
9639 if(player[i].collided<1)player[i].jumpkeydown=0;
9640 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;
9641 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9642 player[0].jumpkeydown=0;
9643 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9644 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9645 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9647 if(tutoriallevel==1){
9648 if(!canattack)player[i].attackkeydown=0;
9652 facing=player[i].coords;
9653 flatfacing=player[0].coords;
9654 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9655 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9656 if(player[i].occluded>=2)
9657 if(-1!=checkcollide(facing,flatfacing)){
9658 if(!player[i].pause)player[i].lastseentime-=.2;
9659 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9660 player[i].aitype=searchtype;
9661 player[i].lastchecktime=12;
9662 player[i].lastseen=player[0].coords;
9663 player[i].lastseentime=12;
9666 else player[i].lastseentime=1;
9669 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9670 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9671 test=player[0].coords;
9673 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9676 // NOTE: Ask about logic of this call : NOTE
9677 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9678 player[i].stunned>0 ||
9679 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9681 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9682 player[i].targetrotation=player[i].rotation;
9683 player[i].forwardkeydown=0;
9684 player[i].leftkeydown=0;
9685 player[i].backkeydown=0;
9686 player[i].rightkeydown=0;
9687 player[i].jumpkeydown=0;
9688 player[i].attackkeydown=0;
9689 player[i].crouchkeydown=0;
9690 player[i].throwkeydown=0;
9697 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9700 if(player[i].aitype==attacktypecutoff){
9701 rotatetarget=player[0].coords-player[i].coords;
9702 Normalise(&rotatetarget);
9703 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9704 player[i].targetheadrotation*=360/6.28;
9705 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9707 player[i].targetheadrotation*=-1;
9708 player[i].targetheadrotation+=180;
9709 //player[i].targetheadrotation2=0;
9710 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9712 else if(player[i].howactive>=typesleeping){
9713 player[i].targetheadrotation=player[i].targetrotation;
9714 player[i].targetheadrotation2=0;
9717 if(player[i].interestdelay<=0){
9718 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9719 player[i].headtarget=player[i].coords;
9720 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9721 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9722 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9723 player[i].headtarget+=player[i].facing*1.5;
9725 rotatetarget=player[i].headtarget-player[i].coords;
9726 Normalise(&rotatetarget);
9727 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9728 player[i].targetheadrotation*=360/6.28;
9729 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9731 player[i].targetheadrotation*=-1;
9732 player[i].targetheadrotation+=180;
9733 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9735 //if(whichlevel==2)player[i].jumpkeydown=0;
9737 if(animation[player[i].targetanimation].attack==reversed){
9738 //player[i].targetrotation=player[i].rotation;
9739 player[i].forwardkeydown=0;
9740 player[i].leftkeydown=0;
9741 player[i].backkeydown=0;
9742 player[i].rightkeydown=0;
9743 player[i].jumpkeydown=0;
9744 player[i].attackkeydown=0;
9745 //player[i].crouchkeydown=0;
9746 player[i].throwkeydown=0;
9750 player[i].forwardkeydown=0;
9751 player[i].leftkeydown=0;
9752 player[i].backkeydown=0;
9753 player[i].rightkeydown=0;
9754 player[i].jumpkeydown=0;
9755 player[i].crouchkeydown=0;
9756 player[i].drawkeydown=0;
9757 player[i].throwkeydown=0;
9760 if(player[i].collided<-.3)player[i].collided=-.3;
9761 if(player[i].collided>1)player[i].collided=1;
9762 player[i].collided-=multiplier*4;
9763 player[i].whichdirectiondelay-=multiplier;
9764 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
9765 player[i].avoidcollided=-.3;
9766 player[i].whichdirection=abs(Random()%2);
9767 player[i].whichdirectiondelay=.4;
9769 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
9770 player[i].avoidcollided-=multiplier/4;
9771 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
9772 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
9773 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;
9775 if(!player[i].throwkeydown){
9776 player[i].throwtogglekeydown=0;
9778 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
9779 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)){
9780 for(j=0;j<weapons.numweapons;j++){
9781 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)
9782 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
9783 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
9784 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
9785 player[i].throwtogglekeydown=1;
9786 player[i].targetanimation=crouchremoveknifeanim;
9788 player[i].targetframe=0;
9789 rotatetarget=weapons.position[j]-player[i].coords;
9790 Normalise(&rotatetarget);
9791 player[i].targetrotation=-asin(0-rotatetarget.x);
9792 player[i].targetrotation*=360/6.28;
9793 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9794 player[i].hasvictim=0;
9796 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9797 player[i].throwtogglekeydown=1;
9798 player[i].hasvictim=0;
9800 //for(i=0;i<weapons.numweapons;i++){
9801 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))
9802 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
9803 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
9806 gLoc[0]=player[i].coords.x;
9807 gLoc[1]=player[i].coords.y;
9808 gLoc[2]=player[i].coords.z;
9809 vel[0]=player[i].velocity.x;
9810 vel[1]=player[i].velocity.y;
9811 vel[2]=player[i].velocity.z;
9812 if(weapons.type[j]!=staff){
9813 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9814 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9815 OPENAL_SetVolume(channels[knifedrawsound], 128);
9816 OPENAL_SetPaused(channels[knifedrawsound], false);
9819 player[i].weaponactive=0;
9820 weapons.owner[j]=player[i].id;
9821 if(player[i].num_weapons>0){
9822 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9824 player[i].num_weapons++;
9825 player[i].weaponids[0]=j;
9831 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){
9832 if(!player[i].isFlip()){
9833 player[i].throwtogglekeydown=1;
9834 player[i].targetanimation=removeknifeanim;
9836 player[i].targetframe=0;
9837 rotatetarget=weapons.position[j]-player[i].coords;
9838 Normalise(&rotatetarget);
9839 player[i].targetrotation=-asin(0-rotatetarget.x);
9840 player[i].targetrotation*=360/6.28;
9841 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9843 if(player[i].isFlip()){
9844 player[i].throwtogglekeydown=1;
9845 player[i].hasvictim=0;
9847 for(k=0;k<weapons.numweapons;k++){
9848 if(player[i].weaponactive==-1)
9849 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))
9850 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
9853 gLoc[0]=player[i].coords.x;
9854 gLoc[1]=player[i].coords.y;
9855 gLoc[2]=player[i].coords.z;
9856 vel[0]=player[i].velocity.x;
9857 vel[1]=player[i].velocity.y;
9858 vel[2]=player[i].velocity.z;
9859 if(weapons.type[k]!=staff){
9860 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9861 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9862 OPENAL_SetVolume(channels[knifedrawsound], 128);
9863 OPENAL_SetPaused(channels[knifedrawsound], false);
9866 player[i].weaponactive=0;
9867 weapons.owner[k]=player[i].id;
9868 if(player[i].num_weapons>0){
9869 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9871 player[i].num_weapons++;
9872 player[i].weaponids[0]=k;
9879 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9881 for(j=0;j<numplayers;j++){
9882 if(player[i].weaponactive==-1)
9884 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)){
9885 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
9886 player[i].throwtogglekeydown=1;
9887 player[i].victim=&player[j];
9888 player[i].hasvictim=1;
9889 player[i].targetanimation=crouchremoveknifeanim;
9891 player[i].targetframe=0;
9892 rotatetarget=player[j].coords-player[i].coords;
9893 Normalise(&rotatetarget);
9894 player[i].targetrotation=-asin(0-rotatetarget.x);
9895 player[i].targetrotation*=360/6.28;
9896 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9898 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9899 player[i].throwtogglekeydown=1;
9900 player[i].victim=&player[j];
9901 player[i].hasvictim=1;
9902 int k = player[j].weaponids[0];
9903 if(player[i].hasvictim){
9906 gLoc[0]=player[i].coords.x;
9907 gLoc[1]=player[i].coords.y;
9908 gLoc[2]=player[i].coords.z;
9909 vel[0]=player[i].velocity.x;
9910 vel[1]=player[i].velocity.y;
9911 vel[2]=player[i].velocity.z;
9914 if(player[i].victim->weaponstuck!=-1){
9915 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9920 if(weapons.type[k]!=staff){
9921 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9922 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9923 OPENAL_SetVolume(channels[knifedrawsound], 128);
9924 OPENAL_SetPaused(channels[knifedrawsound], false);
9928 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
9929 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
9930 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
9931 OPENAL_SetPaused(channels[fleshstabremovesound], false);
9934 player[i].weaponactive=0;
9935 if(weapons.owner[k]!=-1){
9936 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
9937 else player[i].victim->num_weapons=1;
9939 player[i].victim->skeleton.longdead=0;
9940 player[i].victim->skeleton.free=1;
9941 player[i].victim->skeleton.broken=0;
9943 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
9944 player[i].victim->skeleton.joints[l].velchange=0;
9945 player[i].victim->skeleton.joints[l].locked=0;
9951 Normalise(&relative);
9952 XYZ footvel,footpoint;
9954 footpoint=weapons.position[k];
9955 if(player[i].victim->weaponstuck!=-1){
9956 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9957 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
9958 weapons.bloody[k]=2;
9959 weapons.blooddrip[k]=5;
9960 player[i].victim->weaponstuck=-1;
9961 player[i].victim->bloodloss+=2000;
9962 player[i].victim->DoDamage(2000);
9965 if(player[i].victim->num_weapons>0){
9966 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
9967 if(player[i].victim->weaponids[0]==k)
9968 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
9971 player[i].victim->weaponactive=-1;
9973 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
9974 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
9975 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
9976 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
9979 if(player[i].num_weapons>0){
9980 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9982 player[i].num_weapons++;
9983 player[i].weaponids[0]=k;
9990 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9991 if(weapons.type[player[i].weaponids[0]]==knife){
9992 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
9994 for(j=0;j<numplayers;j++){
9996 if(tutoriallevel!=1||tutorialstage==49)
9998 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)){
9999 if(!player[i].isFlip()){
10000 player[i].throwtogglekeydown=1;
10001 player[i].victim=&player[j];
10002 player[i].targetanimation=knifethrowanim;
10003 player[i].target=0;
10004 player[i].targetframe=0;
10005 rotatetarget=player[j].coords-player[i].coords;
10006 Normalise(&rotatetarget);
10007 player[i].targetrotation=-asin(0-rotatetarget.x);
10008 player[i].targetrotation*=360/6.28;
10009 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10011 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10013 if(player[i].isFlip()){
10014 if(player[i].weaponactive!=-1){
10015 player[i].throwtogglekeydown=1;
10016 player[i].victim=&player[j];
10018 weapons.owner[player[i].weaponids[0]]=-1;
10019 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);
10022 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10024 weapons.velocity[player[i].weaponids[0]]=aim*50;
10025 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10026 weapons.missed[player[i].weaponids[0]]=0;
10027 weapons.freetime[player[i].weaponids[0]]=0;
10028 weapons.firstfree[player[i].weaponids[0]]=1;
10029 weapons.physics[player[i].weaponids[0]]=0;
10030 player[i].num_weapons--;
10031 if(player[i].num_weapons){
10032 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10034 player[i].weaponactive=-1;
10041 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10042 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10044 player[i].throwtogglekeydown=1;
10045 weapons.owner[player[i].weaponids[0]]=-1;
10046 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10047 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10048 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10049 weapons.missed[player[i].weaponids[0]]=1;
10050 weapons.freetime[player[i].weaponids[0]]=0;
10051 weapons.firstfree[player[i].weaponids[0]]=1;
10052 weapons.physics[player[i].weaponids[0]]=1;
10053 player[i].num_weapons--;
10054 if(player[i].num_weapons){
10055 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10056 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10059 player[i].weaponactive=-1;
10060 for(j=0;j<numplayers;j++){
10061 player[j].wentforweapon=0;
10068 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10069 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)){
10070 //Setenvironment(1-environment);
10073 if(player[i].weaponactive!=-1){
10074 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10076 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10077 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10078 player[i].targetanimation=drawrightanim;
10079 player[i].targetframe=0;
10080 player[i].target=0;
10081 player[i].drawtogglekeydown=1;
10083 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){
10084 player[i].targetanimation=drawleftanim;
10085 player[i].targetframe=0;
10086 player[i].target=0;
10087 player[i].drawtogglekeydown=1;
10089 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10090 player[i].targetanimation=crouchdrawrightanim;
10091 player[i].targetframe=0;
10092 player[i].target=0;
10093 player[i].drawtogglekeydown=1;
10097 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){
10098 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10099 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10100 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10101 player[i].targetframe=0;
10102 player[i].target=0;
10103 player[i].hasvictim=0;
10104 //player[i].attacktogglekeydown=1;
10108 if(!player[i].drawkeydown){
10109 player[i].drawtogglekeydown=0;
10114 absflatfacing.z=-1;
10116 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10118 else absflatfacing=flatfacing;
10120 if(indialogue!=-1){
10121 player[i].forwardkeydown=0;
10122 player[i].leftkeydown=0;
10123 player[i].backkeydown=0;
10124 player[i].rightkeydown=0;
10125 player[i].jumpkeydown=0;
10126 player[i].crouchkeydown=0;
10127 player[i].drawkeydown=0;
10128 player[i].throwkeydown=0;
10132 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10133 if(!player[i].forwardkeydown){
10134 player[i].forwardstogglekeydown=0;
10136 if(player[i].crouchkeydown){
10140 player[i].superruntoggle=1;
10142 for(j=0;j<numplayers;j++){
10143 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10144 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10145 player[i].superruntoggle=0;
10152 for(j=0;j<numplayers;j++){
10153 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10154 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))){
10155 if(target>=0)target=-1;
10160 if(target>=0)player[target].Reverse();
10161 player[i].lowreversaldelay=.5;
10163 if(player[i].isIdle()){
10164 player[i].targetanimation=player[i].getCrouch();
10165 player[i].target=0;
10166 player[i].targetframe=0;
10167 player[i].transspeed=10;
10169 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10170 player[i].targetanimation=rollanim;
10171 player[i].target=0;
10172 player[i].targetframe=0;
10173 player[i].transspeed=20;
10176 if(!player[i].crouchkeydown){
10178 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10180 if(player[i].isCrouch()){
10182 for(j=0;j<numplayers;j++){
10183 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10184 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10185 if(target>=0)target=-1;
10190 if(target>=0)player[target].Reverse();
10191 player[i].highreversaldelay=.5;
10193 if(player[i].isCrouch()){
10194 if(!player[i].wasCrouch()){
10195 player[i].currentanimation=player[i].getCrouch();
10196 player[i].currentframe=0;
10198 player[i].target=0;
10199 player[i].targetanimation=player[i].getIdle();
10200 player[i].targetframe=0;
10201 player[i].transspeed=10;
10204 if(player[i].targetanimation==sneakanim){
10205 player[i].targetanimation=player[i].getIdle();
10206 player[i].target=0;
10207 player[i].targetframe=0;
10208 player[i].transspeed=10;
10211 if(player[i].forwardkeydown){
10212 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)){
10213 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10214 else player[i].targetanimation=player[i].getRun();
10215 player[i].target=0;
10216 player[i].targetframe=0;
10218 if(player[i].isCrouch()){
10219 player[i].targetanimation=sneakanim;
10220 if(player[i].wasCrouch())player[i].target=0;
10221 player[i].targetframe=0;
10223 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10224 player[i].targetanimation=climbanim;
10225 player[i].target=0;
10226 player[i].targetframe=1;
10227 player[i].jumpclimb=1;
10229 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10230 player[i].velocity+=absflatfacing*5*multiplier;
10232 player[i].forwardstogglekeydown=1;
10235 if (player[i].rightkeydown){
10236 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)){
10237 player[i].targetanimation=player[i].getRun();
10238 player[i].target=0;
10239 player[i].targetframe=0;
10241 if(player[i].isCrouch()){
10242 player[i].targetanimation=sneakanim;
10243 if(player[i].wasCrouch()) player[i].target=0;
10244 player[i].targetframe=0;
10246 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10247 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10249 player[i].targetrotation-=90;
10250 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10251 if(player[i].backkeydown)player[i].targetrotation-=45;
10254 if ( player[i].leftkeydown){
10255 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)){
10256 player[i].targetanimation=player[i].getRun();
10257 player[i].target=0;
10258 player[i].targetframe=0;
10260 if(player[i].isCrouch()){
10261 player[i].targetanimation=sneakanim;
10262 if(player[i].wasCrouch())player[i].target=0;
10263 player[i].targetframe=0;
10265 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10266 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10268 player[i].targetrotation+=90;
10269 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10270 if(player[i].backkeydown)player[i].targetrotation+=45;
10273 if(player[i].backkeydown){
10274 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)){
10275 player[i].targetanimation=player[i].getRun();
10276 player[i].target=0;
10277 player[i].targetframe=0;
10279 if(player[i].isCrouch()){
10280 player[i].targetanimation=sneakanim;
10281 if(player[i].wasCrouch())player[i].target=0;
10282 player[i].targetframe=0;
10284 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10285 player[i].velocity-=absflatfacing*5*multiplier;
10287 if(player[i].targetanimation==hanganim){
10288 player[i].currentanimation=jumpdownanim;
10289 player[i].targetanimation=jumpdownanim;
10290 player[i].target=0;
10291 player[i].currentframe=0;
10292 player[i].targetframe=1;
10293 player[i].velocity=0;
10294 player[i].velocity.y+=gravity;
10295 player[i].coords.y-=1.4;
10296 player[i].grabdelay=1;
10298 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10299 player[i].targetrotation+=180;
10302 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10303 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)){
10304 player[i].jumpstart=0;
10305 player[i].targetanimation=jumpupanim;
10306 player[i].target=0;
10307 player[i].targetframe=0;
10308 player[i].rotation=player[i].targetrotation;
10309 player[i].transspeed=20;
10310 player[i].FootLand(0,1);
10311 player[i].FootLand(1,1);
10315 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10317 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10318 if(!movekey)player[i].velocity=0;
10323 for(j=0;j<numplayers;j++){
10324 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10325 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10326 if(target>=0)target=-1;
10331 if(target>=0)player[i].velocity.y=1;
10332 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10333 player[i].velocity.y=7;
10334 player[i].crouchtogglekeydown=1;
10336 else player[i].velocity.y=5;
10338 if(mousejump&&i==0&&debugmode){
10339 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10340 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10343 player[i].coords.y+=.2;
10344 player[i].jumppower-=1;
10346 static float gLoc[3];
10347 static float vel[3];
10348 gLoc[0]=player[i].coords.x;
10349 gLoc[1]=player[i].coords.y;
10350 gLoc[2]=player[i].coords.z;
10351 vel[0]=player[i].velocity.x;
10352 vel[1]=player[i].velocity.y;
10353 vel[2]=player[i].velocity.z;
10356 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10357 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10358 OPENAL_SetVolume(channels[whooshsound], 128);
10359 OPENAL_SetPaused(channels[whooshsound], false);
10362 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10363 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10364 OPENAL_SetVolume(channels[jumpsound], 128);
10365 OPENAL_SetPaused(channels[jumpsound], false);
10367 if((player[i].isIdle())&&player[i].jumppower>1){
10368 player[i].targetanimation=player[i].getLanding();
10369 player[i].landhard=0;
10370 player[i].target=0;
10371 player[i].targetframe=2;
10372 player[i].jumpstart=1;
10373 player[i].tempdeltav=deltav;
10375 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10376 if(player[i].jumppower>multiplier*6){
10377 player[i].velocity.y+=multiplier*6;
10378 player[i].jumppower-=multiplier*6;
10380 if(player[i].jumppower<=multiplier*6){
10381 player[i].velocity.y+=player[i].jumppower;
10382 player[i].jumppower=0;
10385 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10389 if(player[i].isRun()||player[i].targetanimation==walkanim){
10390 player[i].targetanimation=player[i].getStop();
10391 player[i].target=0;
10392 player[i].targetframe=0;
10394 if(player[i].targetanimation==sneakanim){
10395 player[i].targetanimation=player[i].getCrouch();
10396 if(player[i].currentanimation==sneakanim)player[i].target=0;
10397 player[i].targetframe=0;
10400 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10401 player[i].targetanimation=player[i].getStop();
10402 player[i].target=0;
10403 player[i].targetframe=0;
10405 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10406 player[i].targetanimation=player[i].getStop();
10407 player[i].target=0;
10408 player[i].targetframe=0;
10412 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10416 for(k=0;k<numplayers;k++){
10417 if(abs(player[k].rotation-player[k].targetrotation)>180){
10418 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10419 else player[k].rotation+=360;
10422 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10423 player[k].targetanimation=player[k].getStop();
10424 player[k].targetframe=0;
10425 player[k].target=0;
10428 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10429 player[k].targettilt=0;
10431 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10432 player[k].targettilt=0;
10433 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10434 player[k].jumppower+=multiplier*7;
10435 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10436 //*(1-(player[k].damage/player[k].damagetolerance))
10437 if(player[k].jumppower>5)player[k].jumppower=5;
10440 if(player[k].isRun()){
10441 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10444 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10445 else if(player[k].tilt>player[k].targettilt){
10446 player[k].tilt-=multiplier*150;
10448 else if(player[k].tilt<player[k].targettilt){
10449 player[k].tilt+=multiplier*150;
10452 player[k].grabdelay-=multiplier;
10455 for(k=0;k<numplayers;k++){
10456 player[k].DoAnimations();
10457 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10458 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10463 player[0].righthandmorphstart=0;
10464 player[0].righthandmorphend=1;
10465 player[0].lefthandmorphstart=0;
10466 player[0].lefthandmorphend=1;
10467 player[0].headmorphstart=0;
10468 player[0].headmorphend=2;*/
10471 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10472 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10473 player[0].righthandmorphend=1;
10474 player[0].targetrighthandmorphness=1;
10476 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10477 player[0].lefthandmorphend=0;
10478 player[0].targetlefthandmorphness=1;
10480 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10481 player[0].headmorphend=2;
10482 player[0].targetheadmorphness=1;
10484 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10485 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10486 player[0].righthandmorphend=0;
10487 player[0].targetrighthandmorphness=1;
10489 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10490 player[0].lefthandmorphend=1;
10491 player[0].targetlefthandmorphness=1;
10493 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10494 player[0].headmorphend=0;
10495 player[0].targetheadmorphness=1;
10498 if(numenvsounds!=0)
10499 for(j=numenvsounds-1;j>=0;j--){
10500 envsoundlife[j]-=multiplier;
10501 if(envsoundlife[j]<0){
10503 envsoundlife[j]=envsoundlife[numenvsounds];
10504 envsound[j]=envsound[numenvsounds];
10507 if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
10508 if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
10510 if(tutoriallevel==1){
10527 if(tutorialstage>=51)
10528 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10529 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10530 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
10532 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10533 OPENAL_SetPaused(channels[stream_music3], false);
10534 OPENAL_SetVolume(channels[stream_music3], 256);
10539 float gLoc[3]={0,0,0};
10540 float vel[3]={0,0,0};
10541 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10542 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10543 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10544 OPENAL_SetVolume(channels[fireendsound], 256);
10545 OPENAL_SetPaused(channels[fireendsound], false);
10546 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10554 if(tutorialstage<51)
10555 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10558 gLoc[0]=player[0].coords.x;
10559 gLoc[1]=player[0].coords.y;
10560 gLoc[2]=player[0].coords.z;
10564 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10565 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10566 OPENAL_SetVolume(channels[fireendsound], 256);
10567 OPENAL_SetPaused(channels[fireendsound], false);
10569 player[0].coords=(oldtemp+oldtemp2)/2;
10577 if(tutorialstage>=14&&tutorialstage<50)
10578 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10581 gLoc[0]=player[1].coords.x;
10582 gLoc[1]=player[1].coords.y;
10583 gLoc[2]=player[1].coords.z;
10587 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10588 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10589 OPENAL_SetVolume(channels[fireendsound], 256);
10590 OPENAL_SetPaused(channels[fireendsound], false);
10592 for(int i=0;i<player[1].skeleton.num_joints;i++){
10594 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10595 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10596 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;
10597 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10598 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10602 player[1].coords=(oldtemp+oldtemp2)/2;
10603 for(int i=0;i<player[1].skeleton.num_joints;i++){
10604 player[1].skeleton.joints[i].velocity=0;
10606 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10607 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10608 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;
10609 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10610 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10618 static float gLoc[3];
10622 static float vel[3];
10623 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10624 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10625 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10627 //Set orientation with forward and up vectors
10628 static XYZ upvector;
10632 upvector=DoRotation(upvector,-rotation2+90,0,0);
10633 upvector=DoRotation(upvector,0,0-rotation,0);
10638 facing=DoRotation(facing,-rotation2,0,0);
10639 facing=DoRotation(facing,0,0-rotation,0);
10642 static float ori[6];
10643 ori[0] = -facing.x;
10645 ori[2] = -facing.z;
10646 ori[3] = -upvector.x;
10647 ori[4] = upvector.y;
10648 ori[5] = -upvector.z;
10650 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10657 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10659 freezetogglekeydown=1;
10663 void Game::TickOnce(){
10666 if(directing||indialogue==-1){
10667 rotation+=deltah*.7;
10668 if(!invertmouse)rotation2+=deltav*.7;
10669 if(invertmouse)rotation2-=deltav*.7;
10670 if(rotation2>90)rotation2=90;
10671 if(rotation2<-70)rotation2=-70;
10673 if(mainmenu)rotation+=multiplier*5;
10678 void Game::TickOnceAfter(){
10679 static XYZ colviewer;
10680 static XYZ coltarget;
10683 static float brotate;
10686 static float changedelay;
10687 static bool alldead;
10688 static float unseendelay;
10689 static float cameraspeed;
10693 if(environment==snowyenvironment)music1=stream_music1snow;
10694 if(environment==grassyenvironment)music1=stream_music1grass;
10695 if(environment==desertenvironment)music1=stream_music1desert;
10700 for(i=0;i<numplayers;i++){
10701 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)){
10702 musictype=stream_music2;
10706 if(player[0].dead)musictype=stream_music3;
10709 if(musictype==stream_music2){
10713 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10714 unseendelay-=multiplier;
10716 musictype=stream_music2;
10722 musictype=stream_music3;
10723 musicvolume[2]=512;
10730 if(musictype!=oldmusictype&&musictype==stream_music2){
10731 static float gLoc[3];
10732 static float vel[3];
10733 gLoc[0]=cameraloc.x;
10734 gLoc[1]=cameraloc.y;
10735 gLoc[2]=cameraloc.z;
10739 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
10740 OPENAL_SetVolume(channels[alarmsound], 512);
10741 OPENAL_SetPaused(channels[alarmsound], false);
10745 musicselected=musictype;
10747 if(musicselected==music1)musicvolume[0]+=multiplier*450;
10748 else musicvolume[0]-=multiplier*450;
10749 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
10750 else musicvolume[1]-=multiplier*450;
10751 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
10752 else musicvolume[2]-=multiplier*450;
10754 if(musicselected==music1)musicvolume[0]+=multiplier*100;
10755 else musicvolume[0]-=multiplier*450;
10756 if(musicselected==music2)musicvolume[1]+=multiplier*150;
10757 else if(player[0].dead)musicvolume[1]-=multiplier*450;
10758 else musicvolume[1]-=multiplier*100;
10759 if(musicselected==music3)musicvolume[2]+=multiplier*450;
10760 else musicvolume[2]-=multiplier*450;*/
10763 if(musicvolume[i]<0)musicvolume[i]=0;
10764 if(musicvolume[i]>512)musicvolume[i]=512;
10767 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
10770 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
10771 PlayStreamEx( music1, strm[music1], NULL, true);
10772 OPENAL_SetPaused(channels[music1], false);
10774 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
10775 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
10776 OPENAL_SetPaused(channels[stream_music2], false);
10778 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
10779 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10780 OPENAL_SetPaused(channels[stream_music3], false);
10785 OPENAL_SetPaused(channels[music1], true);
10786 OPENAL_SetPaused(channels[stream_music2], true);
10787 OPENAL_SetPaused(channels[stream_music3], true);
10790 oldmusicvolume[i]=0;
10796 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
10797 OPENAL_SetPaused(channels[music1], true);
10799 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
10800 OPENAL_SetPaused(channels[stream_music2], true);
10802 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
10803 OPENAL_SetPaused(channels[stream_music3], true);
10806 if(musicvolume[0]!=oldmusicvolume[0]){
10807 OPENAL_SetVolume(channels[music1], musicvolume[0]);
10809 if(musicvolume[1]!=oldmusicvolume[1]){
10810 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
10812 if(musicvolume[2]!=oldmusicvolume[2]){
10813 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
10817 oldmusicvolume[i]=musicvolume[i];
10823 for(i=0;i<numhotspots;i++){
10824 if(hotspottype[i]>10&&hotspottype[i]<20){
10825 if(player[hotspottype[i]-10].dead==0){
10828 else if(killhotspot==2)
10832 if(killhotspot==2)killhotspot=0;
10837 for(i=0;i<numhotspots;i++){
10838 if(hotspottype[i]==-1){
10839 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
10846 for(i=1;i<numplayers;i++){
10847 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
10849 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
10851 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
10852 if(player[0].dead&&changedelay<=0){
10854 targetlevel=whichlevel;
10858 for(i=1;i<numplayers;i++){
10859 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
10863 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
10865 targetlevel=whichlevel+1;
10866 if(targetlevel>numchallengelevels-1)targetlevel=0;
10868 if(winhotspot||windialogue){
10870 targetlevel=whichlevel+1;
10871 if(targetlevel>numchallengelevels-1)targetlevel=0;
10877 targetlevel=whichlevel+1;
10878 if(targetlevel>numchallengelevels-1)targetlevel=0;
10881 if(changedelay>0&&!player[0].dead&&!won){
10882 //high scores, awards, win
10885 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10886 accountcampaignchoicesmade[accountactive]++;
10887 accountcampaignscore[accountactive]+=bonustotal;
10889 accountcampaigntime[accountactive]+=leveltime;
10890 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
10892 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10898 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
10899 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
10901 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10917 if(!editorenabled&&gameon&&!mainmenu){
10918 if(changedelay!=-999)changedelay-=multiplier/7;
10919 if(player[0].dead)targetlevel=whichlevel;
10920 if(loading==2&&!campaign){
10928 float gLoc[3]={0,0,0};
10929 float vel[3]={0,0,0};
10930 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10931 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10932 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10933 OPENAL_SetVolume(channels[firestartsound], 256);
10934 OPENAL_SetPaused(channels[firestartsound], false);
10935 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10937 if(!player[0].dead&&targetlevel!=whichlevel){
10938 startbonustotal=bonustotal;
10940 if(!player[0].dead)Loadlevel(targetlevel);
10941 if(player[0].dead)Loadlevel(whichlevel);
10943 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10944 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10945 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10946 OPENAL_SetVolume(channels[fireendsound], 256);
10947 OPENAL_SetPaused(channels[fireendsound], false);
10948 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10952 if(loading==2&&targetlevel==whichlevel){
10960 float gLoc[3]={0,0,0};
10961 float vel[3]={0,0,0};
10962 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10963 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10964 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10965 OPENAL_SetVolume(channels[firestartsound], 256);
10966 OPENAL_SetPaused(channels[firestartsound], false);
10967 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10969 for(i=0;i<255;i++){
10983 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
10984 Loadlevel(mapname);
10986 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10987 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10988 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10989 OPENAL_SetVolume(channels[fireendsound], 256);
10990 OPENAL_SetPaused(channels[fireendsound], false);
10991 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10995 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
10996 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
10998 if(whichlevel!=-2&&!loading&&!player[0].dead){
11002 if(player[0].dead)loading=1;
11008 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11009 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11013 else if(mainmenu==0&&winfreeze){
11014 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11016 else stealthloading=0;
11018 if(!stealthloading){
11019 float gLoc[3]={0,0,0};
11020 float vel[3]={0,0,0};
11021 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11022 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11023 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11024 OPENAL_SetVolume(channels[firestartsound], 256);
11025 OPENAL_SetPaused(channels[firestartsound], false);
11026 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11037 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11038 //campaignnumlevels=0;
11039 //accountcampaignchoicesmade[accountactive]=0;
11040 ipstream.ignore(256,':');
11041 ipstream >> campaignnumlevels;
11042 for(i=0;i<campaignnumlevels;i++){
11043 ipstream.ignore(256,':');
11044 ipstream.ignore(256,':');
11045 ipstream.ignore(256,' ');
11046 ipstream >> campaignmapname[i];
11047 ipstream.ignore(256,':');
11048 ipstream >> campaigndescription[i];
11049 for(j=0;j<256;j++){
11050 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11052 ipstream.ignore(256,':');
11053 ipstream >> campaignchoosenext[i];
11054 ipstream.ignore(256,':');
11055 ipstream >> campaignnumnext[i];
11056 if(campaignnumnext[i])
11057 for(j=0;j<campaignnumnext[i];j++){
11058 ipstream.ignore(256,':');
11059 ipstream >> campaignnextlevel[i][j];
11060 campaignnextlevel[i][j]-=1;
11062 ipstream.ignore(256,':');
11063 ipstream >> campaignlocationx[i];
11064 ipstream.ignore(256,':');
11065 ipstream >> campaignlocationy[i];
11069 for(i=0;i<campaignnumlevels;i++){
11071 levelhighlight[i]=0;
11075 for(i=0;i<campaignnumlevels;i++){
11077 levelhighlight[i]=0;
11082 if(accountcampaignchoicesmade[accountactive])
11083 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11084 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11085 levelvisible[levelorder[i+1]]=1;
11087 int whichlevelstart;
11088 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11089 if(whichlevelstart<0){
11090 campaignchoicenum=1;
11091 campaignchoicewhich[0]=0;
11095 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11096 if(campaignchoicenum)
11097 for(i=0;i<campaignchoicenum;i++){
11098 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11099 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11100 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11107 //if(firstload)TickOnceAfter();
11108 if(!firstload)LoadStuff();
11110 for(i=0;i<255;i++){
11125 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11126 //accountcampaignchoicesmade[accountactive]++;
11129 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11133 Loadlevel(mapname);
11137 OPENAL_SetPaused(channels[stream_music3], true);
11142 if(loading==3)loading=0;
11146 oldmusictype=musictype;
11152 facing=DoRotation(facing,-rotation2,0,0);
11153 facing=DoRotation(facing,0,0-rotation,0);
11154 viewerfacing=facing;
11158 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;
11159 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;
11161 if(player[0].skeleton.free){
11162 for(i=0;i<player[0].skeleton.num_joints;i++){
11163 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11164 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11168 if(player[0].skeleton.free!=2&&!autocam){
11170 if(findLengthfast(&player[0].velocity)>400){
11171 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11173 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11174 coltarget=target-cameraloc;
11175 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11177 Normalise(&coltarget);
11178 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11179 else cameraloc=cameraloc+coltarget*multiplier*8;
11181 if(editorenabled)cameraloc=target;
11182 cameradist+=multiplier*5;
11183 if(cameradist>2.3)cameradist=2.3;
11184 viewer=cameraloc-facing*cameradist;
11186 coltarget=cameraloc;
11187 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11188 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11189 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11190 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11192 coltarget=cameraloc;
11193 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11195 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11196 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11197 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11199 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11203 cameradist=findDistance(&viewer,&target);
11204 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11205 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11207 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11208 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11211 if(player[0].skeleton.free!=2&&autocam){
11213 if(findLengthfast(&player[0].velocity)>400){
11214 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11216 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11217 cameradist+=multiplier*5;
11218 if(cameradist>3.3)cameradist=3.3;
11219 coltarget=target-cameraloc;
11220 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11221 else if(findLengthfast(&coltarget)>1)
11223 Normalise(&coltarget);
11224 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11225 else cameraloc=cameraloc+coltarget*multiplier*8;
11227 if(editorenabled)cameraloc=target;
11230 coltarget=cameraloc;
11231 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11232 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11233 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11234 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11236 coltarget=cameraloc;
11237 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11239 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11240 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11241 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11243 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11247 cameradist=findDistance(&viewer,&target);
11248 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11249 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11251 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11252 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11255 if(camerashake>.8)camerashake=.8;
11256 //if(woozy>10)woozy=10;
11257 //woozy+=multiplier;
11259 if(player[0].dead)camerashake=0;
11260 if(player[0].dead)woozy=0;
11261 camerashake-=multiplier*2;
11262 blackout-=multiplier*2;
11263 //if(player[0].isCrouch())woozy-=multiplier*8;
11264 if(camerashake<0)camerashake=0;
11265 if(blackout<0)blackout=0;
11266 //if(woozy<0)woozy=0;
11268 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11269 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11270 viewer.z+=(float)(Random()%100)*.0005*camerashake;