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);
886 // Change the map filename into something that is os specific
887 char *FixedFN = ConvertFileName(name);
891 tfile=fopen( FixedFN, "rb" );
894 OPENAL_SetPaused(channels[stream_firesound], true);
905 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
911 dialoguegonethrough[i]=0;
920 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
922 if(difficulty!=2)minimap=1;
959 bonustotal=startbonustotal;
965 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
966 OPENAL_SetVolume(channels[consolesuccesssound], 256);
967 OPENAL_SetPaused(channels[consolesuccesssound], false);
975 sprites.numsprites=0;
976 for(i=0;i<objects.numobjects;i++)
978 objects.model[i].numdecals=0;
981 j=objects.numobjects;
984 objects.DeleteObject(0);
985 if(visibleloading){loadscreencolor=4; LoadingScreen();}
988 for(i=0;i<subdivision;i++)
990 for(j=0;j<subdivision;j++)
992 terrain.patchobjectnum[i][j]=0;
995 if(visibleloading){loadscreencolor=4; LoadingScreen();}
998 weapons.numweapons=0;
1000 funpackf(tfile, "Bi", &mapvers);
1001 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1003 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1004 else maptype=mapkilleveryone;
1005 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1007 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1013 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1021 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1024 skyboxlightr=skyboxr;
1025 skyboxlightg=skyboxg;
1026 skyboxlightb=skyboxb;
1028 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);
1029 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1030 player[0].originalcoords=player[0].coords;
1031 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1033 for(j=0;j<player[0].num_weapons;j++)
1035 player[0].weaponids[j]=weapons.numweapons;
1036 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1037 weapons.owner[weapons.numweapons]=0;
1038 weapons.numweapons++;
1042 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1044 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1045 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1046 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1047 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1049 funpackf(tfile, "Bi", &player[0].numclothes);
1053 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1057 player[0].whichskin=0;
1058 player[0].creature=rabbittype;
1061 for(i=0;i<max_dialogues;i++)
1063 for(j=0;j<max_dialoguelength;j++)
1067 dialoguetext[i][j][k]='\0';
1071 dialoguename[i][j][k]='\0';
1076 player[0].lastattack=-1;
1077 player[0].lastattack2=-1;
1078 player[0].lastattack3=-1;
1082 funpackf(tfile, "Bi", &numdialogues);
1085 for(k=0;k<numdialogues;k++)
1087 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1088 funpackf(tfile, "Bi", &dialoguetype[k]);
1091 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1092 funpackf(tfile, "Bf", &participantrotation[k][l]);
1094 if(numdialogueboxes)
1096 for(l=0;l<numdialogueboxes[k];l++)
1098 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1099 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1100 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1101 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1102 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1106 funpackf(tfile, "Bi",&templength);
1107 if(templength>128||templength<=0)templength=128;
1108 for(m=0;m<templength;m++){
1109 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1110 if(dialoguetext[k][l][m]=='\0')break;
1113 funpackf(tfile, "Bi",&templength);
1114 if(templength>64||templength<=0)templength=64;
1115 for(m=0;m<templength;m++){
1116 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1117 if(dialoguename[k][l][m]=='\0'){
1121 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1122 funpackf(tfile, "Bi", &participantfocus[k][l]);
1123 funpackf(tfile, "Bi", &participantaction[k][l]);
1126 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1128 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1134 else numdialogues=0;
1136 if(player[0].numclothes)
1138 for(k=0;k<player[0].numclothes;k++)
1140 funpackf(tfile, "Bi", &templength);
1141 for(l=0;l<templength;l++)
1142 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1143 player[0].clothes[k][templength]='\0';
1144 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1148 funpackf(tfile, "Bi", &environment);
1150 funpackf(tfile, "Bi", &objects.numobjects);
1151 if(objects.numobjects)
1153 for(i=0;i<objects.numobjects;i++)
1155 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]);
1156 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1162 funpackf(tfile, "Bi", &numhotspots);
1165 for(i=0;i<numhotspots;i++)
1167 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1168 funpackf(tfile, "Bi", &templength);
1170 for(l=0;l<templength;l++)
1171 funpackf(tfile, "Bb", &hotspottext[i][l]);
1172 hotspottext[i][templength]='\0';
1173 if(hotspottype[i]==-111)indemo=1;
1179 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1184 for(i=0;i<objects.numobjects;i++)
1186 objects.center+=objects.position[i];
1188 objects.center/=objects.numobjects;
1191 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1193 float maxdistance=0;
1196 for(i=0;i<objects.numobjects;i++)
1198 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1199 if(tempdist>maxdistance)
1202 maxdistance=tempdist;
1205 objects.radius=fast_sqrt(maxdistance);
1208 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1209 //mapcenter=objects.center;
1210 //mapradius=objects.radius;
1212 funpackf(tfile, "Bi", &numplayers);
1213 int howmanyremoved=0;
1214 bool removeanother=0;
1215 if(numplayers>1&&numplayers<maxplayers)
1217 for(i=1;i<numplayers;i++)
1219 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1222 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);
1223 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1224 else player[i-howmanyremoved].howactive=typeactive;
1225 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1226 else player[i-howmanyremoved].scale=-1;
1227 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1228 else player[i-howmanyremoved].immobile=0;
1229 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1230 else player[i-howmanyremoved].rotation=0;
1231 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1232 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1238 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1240 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1242 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1243 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1244 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1245 weapons.numweapons++;
1248 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1249 //player[i-howmanyremoved].numwaypoints=10;
1250 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1252 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1253 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1254 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1255 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1256 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1259 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1260 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1262 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1263 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1264 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1265 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1267 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1275 if(player[i-howmanyremoved].creature==wolftype)
1277 player[i-howmanyremoved].proportionhead=1.1*headprop;
1278 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1279 player[i-howmanyremoved].proportionarms=1.1*armprop;
1280 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1283 if(player[i-howmanyremoved].creature==rabbittype)
1285 player[i-howmanyremoved].proportionhead=1.2*headprop;
1286 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1287 player[i-howmanyremoved].proportionarms=1.00*armprop;
1288 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1289 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1292 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1293 if(player[i-howmanyremoved].numclothes)
1295 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1298 funpackf(tfile, "Bi", &templength);
1299 for(l=0;l<templength;l++)
1300 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1301 player[i-howmanyremoved].clothes[k][templength]='\0';
1302 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1308 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1310 numplayers-=howmanyremoved;
1311 funpackf(tfile, "Bi", &numpathpoints);
1312 if(numpathpoints>30||numpathpoints<0)
1316 for(j=0;j<numpathpoints;j++)
1318 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1319 for(k=0;k<numpathpointconnect[j];k++){
1320 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1324 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1326 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1329 if(environment!=oldenvironment)Setenvironment(environment);
1330 oldenvironment=environment;
1334 j=objects.numobjects;
1335 objects.numobjects=0;
1338 //if(objects.type[i]!=spiketype)
1339 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1340 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1343 //if(skyboxtexture){
1344 terrain.DoShadows();
1345 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1346 objects.DoShadows();
1347 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1349 else terrain.DoLighting();
1355 oldlevel=whichlevel;
1358 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1359 for(i=0;i<numplayers;i++)
1361 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1365 if(i==0||player[i].scale<0)player[i].scale=.2;
1366 player[i].skeleton.free=0;
1367 player[i].skeleton.id=i;
1368 //if(Random()%2==0)player[i].creature=wolftype;
1369 //else player[i].creature=rabbittype;
1370 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1371 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);
1374 if(player[i].creature!=wolftype){
1375 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);
1376 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1378 if(player[i].creature==wolftype){
1379 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);
1385 texsize=512*512*3/texdetail/texdetail;
1386 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1387 //player[i].skeleton.skinText.resize(texsize);
1389 if(player[i].creature==rabbittype)
1391 if(player[i].whichskin==0){
1392 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1394 else if(player[i].whichskin==1){
1395 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1397 else if(player[i].whichskin==2){
1398 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1400 else if(player[i].whichskin==3){
1401 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1403 else if(player[i].whichskin==4){
1404 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1406 else if(player[i].whichskin==5){
1407 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1409 else if(player[i].whichskin==6){
1410 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1412 else if(player[i].whichskin==7){
1413 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1415 else if(player[i].whichskin==8){
1416 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1418 else if(player[i].whichskin==9){
1419 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1422 if(player[i].creature==wolftype)
1424 //k=abs(Random()%3);
1425 if(player[i].whichskin==0){
1426 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1428 else if(player[i].whichskin==1){
1429 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1431 else if(player[i].whichskin==2){
1432 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1436 if(player[i].numclothes)
1438 for(j=0;j<player[i].numclothes;j++)
1440 tintr=player[i].clothestintr[j];
1441 tintg=player[i].clothestintg[j];
1442 tintb=player[i].clothestintb[j];
1443 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1445 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1448 player[i].currentanimation=bounceidleanim;
1449 player[i].targetanimation=bounceidleanim;
1450 player[i].currentframe=0;
1451 player[i].targetframe=1;
1453 player[i].speed=1+(float)(Random()%100)/1000;
1454 if(difficulty==0)player[i].speed-=.2;
1455 if(difficulty==1)player[i].speed-=.1;
1457 player[i].velocity=0;
1458 player[i].oldcoords=player[i].coords;
1459 player[i].realoldcoords=player[i].coords;
1462 player[i].skeleton.id=i;
1463 player[i].updatedelay=0;
1464 player[i].normalsupdatedelay=0;
1466 player[i].aitype=passivetype;
1467 player[i].aitarget=0;
1468 player[i].madskills=0;
1472 player[i].proportionhead=1.2;
1473 player[i].proportionbody=1.05;
1474 player[i].proportionarms=1.00;
1475 player[i].proportionlegs=1.1;
1476 player[i].proportionlegs.y=1.05;
1478 player[i].headless=0;
1479 player[i].currentoffset=0;
1480 player[i].targetoffset=0;
1481 /*player[i].armorhead=1;
1482 player[i].armorhigh=1;
1483 player[i].armorlow=1;
1484 player[i].protectionhead=1;
1485 player[i].protectionhigh=1;
1486 player[i].protectionlow=1;
1487 player[i].metalhead=1;
1488 player[i].metalhigh=1;
1489 player[i].metallow=1;
1491 player[i].speedmult=1;*/
1493 player[i].damagetolerance=200;
1495 if(player[i].creature==wolftype)
1497 /*player[i].proportionhead=1.1;
1498 player[i].proportionbody=1.1;
1499 player[i].proportionarms=1.1;
1500 player[i].proportionlegs=1.1;
1501 player[i].proportionlegs.y=1.1;*/
1502 if(i==0||player[i].scale<0)player[i].scale=.23;
1504 player[i].damagetolerance=300;
1507 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1510 player[i].proportionhead.z=0;
1511 player[i].proportionbody.z=0;
1512 player[i].proportionarms.z=0;
1513 player[i].proportionlegs.z=0;
1516 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1518 player[i].headmorphness=0;
1519 player[i].targetheadmorphness=1;
1520 player[i].headmorphstart=0;
1521 player[i].headmorphend=0;
1523 player[i].pausetime=0;
1526 player[i].jumppower=5;
1528 player[i].permanentdamage=0;
1529 player[i].superpermanentdamage=0;
1531 player[i].forwardkeydown=0;
1532 player[i].leftkeydown=0;
1533 player[i].backkeydown=0;
1534 player[i].rightkeydown=0;
1535 player[i].jumpkeydown=0;
1536 player[i].crouchkeydown=0;
1537 player[i].throwkeydown=0;
1539 player[i].collided=-10;
1541 player[i].bloodloss=0;
1542 player[i].weaponactive=-1;
1543 player[i].weaponstuck=-1;
1544 player[i].bleeding=0;
1545 player[i].deathbleeding=0;
1546 player[i].stunned=0;
1547 player[i].hasvictim=0;
1548 player[i].wentforweapon=0;
1551 player[0].aitype=playercontrolled;
1552 player[0].weaponactive=-1;
1556 //player[0].speedmult=1/.9;
1557 player[0].power=1/.9;
1562 //player[0].speedmult=1/.8;
1563 player[0].power=1/.8;
1566 //player[0].weaponstuck=1;
1568 if(difficulty==1)player[0].damagetolerance=250;
1569 if(difficulty==0)player[0].damagetolerance=300;
1570 if(difficulty==0)player[0].armorhead*=1.5;
1571 if(difficulty==0)player[0].armorhigh*=1.5;
1572 if(difficulty==0)player[0].armorlow*=1.5;
1573 cameraloc=player[0].coords;
1575 rotation=player[0].rotation;
1577 hawkcoords=player[0].coords;
1580 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1581 //weapons.numweapons=numplayers;
1582 for(i=0;i<weapons.numweapons;i++)
1584 weapons.bloody[i]=0;
1585 weapons.blooddrip[i]=0;
1586 weapons.blooddripdelay[i]=0;
1587 weapons.onfire[i]=0;
1588 weapons.flamedelay[i]=0;
1589 weapons.damage[i]=0;
1590 //weapons.type[i]=sword;
1591 if(weapons.type[i]==sword){
1592 weapons.mass[i]=1.5;
1593 weapons.tipmass[i]=1;
1594 weapons.length[i]=.8;
1596 if(weapons.type[i]==staff){
1598 weapons.tipmass[i]=1;
1599 weapons.length[i]=1.5;
1601 if(weapons.type[i]==knife){
1603 weapons.tipmass[i]=1.2;
1604 weapons.length[i]=.25;
1606 weapons.position[i]=-1000;
1607 weapons.tippoint[i]=-1000;
1610 /* for(i=0;i<32;i++){
1612 OPENAL_StopSound(i);
1615 LOG("Starting background music...");
1617 OPENAL_StopSound(OPENAL_ALL);
1618 if(environment==snowyenvironment)
1622 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1623 OPENAL_SetPaused(channels[stream_wind], false);
1624 OPENAL_SetVolume(channels[stream_wind], 256);
1627 else if(environment==desertenvironment)
1631 //PlaySoundEx(desertambient,
1632 // samp[desertambient], NULL, true);
1633 PlayStreamEx(stream_desertambient,
1634 strm[stream_desertambient], NULL, true);
1635 OPENAL_SetPaused(channels[stream_desertambient], false);
1636 OPENAL_SetVolume(channels[stream_desertambient], 256);
1639 else if(environment==grassyenvironment)
1643 //PlaySoundEx(wind, samp[wind], NULL, true);
1644 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1645 OPENAL_SetPaused(channels[stream_wind], false);
1646 OPENAL_SetVolume(channels[stream_wind], 100);
1649 oldmusicvolume[0]=0;
1650 oldmusicvolume[1]=0;
1651 oldmusicvolume[2]=0;
1652 oldmusicvolume[3]=0;
1655 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1656 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1657 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1658 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1659 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1660 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1661 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1662 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1677 static int i,k,j,l,m;
1678 static XYZ facing,flatfacing,absflatfacing;
1679 static XYZ rotatetarget;
1681 static float oldtargetrotation;
1682 static int target, numgood;
1683 static XYZ tempcoords1,tempcoords2;
1686 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1687 static int whichhit;
1688 static bool donesomething;
1689 static bool oldjumpkeydown;
1693 float headprop,bodyprop,armprop,legprop;
1696 displaytime[i]+=multiplier;
1699 static unsigned char theKeyMap[16];
1700 GetKeys( theKeyMap );
1705 static bool mainmenutogglekeydown;
1707 if(mainmenu&&endgame==1)mainmenu=10;
1708 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1710 displaytext[0][j]=' ';
1715 mainmenutogglekeydown=1;
1717 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)){
1719 if(mainmenu==1||mainmenu==2||mainmenu==0){
1720 if(mainmenu==0&&!winfreeze)mainmenu=2;
1721 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1722 else if(mainmenu==0&&winfreeze){
1723 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1725 else stealthloading=0;
1727 if(!stealthloading){
1728 float gLoc[3]={0,0,0};
1729 float vel[3]={0,0,0};
1730 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1731 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1732 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1733 OPENAL_SetVolume(channels[firestartsound], 256);
1734 OPENAL_SetPaused(channels[firestartsound], false);
1735 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1746 for(i=0;i<campaignnumlevels;i++){
1748 levelhighlight[i]=0;
1753 if(accountcampaignchoicesmade[accountactive])
1754 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1755 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1756 levelvisible[levelorder[i+1]]=1;
1758 int whichlevelstart;
1759 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1760 if(whichlevelstart<0){
1761 campaignchoicenum=1;
1762 campaignchoicewhich[0]=0;
1766 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1767 if(campaignchoicenum)
1768 for(i=0;i<campaignchoicenum;i++){
1769 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1770 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1771 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1778 if(firstload)TickOnceAfter();
1779 if(!firstload)LoadStuff();
1796 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1797 //accountcampaignchoicesmade[accountactive]++;
1800 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1808 OPENAL_SetPaused(channels[music3], true);
1812 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1813 if(mainmenu&&musictoggle){
1814 if(mainmenu==1||mainmenu==2||mainmenu==100){
1815 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
1816 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1817 OPENAL_SetPaused(channels[stream_music3], false);
1818 OPENAL_SetVolume(channels[stream_music3], 256);
1819 OPENAL_SetPaused(channels[music1], true);
1823 OPENAL_SetPaused(channels[stream_music3], true);
1824 OPENAL_SetPaused(channels[music1], false);
1828 float gLoc[3]={0,0,0};
1829 float vel[3]={0,0,0};
1830 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1831 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1832 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1833 OPENAL_SetVolume(channels[fireendsound], 256);
1834 OPENAL_SetPaused(channels[fireendsound], false);
1835 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1843 if(newdetail>2)newdetail=detail;
1844 if(newdetail<0)newdetail=detail;
1845 if(newscreenwidth<0)newscreenwidth=screenwidth;
1846 if(newscreenheight<0)newscreenheight=screenheight;
1848 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1849 opstream << "Screenwidth:\n";
1850 opstream << newscreenwidth;
1851 opstream << "\nScreenheight:\n";
1852 opstream << newscreenheight;
1853 opstream << "\nMouse sensitivity:\n";
1854 opstream << usermousesensitivity;
1855 opstream << "\nBlur(0,1):\n";
1856 opstream << ismotionblur;
1857 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1858 opstream << newdetail;
1859 opstream << "\nFloating jump:\n";
1860 opstream << floatjump;
1861 opstream << "\nMouse jump:\n";
1862 opstream << mousejump;
1863 opstream << "\nAmbient sound:\n";
1864 opstream << ambientsound;
1865 opstream << "\nBlood (0,1,2):\n";
1866 opstream << bloodtoggle;
1867 opstream << "\nAuto slomo:\n";
1868 opstream << autoslomo;
1869 opstream << "\nFoliage:\n";
1870 opstream << foliage;
1871 opstream << "\nMusic:\n";
1872 opstream << musictoggle;
1873 opstream << "\nTrilinear:\n";
1874 opstream << trilinear;
1875 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1877 opstream << "\nInvert mouse:\n";
1878 opstream << invertmouse;
1879 opstream << "\nGamespeed:\n";
1880 if(oldgamespeed==0)oldgamespeed=1;
1881 opstream << oldgamespeed;
1882 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1883 opstream << difficulty;
1884 opstream << "\nDamage effects(blackout, doublevision):\n";
1885 opstream << damageeffects;
1886 opstream << "\nText:\n";
1887 opstream << texttoggle;
1888 opstream << "\nDebug:\n";
1889 opstream << debugmode;
1890 opstream << "\nVBL Sync:\n";
1891 opstream << vblsync;
1892 opstream << "\nShow Points:\n";
1893 opstream << showpoints;
1894 opstream << "\nAlways Blur:\n";
1895 opstream << alwaysblur;
1896 opstream << "\nImmediate mode (turn on on G5):\n";
1897 opstream << immediate;
1898 opstream << "\nVelocity blur:\n";
1899 opstream << velocityblur;
1900 opstream << "\nVolume:\n";
1902 opstream << "\nForward key:\n";
1903 opstream << KeyToChar(forwardkey);
1904 opstream << "\nBack key:\n";
1905 opstream << KeyToChar(backkey);
1906 opstream << "\nLeft key:\n";
1907 opstream << KeyToChar(leftkey);
1908 opstream << "\nRight key:\n";
1909 opstream << KeyToChar(rightkey);
1910 opstream << "\nJump key:\n";
1911 opstream << KeyToChar(jumpkey);
1912 opstream << "\nCrouch key:\n";
1913 opstream << KeyToChar(crouchkey);
1914 opstream << "\nDraw key:\n";
1915 opstream << KeyToChar(drawkey);
1916 opstream << "\nThrow key:\n";
1917 opstream << KeyToChar(throwkey);
1918 opstream << "\nAttack key:\n";
1919 opstream << KeyToChar(attackkey);
1920 opstream << "\nChat key:\n";
1921 opstream << KeyToChar(chatkey);
1924 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
1925 float gLoc[3]={0,0,0};
1926 float vel[3]={0,0,0};
1927 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1928 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1929 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1930 OPENAL_SetVolume(channels[fireendsound], 256);
1931 OPENAL_SetPaused(channels[fireendsound], false);
1932 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1940 if(mainmenu==3&&gameon)mainmenu=2;
1941 if(mainmenu==3&&!gameon)mainmenu=1;
1942 if(mainmenu==5&&gameon)mainmenu=2;
1943 if(mainmenu==5&&!gameon)mainmenu=1;
1944 if(mainmenu==4)mainmenu=3;
1945 if(mainmenu==6)mainmenu=5;
1946 if(mainmenu==7)mainmenu=1;
1947 if(mainmenu==9)mainmenu=5;
1948 if(mainmenu==11)mainmenu=5;
1949 if(mainmenu==13)mainmenu=12;
1950 if(mainmenu==10)mainmenu=5;
1956 mainmenutogglekeydown=1;
1958 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1959 mainmenutogglekeydown=0;
1963 /*static bool minimaptogglekeydown;
1964 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1966 minimaptogglekeydown=1;
1968 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1969 minimaptogglekeydown=0;
1973 static bool minimaptogglekeydown;
1974 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1975 if(tutorialstage!=51)
1976 tutorialstagetime=tutorialmaxtime;
1977 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
1978 OPENAL_SetVolume(channels[consolefailsound], 128);
1979 OPENAL_SetPaused(channels[consolefailsound], false);
1980 minimaptogglekeydown=1;
1982 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1983 minimaptogglekeydown=0;
1988 if(mainmenu==1||mainmenu==2){
1989 if(Button()&&!oldbutton&&selected==1){
1991 float gLoc[3]={0,0,0};
1992 float vel[3]={0,0,0};
1993 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1994 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1995 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1996 OPENAL_SetVolume(channels[firestartsound], 256);
1997 OPENAL_SetPaused(channels[firestartsound], false);
1998 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2007 if(accountactive!=-1)mainmenu=5;
2014 if(firstload)TickOnceAfter();
2015 if(!firstload)LoadStuff();
2021 OPENAL_SetPaused(channels[music3], true); */
2027 OPENAL_SetPaused(channels[stream_music3], true);
2028 OPENAL_SetPaused(channels[music1], false);
2032 if(Button()&&!oldbutton&&selected==2){
2033 float gLoc[3]={0,0,0};
2034 float vel[3]={0,0,0};
2035 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2036 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2037 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2038 OPENAL_SetVolume(channels[firestartsound], 256);
2039 OPENAL_SetPaused(channels[firestartsound], false);
2040 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2052 if(newdetail>2)newdetail=detail;
2053 if(newdetail<0)newdetail=detail;
2054 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2055 if(newscreenwidth<0)newscreenwidth=screenwidth;
2056 if(newscreenheight>3000)newscreenheight=screenheight;
2057 if(newscreenheight<0)newscreenheight=screenheight;
2060 if(Button()&&!oldbutton&&selected==3){
2061 float gLoc[3]={0,0,0};
2062 float vel[3]={0,0,0};
2063 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2064 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2065 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2066 OPENAL_SetVolume(channels[fireendsound], 256);
2067 OPENAL_SetPaused(channels[fireendsound], false);
2068 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2079 OPENAL_SetPaused(channels[stream_music3], true);
2087 if(Button())oldbutton=1;
2092 if(Button()&&!oldbutton&&selected!=-1){
2093 float gLoc[3]={0,0,0};
2094 float vel[3]={0,0,0};
2095 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2096 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2097 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2098 OPENAL_SetVolume(channels[firestartsound], 256);
2099 OPENAL_SetPaused(channels[firestartsound], false);
2100 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2102 if(Button()&&!oldbutton&&selected==0){
2104 extern SDL_Rect **resolutions;
2105 bool isCustomResolution = true;
2107 for (int i = 0; (!found) && (resolutions[i]); i++)
2109 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2110 isCustomResolution = false;
2112 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2115 if (resolutions[i] != NULL)
2117 newscreenwidth = (int) resolutions[i]->w;
2118 newscreenheight = (int) resolutions[i]->h;
2120 else if (isCustomResolution)
2122 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2124 newscreenwidth = (int) resolutions[0]->w;
2125 newscreenheight = (int) resolutions[0]->h;
2129 newscreenwidth = screenwidth;
2130 newscreenheight = screenheight;
2135 newscreenwidth = (int) resolutions[0]->w;
2136 newscreenheight = (int) resolutions[0]->h;
2144 newscreenwidth = (int) resolutions[0]->w;
2145 newscreenheight = (int) resolutions[0]->h;
2150 if(Button()&&!oldbutton&&selected==1){
2152 if(newdetail>2)newdetail=0;
2154 if(Button()&&!oldbutton&&selected==2){
2156 if(bloodtoggle>2)bloodtoggle=0;
2158 if(Button()&&!oldbutton&&selected==3){
2160 if(difficulty>2)difficulty=0;
2162 if(Button()&&!oldbutton&&selected==4){
2163 ismotionblur=1-ismotionblur;
2165 if(Button()&&!oldbutton&&selected==5){
2168 if(Button()&&!oldbutton&&selected==6){
2169 musictoggle=1-musictoggle;
2172 OPENAL_SetPaused(channels[music1], true);
2173 OPENAL_SetPaused(channels[stream_music2], true);
2174 OPENAL_SetPaused(channels[stream_music3], true);
2177 oldmusicvolume[i]=0;
2183 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2184 OPENAL_SetPaused(channels[stream_music3], false);
2185 OPENAL_SetVolume(channels[stream_music3], 256);
2188 if(Button()&&!oldbutton&&selected==9){
2189 invertmouse=1-invertmouse;
2191 if(Button()&&!oldbutton&&selected==10){
2192 usermousesensitivity+=.2;
2193 if(usermousesensitivity>2)usermousesensitivity=.2;
2195 if(Button()&&!oldbutton&&selected==11){
2197 if(volume>1.0001f)volume=0;
2198 OPENAL_SetSFXMasterVolume((int)(volume*255));
2200 if(Button()&&!oldbutton&&selected==7){
2201 /*float gLoc[3]={0,0,0};
2202 float vel[3]={0,0,0};
2203 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2204 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2205 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2206 OPENAL_SetVolume(channels[firestartsound], 256);
2207 OPENAL_SetPaused(channels[firestartsound], false);
2208 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2221 if(Button()&&!oldbutton&&selected==8){
2222 float gLoc[3]={0,0,0};
2223 float vel[3]={0,0,0};
2224 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2225 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2226 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2227 OPENAL_SetVolume(channels[fireendsound], 256);
2228 OPENAL_SetPaused(channels[fireendsound], false);
2229 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2237 if(newdetail>2)newdetail=detail;
2238 if(newdetail<0)newdetail=detail;
2239 if(newscreenwidth<0)newscreenwidth=screenwidth;
2240 if(newscreenheight<0)newscreenheight=screenheight;
2243 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2244 opstream << "Screenwidth:\n";
2245 opstream << newscreenwidth;
2246 opstream << "\nScreenheight:\n";
2247 opstream << newscreenheight;
2248 opstream << "\nMouse sensitivity:\n";
2249 opstream << usermousesensitivity;
2250 opstream << "\nBlur(0,1):\n";
2251 opstream << ismotionblur;
2252 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2253 opstream << newdetail;
2254 opstream << "\nFloating jump:\n";
2255 opstream << floatjump;
2256 opstream << "\nMouse jump:\n";
2257 opstream << mousejump;
2258 opstream << "\nAmbient sound:\n";
2259 opstream << ambientsound;
2260 opstream << "\nBlood (0,1,2):\n";
2261 opstream << bloodtoggle;
2262 opstream << "\nAuto slomo:\n";
2263 opstream << autoslomo;
2264 opstream << "\nFoliage:\n";
2265 opstream << foliage;
2266 opstream << "\nMusic:\n";
2267 opstream << musictoggle;
2268 opstream << "\nTrilinear:\n";
2269 opstream << trilinear;
2270 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2272 opstream << "\nInvert mouse:\n";
2273 opstream << invertmouse;
2274 opstream << "\nGamespeed:\n";
2275 if(oldgamespeed==0)oldgamespeed=1;
2276 opstream << oldgamespeed;
2277 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2278 opstream << difficulty;
2279 opstream << "\nDamage effects(blackout, doublevision):\n";
2280 opstream << damageeffects;
2281 opstream << "\nText:\n";
2282 opstream << texttoggle;
2283 opstream << "\nDebug:\n";
2284 opstream << debugmode;
2285 opstream << "\nVBL Sync:\n";
2286 opstream << vblsync;
2287 opstream << "\nShow Points:\n";
2288 opstream << showpoints;
2289 opstream << "\nAlways Blur:\n";
2290 opstream << alwaysblur;
2291 opstream << "\nImmediate mode (turn on on G5):\n";
2292 opstream << immediate;
2293 opstream << "\nVelocity blur:\n";
2294 opstream << velocityblur;
2295 opstream << "\nVolume:\n";
2297 opstream << "\nForward key:\n";
2298 opstream << KeyToChar(forwardkey);
2299 opstream << "\nBack key:\n";
2300 opstream << KeyToChar(backkey);
2301 opstream << "\nLeft key:\n";
2302 opstream << KeyToChar(leftkey);
2303 opstream << "\nRight key:\n";
2304 opstream << KeyToChar(rightkey);
2305 opstream << "\nJump key:\n";
2306 opstream << KeyToChar(jumpkey);
2307 opstream << "\nCrouch key:\n";
2308 opstream << KeyToChar(crouchkey);
2309 opstream << "\nDraw key:\n";
2310 opstream << KeyToChar(drawkey);
2311 opstream << "\nThrow key:\n";
2312 opstream << KeyToChar(throwkey);
2313 opstream << "\nAttack key:\n";
2314 opstream << KeyToChar(attackkey);
2315 opstream << "\nChat key:\n";
2316 opstream << KeyToChar(chatkey);
2319 if(mainmenu==3&&gameon)mainmenu=2;
2320 if(mainmenu==3&&!gameon)mainmenu=1;
2322 if(Button())oldbutton=1;
2326 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2327 float gLoc[3]={0,0,0};
2328 float vel[3]={0,0,0};
2329 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2330 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2331 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2332 OPENAL_SetVolume(channels[firestartsound], 256);
2333 OPENAL_SetPaused(channels[firestartsound], false);
2334 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2336 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2344 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2346 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2347 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2348 float gLoc[3]={0,0,0};
2349 float vel[3]={0,0,0};
2350 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2351 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2352 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2353 OPENAL_SetVolume(channels[fireendsound], 256);
2354 OPENAL_SetPaused(channels[fireendsound], false);
2355 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2359 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2360 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2364 if(keyselect==0)forwardkey=keynum;
2365 if(keyselect==1)backkey=keynum;
2366 if(keyselect==2)leftkey=keynum;
2367 if(keyselect==3)rightkey=keynum;
2368 if(keyselect==4)crouchkey=keynum;
2369 if(keyselect==5)jumpkey=keynum;
2370 if(keyselect==6)drawkey=keynum;
2371 if(keyselect==7)throwkey=keynum;
2372 if(keyselect==8)attackkey=keynum;
2377 if(Button()&&!oldbutton&&selected==9){
2378 float gLoc[3]={0,0,0};
2379 float vel[3]={0,0,0};
2380 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2381 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2382 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2383 OPENAL_SetVolume(channels[fireendsound], 256);
2384 OPENAL_SetPaused(channels[fireendsound], false);
2385 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2395 if(newdetail>2)newdetail=detail;
2396 if(newdetail<0)newdetail=detail;
2397 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2398 if(newscreenwidth<0)newscreenwidth=screenwidth;
2399 if(newscreenheight>3000)newscreenheight=screenheight;
2400 if(newscreenheight<0)newscreenheight=screenheight;
2407 accountcampaignchoicesmade[accountactive]=0;
2408 accountcampaignscore[accountactive]=0;
2409 accountcampaigntime[accountactive]=0;
2413 if(Button()&&!oldbutton&&selected==1){
2414 float gLoc[3]={0,0,0};
2415 float vel[3]={0,0,0};
2416 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2417 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2418 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2419 OPENAL_SetVolume(channels[firestartsound], 256);
2420 OPENAL_SetPaused(channels[firestartsound], false);
2421 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2434 if(firstload)TickOnceAfter();
2435 if(!firstload)LoadStuff();
2442 OPENAL_SetPaused(channels[stream_music3], true);
2444 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2445 float gLoc[3]={0,0,0};
2446 float vel[3]={0,0,0};
2447 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2448 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2449 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2450 OPENAL_SetVolume(channels[firestartsound], 256);
2451 OPENAL_SetPaused(channels[firestartsound], false);
2452 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2465 if(firstload)TickOnceAfter();
2466 if(!firstload)LoadStuff();
2482 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2483 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2487 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2492 OPENAL_SetPaused(channels[stream_music3], true);
2494 if(Button()&&!oldbutton&&selected==4){
2495 float gLoc[3]={0,0,0};
2496 float vel[3]={0,0,0};
2497 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2498 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2499 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2500 OPENAL_SetVolume(channels[fireendsound], 256);
2501 OPENAL_SetPaused(channels[fireendsound], false);
2502 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2510 if(mainmenu==5&&gameon)mainmenu=2;
2511 if(mainmenu==5&&!gameon)mainmenu=1;
2513 if(Button()&&!oldbutton&&selected==5){
2514 float gLoc[3]={0,0,0};
2515 float vel[3]={0,0,0};
2516 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2517 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2518 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2519 OPENAL_SetVolume(channels[fireendsound], 256);
2520 OPENAL_SetPaused(channels[fireendsound], false);
2521 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2531 if(Button()&&!oldbutton&&selected==3){
2532 float gLoc[3]={0,0,0};
2533 float vel[3]={0,0,0};
2534 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2535 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2536 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2537 OPENAL_SetVolume(channels[firestartsound], 256);
2538 OPENAL_SetPaused(channels[firestartsound], false);
2539 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2549 if(Button()&&!oldbutton&&selected==2){
2550 float gLoc[3]={0,0,0};
2551 float vel[3]={0,0,0};
2552 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2553 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2554 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2555 OPENAL_SetVolume(channels[firestartsound], 256);
2556 OPENAL_SetPaused(channels[firestartsound], false);
2557 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2567 if(Button())oldbutton=1;
2571 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2572 float gLoc[3]={0,0,0};
2573 float vel[3]={0,0,0};
2574 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2575 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2576 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2577 OPENAL_SetVolume(channels[firestartsound], 256);
2578 OPENAL_SetPaused(channels[firestartsound], false);
2579 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2591 targetlevel=selected;
2592 if(firstload)TickOnceAfter();
2593 if(!firstload)LoadStuff();
2595 Loadlevel(selected);
2601 OPENAL_SetPaused(channels[stream_music3], true);
2603 if(Button()&&!oldbutton&&selected==numchallengelevels){
2604 float gLoc[3]={0,0,0};
2605 float vel[3]={0,0,0};
2606 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2607 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2608 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2609 OPENAL_SetVolume(channels[fireendsound], 256);
2610 OPENAL_SetPaused(channels[fireendsound], false);
2611 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2621 if(Button())oldbutton=1;
2625 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2626 float gLoc[3]={0,0,0};
2627 float vel[3]={0,0,0};
2628 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2629 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2630 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2631 OPENAL_SetVolume(channels[firestartsound], 256);
2632 OPENAL_SetPaused(channels[firestartsound], false);
2633 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2645 targetlevel=selected;
2646 if(firstload)TickOnceAfter();
2647 if(!firstload)LoadStuff();
2649 Loadlevel(selected);
2655 OPENAL_SetPaused(channels[stream_music3], true);
2657 if(Button()&&!oldbutton&&selected==numchallengelevels){
2658 float gLoc[3]={0,0,0};
2659 float vel[3]={0,0,0};
2660 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2661 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2662 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2663 OPENAL_SetVolume(channels[fireendsound], 256);
2664 OPENAL_SetPaused(channels[fireendsound], false);
2665 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2675 if(Button())oldbutton=1;
2680 if(Button()&&!oldbutton&&selected==3){
2681 float gLoc[3]={0,0,0};
2682 float vel[3]={0,0,0};
2683 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2684 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2685 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2686 OPENAL_SetVolume(channels[fireendsound], 256);
2687 OPENAL_SetPaused(channels[fireendsound], false);
2688 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2698 if(Button())oldbutton=1;
2703 if(Button()&&!oldbutton&&selected!=-1){
2704 float gLoc[3]={0,0,0};
2705 float vel[3]={0,0,0};
2706 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2707 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2708 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2709 OPENAL_SetVolume(channels[firestartsound], 256);
2710 OPENAL_SetPaused(channels[firestartsound], false);
2711 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2713 if(Button()&&!oldbutton&&selected==1){
2714 float gLoc[3]={0,0,0};
2715 float vel[3]={0,0,0};
2716 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2717 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2718 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2719 OPENAL_SetVolume(channels[fireendsound], 256);
2720 OPENAL_SetPaused(channels[fireendsound], false);
2721 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2729 for(i=accountactive;i<numaccounts-1;i++){
2730 accountdifficulty[i]=accountdifficulty[i+1];
2731 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2732 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2733 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2735 accountpoints[i]=accountpoints[i+1];
2737 accounthighscore[i][j]=accounthighscore[i+1][j];
2738 accountfasttime[i][j]=accountfasttime[i+1][j];
2741 accountunlocked[i][j]=accountunlocked[i+1][j];
2744 accountname[i][j]=accountname[i+1][j];
2746 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2747 accountprogress[i]=accountprogress[i+1];
2748 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2749 accountcampaignscore[i]=accountcampaignscore[i+1];
2750 accountcampaigntime[i]=accountcampaigntime[i+1];
2759 if(Button()&&!oldbutton&&selected==2){
2760 float gLoc[3]={0,0,0};
2761 float vel[3]={0,0,0};
2762 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2763 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2764 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2765 OPENAL_SetVolume(channels[fireendsound], 256);
2766 OPENAL_SetPaused(channels[fireendsound], false);
2767 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2777 if(Button())oldbutton=1;
2781 if(Button()&&!oldbutton&&selected!=-1){
2782 float gLoc[3]={0,0,0};
2783 float vel[3]={0,0,0};
2784 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2785 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2786 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2787 OPENAL_SetVolume(channels[firestartsound], 256);
2788 OPENAL_SetPaused(channels[firestartsound], false);
2789 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2791 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2794 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2795 accountactive=selected-1;
2803 if(Button()&&!oldbutton&&selected==numaccounts+1){
2804 float gLoc[3]={0,0,0};
2805 float vel[3]={0,0,0};
2806 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2807 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2808 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2809 OPENAL_SetVolume(channels[fireendsound], 256);
2810 OPENAL_SetPaused(channels[fireendsound], false);
2811 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2822 displaytext[0][j]=' ';
2828 if(Button())oldbutton=1;
2832 if(Button()&&!oldbutton&&selected!=-1){
2833 float gLoc[3]={0,0,0};
2834 float vel[3]={0,0,0};
2835 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2836 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2837 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2838 OPENAL_SetVolume(channels[firestartsound], 256);
2839 OPENAL_SetPaused(channels[firestartsound], false);
2840 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2842 if(selected==0)accountdifficulty[accountactive]=0;
2843 if(selected==1)accountdifficulty[accountactive]=1;
2844 if(selected==2)accountdifficulty[accountactive]=2;
2855 if(Button())oldbutton=1;
2860 if(Button())oldbutton=1;
2863 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2866 if(newdetail>2)newdetail=detail;
2867 if(newdetail<0)newdetail=detail;
2868 if(newscreenwidth<0)newscreenwidth=screenwidth;
2869 if(newscreenheight<0)newscreenheight=screenheight;
2871 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2872 opstream << "Screenwidth:\n";
2873 opstream << newscreenwidth;
2874 opstream << "\nScreenheight:\n";
2875 opstream << newscreenheight;
2876 opstream << "\nMouse sensitivity:\n";
2877 opstream << usermousesensitivity;
2878 opstream << "\nBlur(0,1):\n";
2879 opstream << ismotionblur;
2880 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2881 opstream << newdetail;
2882 opstream << "\nFloating jump:\n";
2883 opstream << floatjump;
2884 opstream << "\nMouse jump:\n";
2885 opstream << mousejump;
2886 opstream << "\nAmbient sound:\n";
2887 opstream << ambientsound;
2888 opstream << "\nBlood (0,1,2):\n";
2889 opstream << bloodtoggle;
2890 opstream << "\nAuto slomo:\n";
2891 opstream << autoslomo;
2892 opstream << "\nFoliage:\n";
2893 opstream << foliage;
2894 opstream << "\nMusic:\n";
2895 opstream << musictoggle;
2896 opstream << "\nTrilinear:\n";
2897 opstream << trilinear;
2898 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2900 opstream << "\nInvert mouse:\n";
2901 opstream << invertmouse;
2902 opstream << "\nGamespeed:\n";
2903 if(oldgamespeed==0)oldgamespeed=1;
2904 opstream << oldgamespeed;
2905 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2906 opstream << difficulty;
2907 opstream << "\nDamage effects(blackout, doublevision):\n";
2908 opstream << damageeffects;
2909 opstream << "\nText:\n";
2910 opstream << texttoggle;
2911 opstream << "\nDebug:\n";
2912 opstream << debugmode;
2913 opstream << "\nVBL Sync:\n";
2914 opstream << vblsync;
2915 opstream << "\nShow Points:\n";
2916 opstream << showpoints;
2917 opstream << "\nAlways Blur:\n";
2918 opstream << alwaysblur;
2919 opstream << "\nImmediate mode (turn on on G5):\n";
2920 opstream << immediate;
2921 opstream << "\nVelocity blur:\n";
2922 opstream << velocityblur;
2923 opstream << "\nVolume:\n";
2925 opstream << "\nForward key:\n";
2926 opstream << KeyToChar(forwardkey);
2927 opstream << "\nBack key:\n";
2928 opstream << KeyToChar(backkey);
2929 opstream << "\nLeft key:\n";
2930 opstream << KeyToChar(leftkey);
2931 opstream << "\nRight key:\n";
2932 opstream << KeyToChar(rightkey);
2933 opstream << "\nJump key:\n";
2934 opstream << KeyToChar(jumpkey);
2935 opstream << "\nCrouch key:\n";
2936 opstream << KeyToChar(crouchkey);
2937 opstream << "\nDraw key:\n";
2938 opstream << KeyToChar(drawkey);
2939 opstream << "\nThrow key:\n";
2940 opstream << KeyToChar(throwkey);
2941 opstream << "\nAttack key:\n";
2942 opstream << KeyToChar(attackkey);
2943 opstream << "\nChat key:\n";
2944 opstream << KeyToChar(chatkey);
2949 if(mainmenu==1||mainmenu==2){
2950 if(loaddistrib>4)transition+=multiplier/8;
2958 OPENAL_SetFrequency(channels[stream_music3], 22050);
2962 if(IsKeyDown(theKeyMap, i)){
2963 togglekeydelay[i]+=multiplier;
2964 if(togglekeydelay[i]>.4){
2966 togglekeydelay[i]=.36;
2969 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
2970 for(j=255;j>=displayselected+1;j--){
2971 displaytext[0][j]=displaytext[0][j-1];
2973 displaytext[0][displayselected]=KeyToSingleChar(i);
2974 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
2978 if(i==MAC_DELETE_KEY&&displayselected!=0){
2979 for(j=displayselected-1;j<255;j++){
2980 displaytext[0][j]=displaytext[0][j+1];
2982 displaytext[0][255]=' ';
2986 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
2989 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
2992 if(i==MAC_RETURN_KEY&&entername){
2993 if(displaychars[0]){
2995 strcpy(accountname[numaccounts-1],displaytext[0]);
2996 accountactive=numaccounts-1;
2997 accountdifficulty[accountactive]=1;
2998 accountprogress[accountactive]=0;
2999 accountpoints[accountactive]=0;
3000 accountcampaigntime[accountactive]=0;
3001 accountcampaignscore[accountactive]=0;
3002 accountcampaignfasttime[accountactive]=0;
3003 accountcampaignhighscore[accountactive]=0;
3005 accounthighscore[accountactive][j]=0;
3006 accountfasttime[accountactive][j]=0;
3009 accountunlocked[accountactive][j]=0;
3011 accountcampaignchoicesmade[accountactive]=0;
3014 displaytext[0][j]=' ';
3028 float gLoc[3]={0,0,0};
3029 float vel[3]={0,0,0};
3030 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3031 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3032 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3033 OPENAL_SetVolume(channels[firestartsound], 256);
3034 OPENAL_SetPaused(channels[firestartsound], false);
3035 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3038 displaytext[0][j]=' ';
3046 if(i==MAC_RETURN_KEY&&mainmenu==13){
3047 if(displaychars[0]){
3048 sprintf (registrationname, "%s", displaytext[0]);
3049 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3059 float gLoc[3]={0,0,0};
3060 float vel[3]={0,0,0};
3061 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3062 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3063 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3064 OPENAL_SetVolume(channels[firestartsound], 256);
3065 OPENAL_SetPaused(channels[firestartsound], false);
3066 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3069 displaytext[0][j]=' ';
3080 togglekeydelay[i]=0;
3084 displayblinkdelay-=multiplier;
3085 if(displayblinkdelay<=0){
3086 displayblinkdelay=.3;
3087 displayblink=1-displayblink;
3093 if(hostile==1)hostiletime+=multiplier;
3095 if(!winfreeze)leveltime+=multiplier;
3096 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3103 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3105 chattogglekeydown=1;
3106 togglekey[chatkey]=1;
3107 togglekeydelay[chatkey]=-20;
3110 if(!IsKeyDown(theKeyMap, chatkey)){
3111 chattogglekeydown=0;
3116 if(IsKeyDown(theKeyMap, i)){
3117 togglekeydelay[i]+=multiplier;
3118 if(togglekeydelay[i]>.4){
3120 togglekeydelay[i]=.36;
3123 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3124 for(j=255;j>=displayselected+1;j--){
3125 displaytext[0][j]=displaytext[0][j-1];
3127 displaytext[0][displayselected]=KeyToSingleChar(i);
3128 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3132 if(i==MAC_DELETE_KEY&&displayselected!=0){
3133 for(j=displayselected-1;j<255;j++){
3134 displaytext[0][j]=displaytext[0][j+1];
3136 displaytext[0][255]=' ';
3140 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3143 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3146 if(i==MAC_RETURN_KEY){
3147 if(displaychars[0]){
3148 /*for(j=0;j<displaychars[0];j++){
3149 talkname[j]=displaytext[0][j];
3151 talkname[displaychars[0]]='\0';
3152 sprintf (chatname, "%s: %s",playerName,talkname);
3153 //NetworkSendInformation(chatname);
3156 displaytext[0][j]=' ';
3168 togglekeydelay[i]=0;
3172 displayblinkdelay-=multiplier;
3173 if(displayblinkdelay<=0){
3174 displayblinkdelay=.3;
3175 displayblink=1-displayblink;
3179 if(chatting)keyboardfrozen=1;
3181 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3184 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3186 freezetogglekeydown=1;
3189 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3190 freezetogglekeydown=0;
3193 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3195 if(!console)freeze=0;
3197 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3199 consoletogglekeydown=1;
3202 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3203 consoletogglekeydown=0;
3206 if(console)freeze=1;
3208 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3210 if(IsKeyDown(theKeyMap, i)){
3211 togglekeydelay[i]+=multiplier;
3212 if(togglekeydelay[i]>.4){
3214 togglekeydelay[i]=.36;
3217 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3218 for(j=255;j>=consoleselected+1;j--){
3219 consoletext[0][j]=consoletext[0][j-1];
3221 consoletext[0][consoleselected]=KeyToSingleChar(i);
3222 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3226 else if(i==MAC_ENTER_KEY){
3227 for(j=255;j>=consoleselected+1;j--){
3228 consoletext[0][j]=consoletext[0][j-1];
3230 consoletext[0][consoleselected]='\n';
3234 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3235 for(j=consoleselected-1;j<255;j++){
3236 consoletext[0][j]=consoletext[0][j+1];
3238 consoletext[0][255]=' ';
3242 if(i==MAC_ARROW_UP_KEY){
3243 if(archiveselected<14)archiveselected++;
3245 consolechars[0]=consolechars[archiveselected];
3246 consoletext[0][j]=consoletext[archiveselected][j];
3247 consoleselected=consolechars[0];
3250 if(i==MAC_ARROW_DOWN_KEY){
3251 if(archiveselected>0)archiveselected--;
3253 consolechars[0]=consolechars[archiveselected];
3254 consoletext[0][j]=consoletext[archiveselected][j];
3255 consoleselected=consolechars[0];
3258 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3261 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3264 if(i==MAC_RETURN_KEY){
3267 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3268 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3269 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3270 OPENAL_SetPaused(channels[consolesuccesssound], false);
3274 /*if(Compare(consoletext[0],"send ",0,4)){
3275 for(j=5;j<consolechars[0];j++){
3276 talkname[j-5]=consoletext[0][j];
3278 talkname[consolechars[0]-5]='\0';
3279 sprintf (chatname, "%s: %s",playerName,talkname);
3280 //NetworkSendInformation(chatname);
3283 if(Compare(consoletext[0],"name ",0,4)){
3285 numchars=consolechars[0]-5;
3286 if(numchars>32)numchars=32;
3287 for(j=5;j<numchars+5;j++){
3288 talkname[j-5]=consoletext[0][j];
3290 talkname[numchars]='\0';
3291 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3292 //NetworkSendInformation(chatname);
3293 sprintf (playerName, "%s",talkname);
3294 //NetworkSendName(playerName);
3297 if(Compare(consoletext[0],"map ",0,3)){
3309 for(j=4;j<consolechars[0];j++){
3310 mapname[j-4+11]=consoletext[0][j];
3312 mapname[consolechars[0]-4+11]='\0';
3318 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3320 unsigned char playerNameStr[32];
3321 char theIPAddress[256];
3323 NMUInt32 port = 25710;
3325 strcpy(playerName, "Client");
3326 GameC2PStr( playerName, playerNameStr );
3328 for(j=0;j<consolechars[0]-8;j++){
3329 theIPAddress[j]=consoletext[0][j+8];
3331 theIPAddress[consolechars[0]-8]='\0';
3333 sprintf( thePort, "%li", port );
3334 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3337 if(consolechars[0]>0){
3340 consoletext[k][j]=consoletext[k-1][j];
3342 consolechars[k]=consolechars[k-1];
3345 consoletext[0][j]=' ';
3347 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3348 else sprintf (consoletext[0], "Could not open connection");
3350 consolechars[0]=255;
3357 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3358 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3359 OPENAL_SetPaused(channels[consolesuccesssound], false);
3361 if(consolechars[0]>0){
3364 consoletext[k][j]=consoletext[k-1][j];
3366 consolechars[k]=consolechars[k-1];
3369 consoletext[0][j]=' ';
3371 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3373 consolechars[0]=255;
3379 if(Compare(consoletext[0],"host ",0,4)){
3380 unsigned char gameNameStr[32], playerNameStr[32];
3381 char gameName[32];//, playerName[32];
3389 strcpy(gameName, "Host's game");
3390 strcpy(playerName, "Host");
3391 GameC2PStr( gameName, gameNameStr );
3392 GameC2PStr( playerName, playerNameStr );
3394 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3397 if(consolechars[0]>0){
3400 consoletext[k][j]=consoletext[k-1][j];
3402 consolechars[k]=consolechars[k-1];
3405 consoletext[0][j]=' ';
3407 sprintf (consoletext[0], "Error #%d!!!",v);
3409 consolechars[0]=255;
3416 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3417 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3418 OPENAL_SetPaused(channels[consolesuccesssound], false);
3420 if(consolechars[0]>0){
3423 consoletext[k][j]=consoletext[k-1][j];
3425 consolechars[k]=consolechars[k-1];
3428 consoletext[0][j]=' ';
3430 sprintf (consoletext[0], "Game hosted");
3432 consolechars[0]=255;
3438 if(Compare(consoletext[0],"save ",0,4)){
3450 for(j=5;j<consolechars[0];j++){
3451 mapname[j-5+11]=consoletext[0][j];
3453 mapname[consolechars[0]-5+11]='\0';
3455 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3456 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3457 OPENAL_SetPaused(channels[consolesuccesssound], false);
3464 tfile=fopen( mapname, "wb" );
3465 fpackf(tfile, "Bi", mapvers);
3466 //fpackf(tfile, "Bi", indemo);
3467 fpackf(tfile, "Bi", maptype);
3468 fpackf(tfile, "Bi", hostile);
3469 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3470 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3471 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3472 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);
3473 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3474 for(j=0;j<player[0].num_weapons;j++){
3475 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3478 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3479 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3480 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3481 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3483 fpackf(tfile, "Bi", player[0].numclothes);
3485 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3487 fpackf(tfile, "Bi", numdialogues);
3489 for(k=0;k<numdialogues;k++){
3490 fpackf(tfile, "Bi", numdialogueboxes[k]);
3491 fpackf(tfile, "Bi", dialoguetype[k]);
3493 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3494 fpackf(tfile, "Bf", participantrotation[k][l]);
3496 if(numdialogueboxes)
3497 for(l=0;l<numdialogueboxes[k];l++){
3498 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3499 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3500 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3501 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3502 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3504 templength=strlen(dialoguetext[k][l]);
3505 fpackf(tfile, "Bi",(templength));
3506 for(m=0;m<templength;m++){
3507 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3508 if(dialoguetext[k][l][m]=='\0')break;
3511 templength=strlen(dialoguename[k][l]);
3512 fpackf(tfile, "Bi",templength);
3513 for(m=0;m<templength;m++){
3514 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3515 if(dialoguename[k][l][m]=='\0')break;
3518 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3519 fpackf(tfile, "Bi", participantfocus[k][l]);
3520 fpackf(tfile, "Bi", participantaction[k][l]);
3523 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3525 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3529 if(player[0].numclothes)
3530 for(k=0;k<player[0].numclothes;k++){
3531 templength=strlen(player[0].clothes[k]);
3532 fpackf(tfile, "Bi", templength);
3533 for(l=0;l<templength;l++)
3534 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3535 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3538 fpackf(tfile, "Bi", environment);
3540 fpackf(tfile, "Bi", objects.numobjects);
3542 if(objects.numobjects)
3543 for(k=0;k<objects.numobjects;k++){
3544 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]);
3547 fpackf(tfile, "Bi", numhotspots);
3549 for(i=0;i<numhotspots;i++){
3550 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3551 templength=strlen(hotspottext[i]);
3552 fpackf(tfile, "Bi",templength);
3553 for(l=0;l<templength;l++)
3554 fpackf(tfile, "Bb", hotspottext[i][l]);
3557 fpackf(tfile, "Bi", numplayers);
3558 if(numplayers>1&&numplayers<maxplayers)
3559 for(j=1;j<numplayers;j++){
3560 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);
3561 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3562 for(k=0;k<player[j].num_weapons;k++){
3563 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3565 if(player[j].numwaypoints<30){
3566 fpackf(tfile, "Bi", player[j].numwaypoints);
3567 for(k=0;k<player[j].numwaypoints;k++){
3568 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3569 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3570 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3571 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3573 fpackf(tfile, "Bi", player[j].waypoint);
3576 player[j].numwaypoints=0;
3577 player[j].waypoint=0;
3578 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3581 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3582 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3583 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3584 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3586 if(player[j].creature==wolftype){
3587 headprop=player[j].proportionhead.x/1.1;
3588 bodyprop=player[j].proportionbody.x/1.1;
3589 armprop=player[j].proportionarms.x/1.1;
3590 legprop=player[j].proportionlegs.x/1.1;
3593 if(player[j].creature==rabbittype){
3594 headprop=player[j].proportionhead.x/1.2;
3595 bodyprop=player[j].proportionbody.x/1.05;
3596 armprop=player[j].proportionarms.x/1.00;
3597 legprop=player[j].proportionlegs.x/1.1;
3600 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3604 fpackf(tfile, "Bi", player[j].numclothes);
3605 if(player[j].numclothes)
3606 for(k=0;k<player[j].numclothes;k++){
3608 templength=strlen(player[j].clothes[k]);
3609 fpackf(tfile, "Bi", templength);
3610 for(l=0;l<templength;l++)
3611 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3612 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3616 fpackf(tfile, "Bi", numpathpoints);
3618 for(j=0;j<numpathpoints;j++){
3619 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3620 for(k=0;k<numpathpointconnect[j];k++){
3621 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3625 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3633 tfile=fopen( mapname, "wb" );
3634 fwrite( &mapvers, 1, sizeof(int), tfile );
3635 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3636 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3637 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3638 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3639 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3640 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3641 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3642 for(j=0;j<player[0].num_weapons;j++){
3643 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3646 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3647 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3648 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3649 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3650 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3651 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3652 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3653 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3654 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3655 fwrite( &player[0].power, 1, sizeof(int), tfile );
3656 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3658 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3659 if(player[0].numclothes)
3660 for(k=0;k<player[0].numclothes;k++){
3662 templength=strlen(player[0].clothes[k]);
3663 fwrite( &templength,1,sizeof(int),tfile);
3664 for(l=0;l<templength;l++)
3665 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3666 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3667 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3668 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3671 fwrite( &environment, 1, sizeof(int), tfile );
3673 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3675 for(k=0;k<objects.numobjects;k++){
3676 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3677 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3678 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3679 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3680 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3681 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3682 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3685 fwrite( &numplayers, 1, sizeof(int), tfile );
3686 if(numplayers>1&&numplayers<maxplayers)
3687 for(j=1;j<numplayers;j++){
3688 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3689 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3690 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3691 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3692 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3693 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3694 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3695 for(k=0;k<player[j].num_weapons;k++){
3696 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3698 if(player[j].numwaypoints<30){
3699 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3700 for(k=0;k<player[j].numwaypoints;k++){
3701 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3702 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3703 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3705 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3706 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3709 player[j].numwaypoints=0;
3710 player[j].waypoint=0;
3711 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3712 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3713 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3715 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3716 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3717 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3718 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3719 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3720 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3721 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3722 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3723 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3724 fwrite( &player[j].power, 1, sizeof(int), tfile );
3725 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3727 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3728 if(player[j].numclothes)
3729 for(k=0;k<player[j].numclothes;k++){
3731 templength=strlen(player[j].clothes[k]);
3732 fwrite( &templength,1,sizeof(int),tfile);
3733 for(l=0;l<templength;l++)
3734 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3735 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3736 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3737 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3740 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3742 for(j=0;j<numpathpoints;j++){
3743 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3744 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3745 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3746 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3747 for(k=0;k<numpathpointconnect[j];k++){
3748 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3752 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3753 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3754 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3756 fwrite( &mapradius, 1, sizeof(float), tfile );
3762 if(Compare(consoletext[0],"save ",0,4)){
3774 for(j=5;j<consolechars[0];j++){
3775 mapname[j-5+11]=consoletext[0][j];
3777 mapname[consolechars[0]-5+11]='\0';
3779 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3780 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3781 OPENAL_SetPaused(channels[consolesuccesssound], false);
3784 tfile=fopen( mapname, "wb" );
3785 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
3786 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3787 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3788 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3789 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3790 for(j=0;j<player[0].num_weapons;j++){
3791 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3793 fwrite( &environment, 1, sizeof(int), tfile );
3795 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3796 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
3797 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
3798 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
3799 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
3801 fwrite( &numplayers, 1, sizeof(int), tfile );
3802 if(numplayers>1&&numplayers<maxplayers)
3803 for(j=1;j<numplayers;j++){
3804 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
3805 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3806 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3807 for(k=0;k<player[j].num_weapons;k++){
3808 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3810 if(player[j].numwaypoints<30){
3811 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3812 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
3813 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3814 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3817 player[j].numwaypoints=0;
3818 player[j].waypoint=0;
3819 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3820 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3821 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3824 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3826 for(j=0;j<numpathpoints;j++){
3827 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
3828 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3829 for(k=0;k<numpathpointconnect[j];k++){
3830 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3836 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
3837 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
3840 /*if(Compare(consoletext[0],"Pants ",0,5)){
3841 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
3842 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
3846 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
3847 for(j=6;j<consolechars[0];j++){
3848 mapname[j-6]=consoletext[0][j];
3851 tintr=atof(mapname);
3856 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
3857 for(j=6;j<consolechars[0];j++){
3858 mapname[j-6]=consoletext[0][j];
3861 player[0].speedmult=atof(mapname);
3866 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
3867 for(j=9;j<consolechars[0];j++){
3868 mapname[j-9]=consoletext[0][j];
3871 player[0].power=atof(mapname);
3876 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
3877 for(j=13;j<consolechars[0];j++){
3878 mapname[j-13]=consoletext[0][j];
3881 viewdistance=atof(mapname)*100;
3886 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
3887 for(j=10;j<consolechars[0];j++){
3888 mapname[j-10]=consoletext[0][j];
3891 fadestart=atof(mapname);
3896 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
3897 for(j=6;j<consolechars[0];j++){
3898 mapname[j-6]=consoletext[0][j];
3901 player[0].power=atof(mapname);
3906 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
3907 for(j=6;j<consolechars[0];j++){
3908 mapname[j-6]=consoletext[0][j];
3911 slomospeed=atof(mapname);
3918 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
3919 for(j=8;j<consolechars[0];j++){
3920 mapname[j-8]=consoletext[0][j];
3923 slomofreq=atoi(mapname);
3928 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
3929 for(j=5;j<consolechars[0];j++){
3930 mapname[j-5]=consoletext[0][j];
3933 player[0].scale=atof(mapname)*.2;
3938 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
3940 float closestdist=-1;
3943 for(i=1;i<numplayers;i++){
3944 distance=findDistancefast(&player[i].coords,&player[0].coords);
3945 if(closestdist==-1||distance<closestdist){
3946 closestdist=distance;
3951 for(j=9;j<consolechars[0];j++){
3952 mapname[j-9]=consoletext[0][j];
3955 player[closest].scale=atof(mapname)*.2;
3960 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
3965 float closestdist=-1;
3968 for(i=1;i<numplayers;i++){
3969 distance=findDistancefast(&player[i].coords,&player[0].coords);
3970 if(closestdist==-1||distance<closestdist){
3971 closestdist=distance;
3979 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3980 mapname[j-startpoint]=consoletext[0][j];
3982 if(consoletext[0][j]=='\0')alldone=1;
3984 mapname[j-startpoint]='\0';
3986 headprop=atof(mapname);
3990 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3991 mapname[j-startpoint]=consoletext[0][j];
3993 if(consoletext[0][j]=='\0')alldone=1;
3995 mapname[j-startpoint]='\0';
3997 bodyprop=atof(mapname);
4001 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4002 mapname[j-startpoint]=consoletext[0][j];
4004 if(consoletext[0][j]=='\0')alldone=1;
4006 mapname[j-startpoint]='\0';
4008 armprop=atof(mapname);
4012 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4013 mapname[j-startpoint]=consoletext[0][j];
4015 if(consoletext[0][j]=='\0')alldone=1;
4017 mapname[j-startpoint]='\0';
4019 legprop=atof(mapname);
4021 if(player[closest].creature==wolftype){
4022 player[closest].proportionhead=1.1*headprop;
4023 player[closest].proportionbody=1.1*bodyprop;
4024 player[closest].proportionarms=1.1*armprop;
4025 player[closest].proportionlegs=1.1*legprop;
4028 if(player[closest].creature==rabbittype){
4029 player[closest].proportionhead=1.2*headprop;
4030 player[closest].proportionbody=1.05*bodyprop;
4031 player[closest].proportionarms=1.00*armprop;
4032 player[closest].proportionlegs=1.1*legprop;
4033 player[closest].proportionlegs.y=1.05*legprop;
4040 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4041 for(i=1;i<numplayers;i++){
4042 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4048 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4049 for(j=9;j<consolechars[0];j++){
4050 mapname[j-9]=consoletext[0][j];
4053 tutoriallevel=atoi(mapname);
4059 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4060 for(j=6;j<consolechars[0];j++){
4061 mapname[j-6]=consoletext[0][j];
4064 tintg=atof(mapname);
4069 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4070 for(j=6;j<consolechars[0];j++){
4071 mapname[j-6]=consoletext[0][j];
4074 tintb=atof(mapname);
4079 if(Compare(consoletext[0],"hostile ",0,7)){
4080 for(j=8;j<consolechars[0];j++){
4081 mapname[j-8]=consoletext[0][j];
4084 hostile=atoi(mapname);
4090 if(Compare(consoletext[0],"type active ",0,11)){
4091 editoractive=typeactive;
4096 if(Compare(consoletext[0],"indemo ",0,6)){
4098 hotspot[numhotspots]=player[0].coords;
4099 hotspotsize[numhotspots]=0;
4100 hotspottype[numhotspots]=-111;
4102 strcpy(hotspottext[numhotspots],"mapname");
4108 if(Compare(consoletext[0],"notindemo ",0,9)){
4115 if(Compare(consoletext[0],"type sitting ",0,12)){
4116 editoractive=typesitting;
4121 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4122 editoractive=typesittingwall;
4127 if(Compare(consoletext[0],"type sleeping ",0,13)){
4128 editoractive=typesleeping;
4132 if(Compare(consoletext[0],"type dead1 ",0,10)){
4133 editoractive=typedead1;
4137 if(Compare(consoletext[0],"type dead2 ",0,10)){
4138 editoractive=typedead2;
4142 if(Compare(consoletext[0],"type dead3 ",0,10)){
4143 editoractive=typedead3;
4146 if(Compare(consoletext[0],"type dead4 ",0,10)){
4147 editoractive=typedead4;
4152 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4153 editorpathtype=wpkeepwalking;
4158 if(Compare(consoletext[0],"path pause ",0,10)){
4159 editorpathtype=wppause;
4164 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4165 maptype=mapkilleveryone;
4170 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4171 maptype=mapgosomewhere;
4176 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4177 maptype=mapkillsomeone;
4183 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4184 maptype=mapkillmost;
4190 if(Compare(consoletext[0],"hs ",0,2)){
4194 hotspot[numhotspots]=player[0].coords;
4199 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4200 mapname[j-startpoint]=consoletext[0][j];
4202 if(consoletext[0][j]=='\0')alldone=1;
4204 mapname[j-startpoint]='\0';
4206 hotspotsize[numhotspots]=atof(mapname);
4210 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4211 mapname[j-startpoint]=consoletext[0][j];
4213 if(consoletext[0][j]=='\0')alldone=1;
4215 mapname[j-startpoint]='\0';
4217 hotspottype[numhotspots]=atoi(mapname);
4221 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4222 mapname[j-startpoint]=consoletext[0][j];
4224 if(consoletext[0][j]=='\0')alldone=1;
4226 mapname[j-startpoint]='\n';
4227 mapname[j-startpoint+1]='\0';
4229 strcpy(hotspottext[numhotspots],mapname);
4236 if(Compare(consoletext[0],"dialogue ",0,8)){
4243 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4244 mapname[j-startpoint]=consoletext[0][j];
4246 if(consoletext[0][j]=='\0')alldone=1;
4248 mapname[j-startpoint]='\0';
4251 dialoguetype[numdialogues]=atoi(mapname);
4269 for(j=startpoint;j<consolechars[0];j++){
4270 mapname[j-startpoint+16]=consoletext[0][j];
4272 mapname[consolechars[0]-startpoint+16]='.';
4273 mapname[consolechars[0]-startpoint+17]='t';
4274 mapname[consolechars[0]-startpoint+18]='x';
4275 mapname[consolechars[0]-startpoint+19]='t';
4276 mapname[consolechars[0]-startpoint+20]='\0';
4278 for(j=0;j<max_dialoguelength;j++){
4280 dialoguetext[numdialogues][j][k]='\0';
4283 dialoguename[numdialogues][j][k]='\0';
4287 ifstream ipstream(ConvertFileName(mapname));
4288 ipstream.ignore(256,':');
4289 ipstream >> numdialogueboxes[numdialogues];
4290 for(i=0;i<numdialogueboxes[numdialogues];i++){
4291 ipstream.ignore(256,':');
4292 ipstream.ignore(256,':');
4293 ipstream.ignore(256,' ');
4294 ipstream >> dialogueboxlocation[numdialogues][i];
4295 ipstream.ignore(256,':');
4296 ipstream >> dialogueboxcolor[numdialogues][i][0];
4297 ipstream >> dialogueboxcolor[numdialogues][i][1];
4298 ipstream >> dialogueboxcolor[numdialogues][i][2];
4299 ipstream.ignore(256,':');
4300 ipstream.getline(dialoguename[numdialogues][i],64);
4301 ipstream.ignore(256,':');
4302 ipstream.ignore(256,' ');
4303 ipstream.getline(dialoguetext[numdialogues][i],128);
4305 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4307 ipstream.ignore(256,':');
4308 ipstream >> dialogueboxsound[numdialogues][i];
4311 for(i=0;i<numdialogueboxes[numdialogues];i++){
4312 for(j=0;j<numplayers;j++){
4313 participantfacing[numdialogues][i][j]=player[j].facing;
4320 whichdialogue=numdialogues;
4328 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4336 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4337 mapname[j-startpoint]=consoletext[0][j];
4339 if(consoletext[0][j]=='\0')alldone=1;
4341 mapname[j-startpoint]='\0';
4344 whichdi=atoi(mapname);
4362 for(j=startpoint;j<consolechars[0];j++){
4363 mapname[j-startpoint+16]=consoletext[0][j];
4365 mapname[consolechars[0]-startpoint+16]='.';
4366 mapname[consolechars[0]-startpoint+17]='t';
4367 mapname[consolechars[0]-startpoint+18]='x';
4368 mapname[consolechars[0]-startpoint+19]='t';
4369 mapname[consolechars[0]-startpoint+20]='\0';
4371 for(j=0;j<max_dialoguelength;j++){
4373 dialoguetext[whichdi][j][k]='\0';
4376 dialoguename[whichdi][j][k]='\0';
4380 ifstream ipstream(ConvertFileName(mapname));
4381 ipstream.ignore(256,':');
4382 ipstream >> numdialogueboxes[whichdi];
4383 for(i=0;i<numdialogueboxes[whichdi];i++){
4384 ipstream.ignore(256,':');
4385 ipstream.ignore(256,':');
4386 ipstream.ignore(256,' ');
4387 ipstream >> dialogueboxlocation[whichdi][i];
4388 ipstream.ignore(256,':');
4389 ipstream >> dialogueboxcolor[whichdi][i][0];
4390 ipstream >> dialogueboxcolor[whichdi][i][1];
4391 ipstream >> dialogueboxcolor[whichdi][i][2];
4392 ipstream.ignore(256,':');
4393 ipstream.getline(dialoguename[whichdi][i],64);
4394 ipstream.ignore(256,':');
4395 ipstream.ignore(256,' ');
4396 ipstream.getline(dialoguetext[whichdi][i],128);
4398 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4400 ipstream.ignore(256,':');
4401 ipstream >> dialogueboxsound[whichdi][i];
4409 if(Compare(consoletext[0],"fixtype ",0,7)){
4417 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4418 mapname[j-startpoint]=consoletext[0][j];
4420 if(consoletext[0][j]=='\0')alldone=1;
4422 mapname[j-startpoint]='\0';
4423 dialoguetype[0]=atoi(mapname);
4431 if(Compare(consoletext[0],"fixrotation ",0,11)){
4432 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4437 if(Compare(consoletext[0],"ddialogue ",0,9)){
4439 if(numdialogues<0)numdialogues=0;
4444 if(Compare(consoletext[0],"immobile ",0,8)){
4445 player[0].immobile=1;
4449 if(Compare(consoletext[0],"mobile ",0,6)){
4450 player[0].immobile=0;
4454 if(Compare(consoletext[0],"play ",0,4)){
4461 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4462 mapname[j-startpoint]=consoletext[0][j];
4464 if(consoletext[0][j]=='\0')alldone=1;
4466 mapname[j-startpoint]='\0';
4469 whichdialogue=atoi(mapname);
4471 if(numdialogues>whichdialogue){
4472 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4473 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4474 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4475 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4476 player[participantfocus[whichdialogue][i]].velocity=0;
4477 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4478 player[participantfocus[whichdialogue][i]].targetframe=0;
4486 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4490 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4491 temppos=temppos-viewer;
4492 Normalise(&temppos);
4502 whichsoundplay=rabbitchitter;
4503 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4504 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4505 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4506 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4507 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4508 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4509 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4510 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4511 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4512 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4513 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4514 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4515 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4516 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4517 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4518 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4519 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4520 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4521 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4522 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4523 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4524 OPENAL_SetVolume(channels[whichsoundplay], 256);
4525 OPENAL_SetPaused(channels[whichsoundplay], false);
4533 if(Compare(consoletext[0],"dhs ",0,3)){
4535 if(numhotspots<0)numhotspots=0;
4540 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4547 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4548 mapname[j-startpoint]=consoletext[0][j];
4550 if(consoletext[0][j]=='\0')alldone=1;
4552 mapname[j-startpoint]='\0';
4554 headprop=atof(mapname);
4558 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4559 mapname[j-startpoint]=consoletext[0][j];
4561 if(consoletext[0][j]=='\0')alldone=1;
4563 mapname[j-startpoint]='\0';
4565 bodyprop=atof(mapname);
4569 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4570 mapname[j-startpoint]=consoletext[0][j];
4572 if(consoletext[0][j]=='\0')alldone=1;
4574 mapname[j-startpoint]='\0';
4576 armprop=atof(mapname);
4580 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4581 mapname[j-startpoint]=consoletext[0][j];
4583 if(consoletext[0][j]=='\0')alldone=1;
4585 mapname[j-startpoint]='\0';
4587 legprop=atof(mapname);
4589 if(player[0].creature==wolftype){
4590 player[0].proportionhead=1.1*headprop;
4591 player[0].proportionbody=1.1*bodyprop;
4592 player[0].proportionarms=1.1*armprop;
4593 player[0].proportionlegs=1.1*legprop;
4596 if(player[0].creature==rabbittype){
4597 player[0].proportionhead=1.2*headprop;
4598 player[0].proportionbody=1.05*bodyprop;
4599 player[0].proportionarms=1.00*armprop;
4600 player[0].proportionlegs=1.1*legprop;
4601 player[0].proportionlegs.y=1.05*legprop;
4607 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4608 for(i=0;i<numplayers;i++){
4609 if(i>0)player[i].immobile=1;
4615 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4616 player[0].armorhead=1;
4617 player[0].armorhigh=1;
4618 player[0].armorlow=1;
4619 player[0].protectionhead=1;
4620 player[0].protectionhigh=1;
4621 player[0].protectionlow=1;
4622 player[0].metalhead=1;
4623 player[0].metalhigh=1;
4624 player[0].metallow=1;
4626 player[0].speedmult=1;
4629 if(player[0].creature==wolftype){
4630 player[0].proportionhead=1.1;
4631 player[0].proportionbody=1.1;
4632 player[0].proportionarms=1.1;
4633 player[0].proportionlegs=1.1;
4636 if(player[0].creature==rabbittype){
4637 player[0].proportionhead=1.2;
4638 player[0].proportionbody=1.05;
4639 player[0].proportionarms=1.00;
4640 player[0].proportionlegs=1.1;
4641 player[0].proportionlegs.y=1.05;
4644 player[0].numclothes=0;
4645 if(player[0].whichskin==0){
4646 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4648 else if(player[0].whichskin==1){
4649 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4651 else if(player[0].whichskin==2){
4652 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4654 else if(player[0].whichskin==3){
4655 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4657 else if(player[0].whichskin==4){
4658 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4660 else if(player[0].whichskin==5){
4661 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4663 else if(player[0].whichskin==6){
4664 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4666 else if(player[0].whichskin==7){
4667 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4669 else if(player[0].whichskin==8){
4670 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4672 else if(player[0].whichskin==9){
4673 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4676 editoractive=typeactive;
4677 player[0].immobile=0;
4684 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4690 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4691 mapname[j-startpoint]=consoletext[0][j];
4693 if(consoletext[0][j]=='\0')alldone=1;
4695 mapname[j-startpoint]='\0';
4697 tintr=atof(mapname);
4701 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4702 mapname[j-startpoint]=consoletext[0][j];
4704 if(consoletext[0][j]=='\0')alldone=1;
4706 mapname[j-startpoint]='\0';
4708 tintg=atof(mapname);
4712 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4713 mapname[j-startpoint]=consoletext[0][j];
4715 if(consoletext[0][j]=='\0')alldone=1;
4717 mapname[j-startpoint]='\0';
4719 tintb=atof(mapname);
4724 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4730 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4731 mapname[j-startpoint]=consoletext[0][j];
4733 if(consoletext[0][j]=='\0')alldone=1;
4735 mapname[j-startpoint]='\0';
4737 skyboxr=atof(mapname);
4741 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4742 mapname[j-startpoint]=consoletext[0][j];
4744 if(consoletext[0][j]=='\0')alldone=1;
4746 mapname[j-startpoint]='\0';
4748 skyboxg=atof(mapname);
4752 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4753 mapname[j-startpoint]=consoletext[0][j];
4755 if(consoletext[0][j]=='\0')alldone=1;
4757 mapname[j-startpoint]='\0';
4759 skyboxb=atof(mapname);
4761 skyboxlightr=skyboxr;
4762 skyboxlightg=skyboxg;
4763 skyboxlightb=skyboxb;
4767 //if(skyboxtexture){
4768 terrain.DoShadows();
4769 objects.DoShadows();
4771 else terrain.DoLighting();
4776 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
4782 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4783 mapname[j-startpoint]=consoletext[0][j];
4785 if(consoletext[0][j]=='\0')alldone=1;
4787 mapname[j-startpoint]='\0';
4789 skyboxlightr=atof(mapname);
4793 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4794 mapname[j-startpoint]=consoletext[0][j];
4796 if(consoletext[0][j]=='\0')alldone=1;
4798 mapname[j-startpoint]='\0';
4800 skyboxlightg=atof(mapname);
4804 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4805 mapname[j-startpoint]=consoletext[0][j];
4807 if(consoletext[0][j]=='\0')alldone=1;
4809 mapname[j-startpoint]='\0';
4811 skyboxlightb=atof(mapname);
4815 //if(skyboxtexture){
4816 terrain.DoShadows();
4817 objects.DoShadows();
4819 else terrain.DoLighting();
4824 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
4825 skyboxtexture=1-skyboxtexture;
4828 //if(skyboxtexture){
4829 terrain.DoShadows();
4830 objects.DoShadows();
4832 else terrain.DoLighting();
4837 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
4843 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4844 mapname[j-startpoint]=consoletext[0][j];
4846 if(consoletext[0][j]=='\0')alldone=1;
4848 mapname[j-startpoint]='\0';
4850 player[0].protectionhead=atof(mapname);
4854 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4855 mapname[j-startpoint]=consoletext[0][j];
4857 if(consoletext[0][j]=='\0')alldone=1;
4859 mapname[j-startpoint]='\0';
4861 player[0].protectionhigh=atof(mapname);
4865 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4866 mapname[j-startpoint]=consoletext[0][j];
4868 if(consoletext[0][j]=='\0')alldone=1;
4870 mapname[j-startpoint]='\0';
4872 player[0].protectionlow=atof(mapname);
4877 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
4883 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4884 mapname[j-startpoint]=consoletext[0][j];
4886 if(consoletext[0][j]=='\0')alldone=1;
4888 mapname[j-startpoint]='\0';
4890 player[0].armorhead=atof(mapname);
4894 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4895 mapname[j-startpoint]=consoletext[0][j];
4897 if(consoletext[0][j]=='\0')alldone=1;
4899 mapname[j-startpoint]='\0';
4901 player[0].armorhigh=atof(mapname);
4905 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4906 mapname[j-startpoint]=consoletext[0][j];
4908 if(consoletext[0][j]=='\0')alldone=1;
4910 mapname[j-startpoint]='\0';
4912 player[0].armorlow=atof(mapname);
4917 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
4918 for(i=0;i<numplayers;i++){
4919 player[i].protectionhead=1.0;
4920 player[i].protectionhigh=1.0;
4921 player[i].protectionlow=1.0;
4922 player[i].armorhead=1.0;
4923 player[i].armorhigh=1.0;
4924 player[i].armorlow=1.0;
4930 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
4932 float closestdist=-1;
4935 for(i=1;i<numplayers;i++){
4936 distance=findDistancefast(&player[i].coords,&player[0].coords);
4937 if(closestdist==-1||distance<closestdist){
4938 closestdist=distance;
4948 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4949 mapname[j-startpoint]=consoletext[0][j];
4951 if(consoletext[0][j]=='\0')alldone=1;
4953 mapname[j-startpoint]='\0';
4955 player[closest].protectionhead=atof(mapname);
4959 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4960 mapname[j-startpoint]=consoletext[0][j];
4962 if(consoletext[0][j]=='\0')alldone=1;
4964 mapname[j-startpoint]='\0';
4966 player[closest].protectionhigh=atof(mapname);
4970 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4971 mapname[j-startpoint]=consoletext[0][j];
4973 if(consoletext[0][j]=='\0')alldone=1;
4975 mapname[j-startpoint]='\0';
4977 player[closest].protectionlow=atof(mapname);
4982 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
4984 float closestdist=-1;
4987 for(i=1;i<numplayers;i++){
4988 distance=findDistancefast(&player[i].coords,&player[0].coords);
4989 if(closestdist==-1||distance<closestdist){
4990 closestdist=distance;
4999 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5000 mapname[j-startpoint]=consoletext[0][j];
5002 if(consoletext[0][j]=='\0')alldone=1;
5004 mapname[j-startpoint]='\0';
5006 player[closest].armorhead=atof(mapname);
5010 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5011 mapname[j-startpoint]=consoletext[0][j];
5013 if(consoletext[0][j]=='\0')alldone=1;
5015 mapname[j-startpoint]='\0';
5017 player[closest].armorhigh=atof(mapname);
5021 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5022 mapname[j-startpoint]=consoletext[0][j];
5024 if(consoletext[0][j]=='\0')alldone=1;
5026 mapname[j-startpoint]='\0';
5028 player[closest].armorlow=atof(mapname);
5034 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5040 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5041 mapname[j-startpoint]=consoletext[0][j];
5043 if(consoletext[0][j]=='\0')alldone=1;
5045 mapname[j-startpoint]='\0';
5047 player[0].metalhead=atof(mapname);
5051 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5052 mapname[j-startpoint]=consoletext[0][j];
5054 if(consoletext[0][j]=='\0')alldone=1;
5056 mapname[j-startpoint]='\0';
5058 player[0].metalhigh=atof(mapname);
5062 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5063 mapname[j-startpoint]=consoletext[0][j];
5065 if(consoletext[0][j]=='\0')alldone=1;
5068 mapname[j-startpoint]='\0';
5070 player[0].metallow=atof(mapname);
5075 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5077 float closestdist=-1;
5080 for(i=1;i<numplayers;i++){
5081 distance=findDistancefast(&player[i].coords,&player[0].coords);
5082 if(closestdist==-1||distance<closestdist){
5083 closestdist=distance;
5087 player[closest].numclothes=0;
5088 if(player[closest].whichskin==0){
5089 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5091 else if(player[closest].whichskin==1){
5092 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5094 else if(player[closest].whichskin==2){
5095 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5097 else if(player[closest].whichskin==3){
5098 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5100 else if(player[closest].whichskin==4){
5101 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5103 else if(player[closest].whichskin==5){
5104 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5106 else if(player[closest].whichskin==6){
5107 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5109 else if(player[closest].whichskin==7){
5110 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5112 else if(player[closest].whichskin==8){
5113 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5115 else if(player[closest].whichskin==9){
5116 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5122 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5125 player[closest].numclothes=0;
5126 if(player[closest].whichskin==0){
5127 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5129 else if(player[closest].whichskin==1){
5130 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5132 else if(player[closest].whichskin==2){
5133 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5135 else if(player[closest].whichskin==3){
5136 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5138 else if(player[closest].whichskin==4){
5139 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5141 else if(player[closest].whichskin==5){
5142 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5144 else if(player[closest].whichskin==6){
5145 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5147 else if(player[closest].whichskin==7){
5148 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5150 else if(player[closest].whichskin==8){
5151 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5153 else if(player[closest].whichskin==9){
5154 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5160 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5176 for(j=8;j<consolechars[0];j++){
5177 mapname[j-8+15]=consoletext[0][j];
5179 mapname[consolechars[0]-8+15]='.';
5180 mapname[consolechars[0]-8+16]='p';
5181 mapname[consolechars[0]-8+17]='n';
5182 mapname[consolechars[0]-8+18]='g';
5183 mapname[consolechars[0]-8+19]='\0';
5185 //:Data:Textures:Pants.png
5187 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5188 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5189 strcpy(player[0].clothes[player[0].numclothes],mapname);
5190 player[0].clothestintr[player[0].numclothes]=tintr;
5191 player[0].clothestintg[player[0].numclothes]=tintg;
5192 player[0].clothestintb[player[0].numclothes]=tintb;
5193 player[0].numclothes++;
5199 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5200 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5205 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5206 cellophane=1-cellophane;
5209 for(i=0;i<numplayers;i++){
5210 player[i].proportionhead.z=0;
5211 player[i].proportionbody.z=0;
5212 player[i].proportionarms.z=0;
5213 player[i].proportionlegs.z=0;
5218 for(i=0;i<numplayers;i++){
5219 player[i].proportionhead.z=player[i].proportionhead.x;
5220 player[i].proportionbody.z=player[i].proportionbody.x;
5221 player[i].proportionarms.z=player[i].proportionarms.x;
5222 player[i].proportionlegs.z=player[i].proportionlegs.x;
5229 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5245 for(j=12;j<consolechars[0];j++){
5246 mapname[j-12+15]=consoletext[0][j];
5248 mapname[consolechars[0]-12+15]='.';
5249 mapname[consolechars[0]-12+16]='p';
5250 mapname[consolechars[0]-12+17]='n';
5251 mapname[consolechars[0]-12+18]='g';
5252 mapname[consolechars[0]-12+19]='\0';
5254 //:Data:Textures:Pants.png
5256 float closestdist=-1;
5259 for(i=1;i<numplayers;i++){
5260 distance=findDistancefast(&player[i].coords,&player[0].coords);
5261 if(closestdist==-1||distance<closestdist){
5262 closestdist=distance;
5267 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5268 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5269 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5270 player[closest].clothestintr[player[closest].numclothes]=tintr;
5271 player[closest].clothestintg[player[closest].numclothes]=tintg;
5272 player[closest].clothestintb[player[closest].numclothes]=tintb;
5273 player[closest].numclothes++;
5279 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5280 player[0].skeleton.id=0;
5281 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);
5282 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5283 player[0].creature=rabbittype;
5286 player[0].proportionhead=1.2;
5287 player[0].proportionbody=1.05;
5288 player[0].proportionarms=1.00;
5289 player[0].proportionlegs=1.1;
5290 player[0].proportionlegs.y=1.05;
5291 player[0].headless=0;
5293 player[0].damagetolerance=200;
5297 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5298 player[0].skeleton.id=0;
5299 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);
5300 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5301 player[0].creature=wolftype;
5303 player[0].proportionhead=1.1;
5304 player[0].proportionbody=1.1;
5305 player[0].proportionarms=1.1;
5306 player[0].proportionlegs=1.1;
5307 player[0].proportionlegs.y=1.1;
5308 player[0].scale=.23;
5310 player[0].damagetolerance=300;
5314 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5315 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5318 if(Compare(consoletext[0],"rambo ",0,5)){
5319 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5322 if(Compare(consoletext[0],"david ",0,5)){
5323 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5326 if(Compare(consoletext[0],"wolf ",0,4)){
5327 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5330 if(Compare(consoletext[0],"darkwolf ",0,8)){
5331 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5334 if(Compare(consoletext[0],"snowwolf ",0,8)){
5335 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5338 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5339 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5342 if(Compare(consoletext[0],"white ",0,5)){
5343 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5346 if(Compare(consoletext[0],"brown ",0,5)){
5347 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5350 if(Compare(consoletext[0],"black ",0,5)){
5351 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5354 if(consolechars[0]>0){
5357 consoletext[k][j]=consoletext[k-1][j];
5359 consolechars[k]=consolechars[k-1];
5362 consoletext[0][j]=' ';
5368 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5369 OPENAL_SetVolume(channels[consolefailsound], 256);
5370 OPENAL_SetPaused(channels[consolefailsound], false);
5379 togglekeydelay[i]=0;
5383 consoleblinkdelay-=multiplier;
5384 if(consoleblinkdelay<=0){
5385 consoleblinkdelay=.3;
5386 consoleblink=1-consoleblink;
5390 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5393 if(newdetail>2)newdetail=detail;
5394 if(newdetail<0)newdetail=detail;
5395 if(newscreenwidth<0)newscreenwidth=screenwidth;
5396 if(newscreenheight<0)newscreenheight=screenheight;
5398 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5399 opstream << "Screenwidth:\n";
5400 opstream << newscreenwidth;
5401 opstream << "\nScreenheight:\n";
5402 opstream << newscreenheight;
5403 opstream << "\nMouse sensitivity:\n";
5404 opstream << usermousesensitivity;
5405 opstream << "\nBlur(0,1):\n";
5406 opstream << ismotionblur;
5407 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5408 opstream << newdetail;
5409 opstream << "\nFloating jump:\n";
5410 opstream << floatjump;
5411 opstream << "\nMouse jump:\n";
5412 opstream << mousejump;
5413 opstream << "\nAmbient sound:\n";
5414 opstream << ambientsound;
5415 opstream << "\nBlood (0,1,2):\n";
5416 opstream << bloodtoggle;
5417 opstream << "\nAuto slomo:\n";
5418 opstream << autoslomo;
5419 opstream << "\nFoliage:\n";
5420 opstream << foliage;
5421 opstream << "\nMusic:\n";
5422 opstream << musictoggle;
5423 opstream << "\nTrilinear:\n";
5424 opstream << trilinear;
5425 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5427 opstream << "\nInvert mouse:\n";
5428 opstream << invertmouse;
5429 opstream << "\nGamespeed:\n";
5430 if(oldgamespeed==0)oldgamespeed=1;
5431 opstream << oldgamespeed;
5432 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5433 opstream << difficulty;
5434 opstream << "\nDamage effects(blackout, doublevision):\n";
5435 opstream << damageeffects;
5436 opstream << "\nText:\n";
5437 opstream << texttoggle;
5438 opstream << "\nDebug:\n";
5439 opstream << debugmode;
5440 opstream << "\nVBL Sync:\n";
5441 opstream << vblsync;
5442 opstream << "\nShow Points:\n";
5443 opstream << showpoints;
5444 opstream << "\nAlways Blur:\n";
5445 opstream << alwaysblur;
5446 opstream << "\nImmediate mode (turn on on G5):\n";
5447 opstream << immediate;
5448 opstream << "\nVelocity blur:\n";
5449 opstream << velocityblur;
5450 opstream << "\nVolume:\n";
5452 opstream << "\nForward key:\n";
5453 opstream << KeyToChar(forwardkey);
5454 opstream << "\nBack key:\n";
5455 opstream << KeyToChar(backkey);
5456 opstream << "\nLeft key:\n";
5457 opstream << KeyToChar(leftkey);
5458 opstream << "\nRight key:\n";
5459 opstream << KeyToChar(rightkey);
5460 opstream << "\nJump key:\n";
5461 opstream << KeyToChar(jumpkey);
5462 opstream << "\nCrouch key:\n";
5463 opstream << KeyToChar(crouchkey);
5464 opstream << "\nDraw key:\n";
5465 opstream << KeyToChar(drawkey);
5466 opstream << "\nThrow key:\n";
5467 opstream << KeyToChar(throwkey);
5468 opstream << "\nAttack key:\n";
5469 opstream << KeyToChar(attackkey);
5470 opstream << "\nChat key:\n";
5471 opstream << KeyToChar(chatkey);
5476 static int oldwinfreeze;
5477 if(winfreeze&&!oldwinfreeze){
5478 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
5479 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5480 OPENAL_SetVolume(channels[consolesuccesssound], 256);
5481 OPENAL_SetPaused(channels[consolesuccesssound], false);
5483 if(winfreeze==0)oldwinfreeze=winfreeze;
5484 else oldwinfreeze++;
5486 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5487 if(winfreeze)winfreeze=0;
5490 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5496 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5499 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5501 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5503 static bool oldbuttondialogue;
5505 if(indialogue!=-1)talkdelay=1;
5506 talkdelay-=multiplier;
5509 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5510 for(i=0;i<numdialogues;i++){
5511 int realdialoguetype;
5513 if(dialoguetype[i]>49){
5514 realdialoguetype=dialoguetype[i]-50;
5517 else if(dialoguetype[i]>39){
5518 realdialoguetype=dialoguetype[i]-40;
5521 else if(dialoguetype[i]>29){
5522 realdialoguetype=dialoguetype[i]-30;
5525 else if(dialoguetype[i]>19){
5526 realdialoguetype=dialoguetype[i]-20;
5529 else if(dialoguetype[i]>9){
5530 realdialoguetype=dialoguetype[i]-10;
5534 realdialoguetype=dialoguetype[i];
5537 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5538 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5540 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5541 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5542 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5543 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5544 player[participantfocus[whichdialogue][j]].velocity=0;
5545 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5546 player[participantfocus[whichdialogue][j]].targetframe=0;
5551 dialoguegonethrough[i]++;
5552 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5553 static float gLoc[3];
5554 static float vel[3];
5556 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5557 temppos=temppos-viewer;
5558 Normalise(&temppos);
5563 gLoc[2]=temppos.z;vel[0]=0;
5567 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5568 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5569 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5570 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5571 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5572 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5573 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5574 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5575 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5576 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5577 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5578 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5579 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5580 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5581 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5582 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5583 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5584 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5585 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5586 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5587 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5588 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5589 OPENAL_SetVolume(channels[whichsoundplay], 256);
5590 OPENAL_SetPaused(channels[whichsoundplay], false);
5592 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5597 windvar+=multiplier;
5598 smoketex+=multiplier;
5599 tutorialstagetime+=multiplier;
5601 static float hotspotvisual[40];
5605 for(i=0;i<numhotspots;i++)
5606 hotspotvisual[i]-=multiplier/320;
5608 for(i=0;i<numhotspots;i++){
5609 //if(hotspottype[i]<=10)
5610 while(hotspotvisual[i]<0){
5612 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5613 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5614 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5615 hotspotsprite+=hotspot[i];
5616 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5617 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5621 for(i=0;i<numhotspots;i++){
5622 if(hotspottype[i]<=10&&hotspottype[i]>0){
5623 hotspot[i]=player[hotspottype[i]].coords;
5629 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5632 if(tutorialstage<=1){
5637 if(tutorialstage==1){
5640 if(tutorialstage==2){
5643 if(tutorialstage==3){
5644 tutorialmaxtime=600;
5646 if(tutorialstage==4){
5647 tutorialmaxtime=1000;
5649 if(tutorialstage==5){
5650 tutorialmaxtime=600;
5652 if(tutorialstage==6){
5653 tutorialmaxtime=600;
5655 if(tutorialstage==7){
5656 tutorialmaxtime=600;
5658 if(tutorialstage==8){
5659 tutorialmaxtime=600;
5661 if(tutorialstage==9){
5662 tutorialmaxtime=600;
5664 if(tutorialstage==10){
5667 if(tutorialstage==11){
5668 tutorialmaxtime=1000;
5670 if(tutorialstage==12){
5671 tutorialmaxtime=1000;
5673 if(tutorialstage==13){
5676 if(tutorialstage==14){
5688 player[1].coords=(temp+temp2)/2;
5692 gLoc[0]=player[1].coords.x;
5693 gLoc[1]=player[1].coords.y;
5694 gLoc[2]=player[1].coords.z;
5698 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5699 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5700 OPENAL_SetVolume(channels[fireendsound], 256);
5701 OPENAL_SetPaused(channels[fireendsound], false);
5703 for(i=0;i<player[1].skeleton.num_joints;i++){
5705 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5706 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5707 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;
5708 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5709 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5714 if(tutorialstage==15){
5715 tutorialmaxtime=500;
5717 if(tutorialstage==16){
5718 tutorialmaxtime=500;
5720 if(tutorialstage==17){
5721 tutorialmaxtime=500;
5723 if(tutorialstage==18){
5724 tutorialmaxtime=500;
5726 if(tutorialstage==19){
5728 //tutorialmaxtime=500;
5730 if(tutorialstage==20){
5731 tutorialmaxtime=500;
5733 if(tutorialstage==21){
5734 tutorialmaxtime=500;
5741 if(tutorialstage==22){
5742 tutorialmaxtime=500;
5744 if(tutorialstage==23){
5745 tutorialmaxtime=500;
5747 if(tutorialstage==24){
5748 tutorialmaxtime=500;
5750 if(tutorialstage==25){
5751 tutorialmaxtime=500;
5753 if(tutorialstage==26){
5756 if(tutorialstage==27){
5760 player[1].aitype=attacktypecutoff;
5762 if(tutorialstage==28){
5763 tutorialmaxtime=400;
5765 if(tutorialstage==29){
5766 tutorialmaxtime=400;
5767 player[0].escapednum=0;
5769 if(tutorialstage==30){
5773 player[1].aitype=passivetype;
5775 if(tutorialstage==31){
5778 if(tutorialstage==32){
5781 if(tutorialstage==33){
5782 tutorialmaxtime=400;
5785 player[1].aitype=attacktypecutoff;
5787 if(tutorialstage==34){
5788 tutorialmaxtime=400;
5790 if(tutorialstage==35){
5791 tutorialmaxtime=400;
5793 if(tutorialstage==36){
5797 player[1].aitype=passivetype;
5799 if(tutorialstage==37){
5805 player[1].aitype=attacktypecutoff;
5807 if(tutorialstage==38){
5811 player[1].aitype=passivetype;
5813 if(tutorialstage==39){
5824 weapons.owner[weapons.numweapons]=-1;
5825 weapons.type[weapons.numweapons]=knife;
5826 weapons.damage[weapons.numweapons]=0;
5827 weapons.mass[weapons.numweapons]=1;
5828 weapons.tipmass[weapons.numweapons]=1.2;
5829 weapons.length[weapons.numweapons]=.25;
5830 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5831 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5833 weapons.velocity[weapons.numweapons]=0.1;
5834 weapons.tipvelocity[weapons.numweapons]=0.1;
5835 weapons.missed[weapons.numweapons]=1;
5836 weapons.hitsomething[weapons.numweapons]=0;
5837 weapons.freetime[weapons.numweapons]=0;
5838 weapons.firstfree[weapons.numweapons]=1;
5839 weapons.physics[weapons.numweapons]=1;
5841 weapons.numweapons++;
5843 if(tutorialstage==40){
5844 tutorialmaxtime=300;
5846 if(tutorialstage==41){
5847 tutorialmaxtime=300;
5849 if(tutorialstage==42){
5852 if(tutorialstage==43){
5853 tutorialmaxtime=300;
5855 if(tutorialstage==44){
5857 player[0].weaponactive=-1;
5858 player[0].num_weapons=0;
5859 player[1].weaponactive=0;
5860 player[1].num_weapons=1;
5861 player[1].weaponids[0]=0;
5865 player[1].aitype=attacktypecutoff;
5867 tutorialmaxtime=300;
5869 if(tutorialstage==45){
5871 player[0].weaponactive=-1;
5872 player[0].num_weapons=0;
5873 player[1].weaponactive=0;
5874 player[1].num_weapons=1;
5875 player[1].weaponids[0]=0;
5877 tutorialmaxtime=300;
5879 if(tutorialstage==46){
5881 player[0].weaponactive=-1;
5882 player[0].num_weapons=0;
5883 player[1].weaponactive=0;
5884 player[1].num_weapons=1;
5885 player[1].weaponids[0]=0;
5887 weapons.type[0]=sword;
5889 tutorialmaxtime=300;
5892 if(tutorialstage==47){
5904 weapons.owner[weapons.numweapons]=-1;
5905 weapons.type[weapons.numweapons]=sword;
5906 weapons.damage[weapons.numweapons]=0;
5907 weapons.mass[weapons.numweapons]=1;
5908 weapons.tipmass[weapons.numweapons]=1.2;
5909 weapons.length[weapons.numweapons]=.25;
5910 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5911 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5913 weapons.velocity[weapons.numweapons]=0.1;
5914 weapons.tipvelocity[weapons.numweapons]=0.1;
5915 weapons.missed[weapons.numweapons]=1;
5916 weapons.hitsomething[weapons.numweapons]=0;
5917 weapons.freetime[weapons.numweapons]=0;
5918 weapons.firstfree[weapons.numweapons]=1;
5919 weapons.physics[weapons.numweapons]=1;
5923 player[0].weaponactive=0;
5924 player[0].num_weapons=1;
5925 player[0].weaponids[0]=1;
5926 player[1].weaponactive=0;
5927 player[1].num_weapons=1;
5928 player[1].weaponids[0]=0;
5930 weapons.numweapons++;
5932 if(tutorialstage==48){
5935 player[1].aitype=passivetype;
5941 player[0].weaponactive=0;
5942 player[0].num_weapons=1;
5943 player[0].weaponids[0]=1;
5944 player[1].weaponactive=0;
5945 player[1].num_weapons=1;
5946 player[1].weaponids[0]=0;
5948 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
5949 else weapons.type[0]=staff;
5951 weapons.numweapons++;
5953 if(tutorialstage==49){
5956 player[1].aitype=passivetype;
5958 tutorialmaxtime=200;
5960 weapons.position[1]=1000;
5961 weapons.tippoint[1]=1000;
5963 weapons.numweapons=1;
5965 player[1].weaponactive=-1;
5966 player[1].num_weapons=0;
5967 player[0].weaponactive=0;
5968 player[0].num_weapons=1;
5969 player[0].weaponids[0]=0;
5971 weapons.type[0]=knife;
5973 weapons.numweapons++;
5975 if(tutorialstage==50){
5981 gLoc[0]=player[1].coords.x;
5982 gLoc[1]=player[1].coords.y;
5983 gLoc[2]=player[1].coords.z;
5987 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5988 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5989 OPENAL_SetVolume(channels[fireendsound], 256);
5990 OPENAL_SetPaused(channels[fireendsound], false);
5992 for(i=0;i<player[1].skeleton.num_joints;i++){
5994 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5995 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5996 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;
5997 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5998 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6002 player[1].num_weapons=0;
6003 player[1].weaponstuck=-1;
6004 player[1].weaponactive=-1;
6006 weapons.numweapons=0;
6008 weapons.owner[0]=-1;
6009 weapons.velocity[0]=0.1;
6010 weapons.tipvelocity[0]=-0.1;
6011 weapons.missed[0]=1;
6012 weapons.hitsomething[0]=0;
6013 weapons.freetime[0]=0;
6014 weapons.firstfree[0]=1;
6015 weapons.physics[0]=1;
6017 if(tutorialstage==51){
6018 tutorialmaxtime=80000;
6020 if(tutorialstage<=51)tutorialstagetime=0;
6024 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6025 if(tutorialstage==3){
6026 if(deltah||deltav)tutorialsuccess+=multiplier;
6028 if(tutorialstage==4){
6029 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6031 if(tutorialstage==5){
6032 if(player[0].jumpkeydown)tutorialsuccess=1;
6034 if(tutorialstage==6){
6035 if(player[0].isCrouch())tutorialsuccess=1;
6037 if(tutorialstage==7){
6038 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6040 if(tutorialstage==8){
6041 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6043 if(tutorialstage==9){
6044 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6046 if(tutorialstage==11){
6047 if(player[0].isWallJump())tutorialsuccess=1;
6049 if(tutorialstage==12){
6050 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6052 if(tutorialstage==15){
6053 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6055 if(tutorialstage==16){
6056 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6058 if(tutorialstage==17){
6059 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6061 if(tutorialstage==18){
6062 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6064 if(tutorialstage==19){
6065 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6067 if(tutorialstage==20){
6068 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6070 if(tutorialstage==21){
6071 if(bonus==cannon)tutorialsuccess=1;
6073 if(tutorialstage==22){
6074 if(bonus==spinecrusher)tutorialsuccess=1;
6076 if(tutorialstage==23){
6077 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6079 if(tutorialstage==24){
6080 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6082 if(tutorialstage==25){
6083 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6085 if(tutorialstage==28){
6086 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6088 if(tutorialstage==29){
6089 if(player[0].escapednum==2){
6093 player[1].aitype=passivetype;
6096 if(tutorialstage==33){
6097 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6099 if(tutorialstage==34){
6100 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6102 if(tutorialstage==35){
6103 if(animation[player[0].targetanimation].attack==reversal){
6107 player[1].aitype=passivetype;
6110 if(tutorialstage==40){
6111 if(player[0].num_weapons>0)tutorialsuccess=1;
6113 if(tutorialstage==41){
6114 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6116 if(tutorialstage==43){
6117 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6119 if(tutorialstage==44){
6120 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6122 if(tutorialstage==45){
6123 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6125 if(tutorialstage==46){
6126 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6128 if(tutorialstage==49){
6129 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6131 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6134 if(tutorialstagetime==tutorialmaxtime-3){
6135 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6136 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6137 OPENAL_SetPaused(channels[consolesuccesssound], false);
6140 if(tutorialsuccess>=1){
6141 if(tutorialstage==34||tutorialstage==35)
6142 tutorialstagetime=tutorialmaxtime-1;
6147 if(tutorialstage<14||tutorialstage>=50){
6148 player[1].coords.y=300;
6149 player[1].velocity=0;
6153 if(tutoriallevel!=1){
6154 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6155 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6156 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6157 OPENAL_SetPaused(channels[consolesuccesssound], false);
6162 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6163 OPENAL_SetVolume(channels[fireendsound], 256);
6164 OPENAL_SetPaused(channels[fireendsound], false);
6167 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6168 else bonusnum[bonus]+=0.15;
6169 if(tutoriallevel)bonusvalue=0;
6170 bonusvalue/=bonusnum[bonus];
6171 bonustotal+=bonusvalue;
6173 bonustime+=multiplier;
6175 if(environment==snowyenvironment){
6176 precipdelay-=multiplier;
6177 while(precipdelay<0){
6179 if(!detail)precipdelay+=.04;
6180 XYZ footvel,footpoint;
6183 footpoint=viewer+viewerfacing*6;
6184 footpoint.y+=((float)abs(Random()%1200))/100-6;
6185 footpoint.x+=((float)abs(Random()%1200))/100-6;
6186 footpoint.z+=((float)abs(Random()%1200))/100-6;
6187 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6190 for(k=0;k<numplayers;k++){
6191 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6192 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6194 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){
6195 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6196 else if(player[k].rotation>player[k].targetrotation){
6197 player[k].rotation-=multiplier*player[k].turnspeed;
6199 else if(player[k].rotation<player[k].targetrotation){
6200 player[k].rotation+=multiplier*player[k].turnspeed;
6205 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))){
6206 player[k].turnspeed*=2;
6207 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6208 else if(player[k].rotation>player[k].targetrotation){
6209 player[k].rotation-=multiplier*player[k].turnspeed;
6211 else if(player[k].rotation<player[k].targetrotation){
6212 player[k].rotation+=multiplier*player[k].turnspeed;
6214 player[k].turnspeed/=2;
6217 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6218 player[k].turnspeed*=4;
6219 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6220 else if(player[k].rotation>player[k].targetrotation){
6221 player[k].rotation-=multiplier*player[k].turnspeed;
6223 else if(player[k].rotation<player[k].targetrotation){
6224 player[k].rotation+=multiplier*player[k].turnspeed;
6226 player[k].turnspeed/=4;
6229 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6230 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6232 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6233 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6236 if(player[k].collide<-.3)player[k].collide=-.3;
6237 if(player[k].collide>1)player[k].collide=1;
6238 player[k].collide-=multiplier*30;
6240 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6241 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6243 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6244 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6245 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6246 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6247 lowpoint=player[k].coords;
6248 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6249 else lowpoint.y+=1.3;
6250 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){
6251 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6253 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6254 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6256 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6257 flatfacing=lowpoint-player[k].coords;
6258 player[k].coords=lowpoint;
6259 player[k].coords.y-=1.3;
6260 player[k].collide=1;
6262 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6263 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6264 tempcoords1=lowpoint;
6265 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6266 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6268 player[k].targetanimation=walljumpleftanim;
6269 player[k].targetframe=0;
6272 gLoc[0]=player[k].coords.x;
6273 gLoc[1]=player[k].coords.y;
6274 gLoc[2]=player[k].coords.z;
6278 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6279 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6280 OPENAL_SetVolume(channels[movewhooshsound], 256);
6281 OPENAL_SetPaused(channels[movewhooshsound], false);
6282 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6284 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6285 player[k].rotation=-asin(0-lowpointtarget.x);
6286 player[k].rotation*=360/6.28;
6287 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6288 player[k].targetrotation=player[k].rotation;
6289 player[k].lowrotation=player[k].rotation;
6290 if(k==0)numwallflipped++;
6294 lowpoint=tempcoords1;
6295 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6296 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6297 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6299 player[k].targetanimation=walljumprightanim;
6300 player[k].targetframe=0;
6303 gLoc[0]=player[k].coords.x;
6304 gLoc[1]=player[k].coords.y;
6305 gLoc[2]=player[k].coords.z;
6309 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6310 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6311 OPENAL_SetVolume(channels[movewhooshsound], 256);
6312 OPENAL_SetPaused(channels[movewhooshsound], false);
6313 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6315 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6316 player[k].rotation=-asin(0-lowpointtarget.x);
6317 player[k].rotation*=360/6.28;
6318 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6319 player[k].targetrotation=player[k].rotation;
6320 player[k].lowrotation=player[k].rotation;
6321 if(k==0)numwallflipped++;
6325 lowpoint=tempcoords1;
6326 lowpointtarget=lowpoint+player[k].facing*2;
6327 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6328 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6330 player[k].targetanimation=walljumpbackanim;
6331 player[k].targetframe=0;
6334 gLoc[0]=player[k].coords.x;
6335 gLoc[1]=player[k].coords.y;
6336 gLoc[2]=player[k].coords.z;
6340 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6341 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6342 OPENAL_SetVolume(channels[movewhooshsound], 256);
6343 OPENAL_SetPaused(channels[movewhooshsound], false);
6344 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6346 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6347 player[k].rotation=-asin(0-lowpointtarget.x);
6348 player[k].rotation*=360/6.28;
6349 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6350 player[k].targetrotation=player[k].rotation;
6351 player[k].lowrotation=player[k].rotation;
6352 if(k==0)numwallflipped++;
6356 lowpoint=tempcoords1;
6357 lowpointtarget=lowpoint-player[k].facing*2;
6358 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6359 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6361 player[k].targetanimation=walljumpfrontanim;
6362 player[k].targetframe=0;
6365 gLoc[0]=player[k].coords.x;
6366 gLoc[1]=player[k].coords.y;
6367 gLoc[2]=player[k].coords.z;
6371 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6372 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6373 OPENAL_SetVolume(channels[movewhooshsound], 256);
6374 OPENAL_SetPaused(channels[movewhooshsound], false);
6375 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6377 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6378 player[k].rotation=-asin(0-lowpointtarget.x);
6379 player[k].rotation*=360/6.28;
6380 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6381 player[k].rotation+=180;
6382 player[k].targetrotation=player[k].rotation;
6383 player[k].lowrotation=player[k].rotation;
6384 if(k==0)numwallflipped++;
6392 else if(objects.type[i]==rocktype){
6393 lowpoint2=player[k].coords;
6394 lowpoint=player[k].coords;
6396 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6397 player[k].coords=colpoint;
6398 player[k].collide=1;
6401 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6402 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6404 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6406 player[k].targetframe=0;
6407 player[k].onterrain=1;
6409 if(player[k].id==0){
6410 OPENAL_SetPaused(channels[whooshsound], true);
6411 OPENAL_SetVolume(channels[whooshsound], 0);
6414 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6415 if(player[k].isFlip())player[k].jumppower=-4;
6416 player[k].targetanimation=player[k].getLanding();
6419 gLoc[0]=player[k].coords.x;
6420 gLoc[1]=player[k].coords.y;
6421 gLoc[2]=player[k].coords.z;
6422 vel[0]=player[k].velocity.x;
6423 vel[1]=player[k].velocity.y;
6424 vel[2]=player[k].velocity.z;
6425 PlaySoundEx( landsound, samp[landsound], NULL, true);
6426 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6427 OPENAL_SetVolume(channels[landsound], 128);
6428 OPENAL_SetPaused(channels[landsound], false);
6430 envsound[numenvsounds]=player[k].coords;
6431 envsoundvol[numenvsounds]=16;
6432 envsoundlife[numenvsounds]=.4;
6441 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6442 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6443 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6444 lowpoint=player[k].coords;
6446 if(objects.type[i]!=rocktype)
6447 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6448 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6449 player[k].coords=lowpoint;
6450 player[k].coords.y-=1.35;
6451 player[k].collide=1;
6453 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)){
6454 lowpoint=player[k].coords;
6455 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6456 lowpoint=player[k].coords;
6460 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6461 lowpointtarget=lowpoint+facing*1.4;
6462 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6464 lowpoint=player[k].coords;
6466 lowpointtarget=lowpoint+facing*1.4;
6468 lowpointtarget2=lowpointtarget;
6470 lowpointtarget3=lowpointtarget;
6472 lowpointtarget4=lowpointtarget;
6474 lowpointtarget5=lowpointtarget;
6476 lowpointtarget6=lowpointtarget;
6478 lowpointtarget7=lowpoint;
6480 lowpointtarget2.x+=.1;
6482 lowpointtarget3.z+=.1;
6484 lowpointtarget4.x-=.1;
6486 lowpointtarget5.z-=.1;
6488 lowpointtarget6.y+=45/13;
6489 lowpointtarget6+=facing*.6;
6490 lowpointtarget7.y+=90/13;
6491 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6492 if(objects.friction[i]>.5)
6495 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6496 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6497 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6498 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)
6500 lowpoint=player[k].coords;
6501 lowpoint.y+=(float)j/13;
6502 lowpointtarget=lowpoint+facing*1.4;
6503 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6507 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6510 if(j<=25&&player[k].targetanimation==jumpdownanim){
6513 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6514 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6515 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)*/){
6516 lowpoint=player[k].coords;
6517 lowpoint.y+=(float)j/13;
6518 lowpointtarget=lowpoint+facing*1.3;
6519 flatfacing=player[k].coords;
6520 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6521 player[k].coords.y=lowpointtarget.y-.07;
6522 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6524 if(j>10||!player[k].isRun()){
6525 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6526 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6530 gLoc[0]=player[k].coords.x;
6531 gLoc[1]=player[k].coords.y;
6532 gLoc[2]=player[k].coords.z;
6533 vel[0]=player[k].velocity.x;
6534 vel[1]=player[k].velocity.y;
6535 vel[2]=player[k].velocity.z;
6536 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6537 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6538 OPENAL_SetVolume(channels[jumpsound], 128);
6539 OPENAL_SetPaused(channels[jumpsound], false);
6541 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6542 player[k].rotation=-asin(0-lowpointtarget.x);
6543 player[k].rotation*=360/6.28;
6544 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6545 player[k].targetrotation=player[k].rotation;
6546 player[k].lowrotation=player[k].rotation;
6548 //player[k].velocity=lowpointtarget*.03;
6549 player[k].velocity=0;
6551 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6552 //player[k].currentanimation=climbanim;
6553 player[k].targetanimation=climbanim;
6554 player[k].jumppower=0;
6555 player[k].jumpclimb=1;
6557 player[k].transspeed=6;
6560 //player[k].currentframe=1;
6561 player[k].targetframe=1;
6563 //player[k].currentframe=0;
6564 player[k].targetframe=0;
6565 //player[k].currentanimation=hanganim;
6566 player[k].targetanimation=hanganim;
6567 player[k].jumppower=0;
6581 if(player[k].collide<=0){
6582 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()){
6583 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)){
6584 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6585 player[k].targetanimation=jumpdownanim;
6586 player[k].targetframe=0;
6591 gLoc[0]=player[k].coords.x;
6592 gLoc[1]=player[k].coords.y;
6593 gLoc[2]=player[k].coords.z;
6594 vel[0]=player[k].velocity.x;
6595 vel[1]=player[k].velocity.y;
6596 vel[2]=player[k].velocity.z;
6598 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6599 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6600 OPENAL_SetVolume(channels[whooshsound], 128);
6601 OPENAL_SetPaused(channels[whooshsound], false);
6604 player[k].velocity.y+=gravity;
6609 player[k].realoldcoords=player[k].coords;
6612 static XYZ oldviewer;
6615 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6616 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6617 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6618 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6619 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6620 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6621 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6622 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6626 player[0].forwardkeydown=0;
6627 player[0].leftkeydown=0;
6628 player[0].backkeydown=0;
6629 player[0].rightkeydown=0;
6630 player[0].jumpkeydown=0;
6631 player[0].crouchkeydown=0;
6632 player[0].drawkeydown=0;
6633 player[0].throwkeydown=0;
6636 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6639 static bool endkeydown;
6646 facing=DoRotation(facing,-rotation2,0,0);
6647 facing=DoRotation(facing,0,0-rotation,0);
6652 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6654 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6655 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6656 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6657 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6658 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6659 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6660 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)
6661 ||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)
6662 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6664 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6665 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6666 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6667 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6668 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6669 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6670 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6671 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6672 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6673 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6674 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6676 participantfocus[whichdialogue][indialogue]=whichend;
6677 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6678 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6681 participantfocus[whichdialogue][indialogue]=-1;
6683 if(player[participantfocus[whichdialogue][indialogue]].dead){
6688 dialoguecamera[whichdialogue][indialogue]=viewer;
6689 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6690 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6692 if(indialogue<numdialogueboxes[whichdialogue]){
6693 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6694 static float gLoc[3];
6695 static float vel[3];
6697 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6698 temppos=temppos-viewer;
6699 Normalise(&temppos);
6704 gLoc[2]=temppos.z;vel[0]=0;
6708 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6709 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6710 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6711 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6712 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6713 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6714 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6715 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6716 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6717 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6718 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6719 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6720 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6721 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6722 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6723 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6724 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6725 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6726 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6727 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6728 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6729 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6730 OPENAL_SetVolume(channels[whichsoundplay], 256);
6731 OPENAL_SetPaused(channels[whichsoundplay], false);
6735 for(j=0;j<numplayers;j++){
6736 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6741 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)
6742 ||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)
6745 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6746 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6747 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6748 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6749 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6750 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6751 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6752 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6753 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6754 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6755 participantfacing[whichdialogue][indialogue][whichend]=facing;
6757 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)
6758 &&!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)
6759 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6762 if(indialogue>=numdialogueboxes[whichdialogue]){
6769 OPENAL_SetPaused(channels[whooshsound], true);
6770 viewer=dialoguecamera[whichdialogue][indialogue];
6771 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
6772 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
6774 rotation=dialoguecamerarotation[whichdialogue][indialogue];
6775 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
6776 if(dialoguetime>0.5)
6777 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)
6778 ||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)
6779 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
6782 if(indialogue<numdialogueboxes[whichdialogue]){
6783 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6784 static float gLoc[3];
6785 static float vel[3];
6787 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6788 temppos=temppos-viewer;
6789 Normalise(&temppos);
6794 gLoc[2]=temppos.z;vel[0]=0;
6798 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6799 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6800 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6801 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6802 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6803 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6804 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6805 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6806 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6807 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6808 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6809 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6810 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6811 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6812 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6813 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6814 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6815 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6816 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6817 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6818 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
6819 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
6820 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6821 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6822 OPENAL_SetVolume(channels[whichsoundplay], 256);
6823 OPENAL_SetPaused(channels[whichsoundplay], false);
6825 if(dialogueboxsound[whichdialogue][indialogue]==-5){
6826 hotspot[numhotspots]=player[0].coords;
6827 hotspotsize[numhotspots]=10;
6828 hotspottype[numhotspots]=-1;
6832 if(dialogueboxsound[whichdialogue][indialogue]==-6){
6836 if(player[participantfocus[whichdialogue][indialogue]].dead){
6844 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)
6845 &&!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)
6846 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6849 if(indialogue>=numdialogueboxes[whichdialogue]){
6853 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
6856 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
6859 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
6861 for(i=1;i<numplayers;i++){
6862 player[i].aitype = attacktypecutoff;
6869 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
6870 else oldbuttondialogue=1;
6872 static float keyrefreshdelay=0,bigrefreshdelay=0;
6876 /*keyrefreshdelay-=multiplier;
6877 bigrefreshdelay-=multiplier;
6879 if(keyrefreshdelay<=0){
6880 static int concat[4];
6882 concat[0]=player[0].forwardkeydown;
6883 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
6884 concat[0]=concat[0]*2+player[0].rightkeydown;
6885 concat[0]=concat[0]*2+player[0].leftkeydown;
6886 concat[0]=concat[0]*2+player[0].backkeydown;
6887 concat[0]=concat[0]*2+player[0].jumpkeydown;
6888 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
6889 concat[0]=concat[0]*2+player[0].crouchkeydown;
6891 concat[1]=player[0].crouchtogglekeydown;
6892 concat[1]=concat[1]*2+player[0].drawkeydown;
6893 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
6894 concat[1]=concat[1]*2+player[0].throwkeydown;
6895 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
6896 concat[1]=concat[1]*2+player[0].attackkeydown;
6898 //concat[2]=(char)((int)(rotation/2)%180);
6900 //concat[3]=(char)((int)(rotation2/2)%180);
6902 chatname[0]=concat[0]-128;
6903 chatname[1]=concat[1]-128;
6904 //chatname[2]=concat[2]-128;
6905 //chatname[3]=concat[3]-128;
6907 memcpy(chatname+temppoint,&rotation,sizeof(float));
6908 temppoint+=sizeof(float);
6909 memcpy(chatname+temppoint,&rotation2,sizeof(float));
6910 temppoint+=sizeof(float);
6912 chatname[temppoint]='\0';
6914 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
6915 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
6916 //keyrefreshdelay=.01;
6917 keyrefreshdelay=.03;
6920 if(bigrefreshdelay<=0){
6923 memcpy(chatname+temppoint,&i,sizeof(int));
6924 temppoint+=sizeof(int);
6925 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
6926 temppoint+=sizeof(float);
6927 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
6928 temppoint+=sizeof(float);
6929 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
6930 temppoint+=sizeof(float);
6931 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
6932 temppoint+=sizeof(float);
6933 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
6934 temppoint+=sizeof(float);
6935 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
6936 temppoint+=sizeof(int);
6937 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
6938 temppoint+=sizeof(int);
6939 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
6940 temppoint+=sizeof(float);
6941 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
6942 temppoint+=sizeof(float);
6943 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
6944 temppoint+=sizeof(float);
6945 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
6946 temppoint+=sizeof(int);
6947 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
6948 temppoint+=sizeof(int);
6949 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
6950 temppoint+=sizeof(float);
6951 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
6952 temppoint+=sizeof(float);
6953 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
6954 temppoint+=sizeof(float);
6955 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
6956 temppoint+=sizeof(int);
6957 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
6958 temppoint+=sizeof(int);
6959 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
6960 temppoint+=sizeof(int);
6961 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
6962 temppoint+=sizeof(int);
6963 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
6964 temppoint+=sizeof(int);
6965 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
6966 temppoint+=sizeof(int);
6967 chatname[temppoint]='\0';
6969 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);
6970 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
6971 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
6973 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);
6975 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
6976 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
6978 //bigrefreshdelay=.02;
6983 if(!player[0].jumpkeydown){
6984 player[0].jumptogglekeydown=0;
6986 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
6989 dialoguetime+=multiplier;
6990 skybox.cloudmove+=multiplier;
6991 hawkrotation+=multiplier*25;
6993 realhawkcoords.x=25;
6994 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
6995 hawkcalldelay-=multiplier/2;
6997 if(hawkcalldelay<=0)
6999 static float gLoc[3];
7000 static float vel[3];
7001 gLoc[0]=realhawkcoords.x;
7002 gLoc[1]=realhawkcoords.y;
7003 gLoc[2]=realhawkcoords.z;
7007 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
7008 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
7009 OPENAL_SetVolume(channels[hawksound], 128);
7010 OPENAL_SetPaused(channels[hawksound], false);
7012 hawkcalldelay=16+abs(Random()%8);
7014 static float temptexdetail;
7017 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7018 player[0].damagetolerance=200000;
7021 player[0].permanentdamage=0;
7022 player[0].superpermanentdamage=0;
7025 whichchar = abs(Random()%7);
7026 registrationname[whichchar]+=1;
7030 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7032 if(environment>2)environment=0;
7033 Setenvironment(environment);
7039 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7043 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7044 cameramode=1-cameramode;
7045 cameratogglekeydown=1;
7048 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7049 cameratogglekeydown=0;
7052 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7053 if(player[0].num_weapons>0){
7054 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7055 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7056 else weapons.type[player[0].weaponids[0]]=sword;
7057 if(weapons.type[player[0].weaponids[0]]==sword){
7058 weapons.mass[player[0].weaponids[0]]=1.5;
7059 weapons.tipmass[player[0].weaponids[0]]=1;
7060 weapons.length[player[0].weaponids[0]]=.8;
7062 if(weapons.type[player[0].weaponids[0]]==staff){
7063 weapons.mass[player[0].weaponids[0]]=2;
7064 weapons.tipmass[player[0].weaponids[0]]=1;
7065 weapons.length[player[0].weaponids[0]]=1.5;
7068 if(weapons.type[player[0].weaponids[0]]==knife){
7069 weapons.mass[player[0].weaponids[0]]=1;
7070 weapons.tipmass[player[0].weaponids[0]]=1.2;
7071 weapons.length[player[0].weaponids[0]]=.25;
7075 /*for(i=0;i<objects.numobjects;i++){
7076 if(objects.type[i]==treeleavestype){
7077 for(j=0;j<objects.numobjects;j++){
7078 if(objects.type[j]==treetrunktype)
7079 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7080 objects.scale[i]=objects.scale[j];
7084 detailtogglekeydown=1;
7087 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7089 float closestdist=-1;
7092 for(i=1;i<numplayers;i++){
7093 distance=findDistancefast(&player[i].coords,&player[0].coords);
7094 if(closestdist==-1||distance<closestdist){
7095 closestdist=distance;
7100 if(player[closest].num_weapons)
7102 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7103 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7104 else weapons.type[player[closest].weaponids[0]]=sword;
7105 if(weapons.type[player[closest].weaponids[0]]==sword){
7106 weapons.mass[player[closest].weaponids[0]]=1.5;
7107 weapons.tipmass[player[closest].weaponids[0]]=1;
7108 weapons.length[player[closest].weaponids[0]]=.8;
7110 if(weapons.type[player[0].weaponids[0]]==staff){
7111 weapons.mass[player[0].weaponids[0]]=2;
7112 weapons.tipmass[player[0].weaponids[0]]=1;
7113 weapons.length[player[0].weaponids[0]]=1.5;
7115 if(weapons.type[player[closest].weaponids[0]]==knife){
7116 weapons.mass[player[closest].weaponids[0]]=1;
7117 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7118 weapons.length[player[closest].weaponids[0]]=.25;
7121 if(!player[closest].num_weapons)
7123 player[closest].weaponids[0]=weapons.numweapons;
7124 weapons.owner[weapons.numweapons]=closest;
7125 weapons.type[weapons.numweapons]=knife;
7126 weapons.damage[weapons.numweapons]=0;
7127 weapons.numweapons++;
7128 player[closest].num_weapons=1;
7129 if(weapons.type[player[closest].weaponids[0]]==sword){
7130 weapons.mass[player[closest].weaponids[0]]=1.5;
7131 weapons.tipmass[player[closest].weaponids[0]]=1;
7132 weapons.length[player[closest].weaponids[0]]=.8;
7134 if(weapons.type[player[closest].weaponids[0]]==knife){
7135 weapons.mass[player[closest].weaponids[0]]=1;
7136 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7137 weapons.length[player[closest].weaponids[0]]=.25;
7141 detailtogglekeydown=1;
7144 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7146 float closestdist=-1;
7149 for(i=1;i<numplayers;i++){
7150 distance=findDistancefast(&player[i].coords,&player[0].coords);
7151 if(closestdist==-1||distance<closestdist){
7152 closestdist=distance;
7157 player[closest].rotation+=multiplier*50;
7158 player[closest].targetrotation=player[closest].rotation;
7162 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7164 float closestdist=-1;
7167 for(i=1;i<numplayers;i++){
7168 distance=findDistancefast(&player[i].coords,&player[0].coords);
7169 if(closestdist==-1||distance<closestdist){
7170 closestdist=distance;
7174 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7177 player[closest].whichskin++;
7178 if(player[closest].whichskin>9)player[closest].whichskin=0;
7179 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7181 if(player[closest].creature==rabbittype){
7182 if(player[closest].whichskin==0){
7183 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7185 else if(player[closest].whichskin==1){
7186 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7188 else if(player[closest].whichskin==2){
7189 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7191 else if(player[closest].whichskin==3){
7192 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7194 else if(player[closest].whichskin==4){
7195 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7197 else if(player[closest].whichskin==5){
7198 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7200 else if(player[closest].whichskin==6){
7201 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7203 else if(player[closest].whichskin==7){
7204 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7206 else if(player[closest].whichskin==8){
7207 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7209 else if(player[closest].whichskin==9){
7210 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7213 if(player[closest].creature==wolftype){
7215 if(player[closest].whichskin==0){
7216 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7218 else if(player[closest].whichskin==1){
7219 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7221 else if(player[closest].whichskin==2){
7222 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7227 if(player[closest].numclothes){
7228 for(i=0;i<player[closest].numclothes;i++){
7229 tintr=player[closest].clothestintr[i];
7230 tintg=player[closest].clothestintg[i];
7231 tintb=player[closest].clothestintb[i];
7232 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7234 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7237 detailtogglekeydown=1;
7240 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7242 float closestdist=-1;
7245 for(i=1;i<numplayers;i++){
7246 distance=findDistancefast(&player[i].coords,&player[0].coords);
7247 if(closestdist==-1||distance<closestdist){
7248 closestdist=distance;
7253 if(player[closest].creature==wolftype){
7254 headprop=player[closest].proportionhead.x/1.1;
7255 bodyprop=player[closest].proportionbody.x/1.1;
7256 armprop=player[closest].proportionarms.x/1.1;
7257 legprop=player[closest].proportionlegs.x/1.1;
7260 if(player[closest].creature==rabbittype){
7261 headprop=player[closest].proportionhead.x/1.2;
7262 bodyprop=player[closest].proportionbody.x/1.05;
7263 armprop=player[closest].proportionarms.x/1.00;
7264 legprop=player[closest].proportionlegs.x/1.1;
7268 if(player[closest].creature==rabbittype){
7269 player[closest].skeleton.id=closest;
7270 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);
7271 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7272 player[closest].whichskin=0;
7273 player[closest].creature=wolftype;
7275 player[closest].proportionhead=1.1;
7276 player[closest].proportionbody=1.1;
7277 player[closest].proportionarms=1.1;
7278 player[closest].proportionlegs=1.1;
7279 player[closest].proportionlegs.y=1.1;
7280 player[closest].scale=.23*5*player[0].scale;
7282 player[closest].damagetolerance=300;
7286 player[closest].skeleton.id=closest;
7287 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);
7288 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7289 player[closest].whichskin=0;
7290 player[closest].creature=rabbittype;
7292 player[closest].proportionhead=1.2;
7293 player[closest].proportionbody=1.05;
7294 player[closest].proportionarms=1.00;
7295 player[closest].proportionlegs=1.1;
7296 player[closest].proportionlegs.y=1.05;
7297 player[closest].scale=.2*5*player[0].scale;
7299 player[closest].damagetolerance=200;
7302 if(player[closest].creature==wolftype){
7303 player[closest].proportionhead=1.1*headprop;
7304 player[closest].proportionbody=1.1*bodyprop;
7305 player[closest].proportionarms=1.1*armprop;
7306 player[closest].proportionlegs=1.1*legprop;
7309 if(player[closest].creature==rabbittype){
7310 player[closest].proportionhead=1.2*headprop;
7311 player[closest].proportionbody=1.05*bodyprop;
7312 player[closest].proportionarms=1.00*armprop;
7313 player[closest].proportionlegs=1.1*legprop;
7314 player[closest].proportionlegs.y=1.05*legprop;
7318 detailtogglekeydown=1;
7321 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7322 detailtogglekeydown=0;
7325 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7328 slomotogglekeydown=1;
7332 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7334 float closestdist=-1;
7336 XYZ flatfacing2,flatvelocity2;
7339 for(i=1;i<numplayers;i++){
7340 distance=findDistancefast(&player[i].coords,&player[0].coords);
7341 if(distance<144&&!player[i].headless)
7342 if(closestdist==-1||distance<closestdist){
7343 closestdist=distance;
7345 blah = player[i].coords;
7350 XYZ headspurtdirection;
7351 int i = player[closest].skeleton.jointlabels[head];
7352 for(k=0;k<player[closest].skeleton.num_joints; k++){
7353 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7354 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7355 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;
7356 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7357 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7358 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7359 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7360 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7361 Normalise(&headspurtdirection);
7362 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7363 flatvelocity2+=headspurtdirection*8;
7364 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7366 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7376 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7377 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7378 OPENAL_SetVolume(channels[splattersound], 256);
7379 OPENAL_SetPaused(channels[splattersound], false);
7381 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7382 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7383 OPENAL_SetVolume(channels[breaksound2], 100);
7384 OPENAL_SetPaused(channels[breaksound2], false);
7386 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7387 player[closest].RagDoll(0);
7388 player[closest].dead=2;
7389 player[closest].headless=1;
7390 player[closest].DoBloodBig(3,165);
7395 explodetogglekeydown=1;
7398 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7400 float closestdist=-1;
7402 XYZ flatfacing2,flatvelocity2;
7405 for(i=1;i<numplayers;i++){
7406 distance=findDistancefast(&player[i].coords,&player[0].coords);
7408 if(closestdist==-1||distance<closestdist){
7409 closestdist=distance;
7411 blah=player[i].coords;
7425 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7426 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7427 OPENAL_SetVolume(channels[splattersound], 256);
7428 OPENAL_SetPaused(channels[splattersound], false);
7430 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7431 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7432 OPENAL_SetVolume(channels[breaksound2], 600);
7433 OPENAL_SetPaused(channels[breaksound2], false);
7435 for(i=0;i<player[closest].skeleton.num_joints; i++){
7436 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7437 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7438 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;
7439 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7440 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7441 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7442 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7443 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7444 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7445 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7448 for(i=0;i<player[closest].skeleton.num_joints; i++){
7449 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7450 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7451 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;
7452 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7453 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7454 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7455 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7456 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7457 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7460 for(i=0;i<player[closest].skeleton.num_joints; i++){
7461 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7462 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7463 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;
7464 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7465 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7466 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7467 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7468 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7469 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7472 for(i=0;i<player[closest].skeleton.num_joints; i++){
7473 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7474 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7475 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;
7476 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7477 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7478 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7479 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7480 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7481 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7485 for(j=0;j<numplayers; j++){
7487 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7488 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7489 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7490 player[j].skeleton.longdead=0;
7491 player[j].RagDoll(0);
7492 for(i=0;i<player[j].skeleton.num_joints; i++){
7493 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7494 if(findDistancefast(&temppos,&player[closest].coords)<25){
7495 flatvelocity2=temppos-player[closest].coords;
7496 Normalise(&flatvelocity2);
7497 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7504 player[closest].DoDamage(10000);
7505 player[closest].RagDoll(0);
7506 player[closest].dead=2;
7507 player[closest].coords=20;
7508 player[closest].skeleton.free=2;
7514 explodetogglekeydown=1;
7517 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7518 explodetogglekeydown=0;
7522 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7524 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7525 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7526 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7527 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7528 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7529 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7530 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7532 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7533 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7534 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7535 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7536 for(j=0;j<player[0].num_weapons;j++){
7537 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7539 fwrite( &environment, 1, sizeof(int), tfile );
7541 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7542 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7543 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7544 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7545 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7547 fwrite( &numplayers, 1, sizeof(int), tfile );
7548 if(numplayers>1&&numplayers<maxplayers)
7549 for(i=1;i<numplayers;i++){
7550 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7551 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7552 for(j=0;j<player[i].num_weapons;j++){
7553 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7555 if(player[i].numwaypoints<30){
7556 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7557 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7558 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7559 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7562 player[i].numwaypoints=0;
7563 player[i].waypoint=0;
7564 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7565 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7566 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7572 slomotogglekeydown=1;
7575 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7576 slomotogglekeydown=0;
7580 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7581 player[0].onfire=1-player[0].onfire;
7582 if(player[0].onfire){
7583 player[0].CatchFire();
7585 if(!player[0].onfire){
7588 gLoc[0]=player[0].coords.x;
7589 gLoc[1]=player[0].coords.y;
7590 gLoc[2]=player[0].coords.z;
7594 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7595 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7596 OPENAL_SetVolume(channels[fireendsound], 256);
7597 OPENAL_SetPaused(channels[fireendsound], false);
7598 OPENAL_SetPaused(channels[stream_firesound], true);
7600 slomotogglekeydown=1;
7603 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7604 if(player[0].bleeding<=0)
7605 player[0].DoBlood(1,255);
7609 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7611 float closestdist=-1;
7614 for(i=1;i<numplayers;i++){
7615 distance=findDistancefast(&player[i].coords,&player[0].coords);
7616 if(closestdist==-1||distance<closestdist){
7617 closestdist=distance;
7621 if(closestdist>0&&closest>=0){
7622 //player[closest]=player[numplayers-1];
7623 //player[closest].skeleton=player[numplayers-1].skeleton;
7626 drawmodetogglekeydown=1;
7629 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7631 float closestdist=-1;
7634 for(i=1;i<max_objects;i++){
7635 distance=findDistancefast(&objects.position[i],&player[0].coords);
7636 if(closestdist==-1||distance<closestdist){
7637 closestdist=distance;
7641 if(closestdist>0&&closest>=0){
7642 objects.position[closest].y-=500;
7644 drawmodetogglekeydown=1;
7647 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7649 //if(drawmode>2)drawmode=0;
7650 if(objects.numobjects<max_objects-1){
7652 boxcoords.x=player[0].coords.x;
7653 boxcoords.z=player[0].coords.z;
7654 boxcoords.y=player[0].coords.y-3;
7655 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7656 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7657 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7658 float temprotat,temprotat2;
7659 temprotat=editorrotation;
7660 temprotat2=editorrotation2;
7661 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7662 if(temprotat2<0)temprotat2=Random()%360;
7664 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7665 if(editortype==treetrunktype)
7666 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7669 drawmodetogglekeydown=1;
7672 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7673 if(numplayers<maxplayers-1){
7674 player[numplayers].scale=.2*5*player[0].scale;
7675 player[numplayers].creature=rabbittype;
7676 player[numplayers].howactive=editoractive;
7677 player[numplayers].skeleton.id=numplayers;
7678 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);
7680 //texsize=512*512*3/texdetail/texdetail;
7681 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7682 //player[numplayers].skeleton.skinText.resize(texsize);
7684 k=abs(Random()%2)+1;
7686 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7687 player[numplayers].whichskin=0;
7690 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7691 player[numplayers].whichskin=1;
7694 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7695 player[numplayers].whichskin=2;
7698 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7699 player[numplayers].power=1;
7700 player[numplayers].speedmult=1;
7701 player[numplayers].currentanimation=bounceidleanim;
7702 player[numplayers].targetanimation=bounceidleanim;
7703 player[numplayers].currentframe=0;
7704 player[numplayers].targetframe=1;
7705 player[numplayers].target=0;
7706 player[numplayers].bled=0;
7707 player[numplayers].speed=1+(float)(Random()%100)/1000;
7709 player[numplayers].targetrotation=player[0].targetrotation;
7710 player[numplayers].rotation=player[0].rotation;
7712 player[numplayers].velocity=0;
7713 player[numplayers].coords=player[0].coords;
7714 player[numplayers].oldcoords=player[numplayers].coords;
7715 player[numplayers].realoldcoords=player[numplayers].coords;
7717 player[numplayers].id=numplayers;
7718 player[numplayers].skeleton.id=numplayers;
7719 player[numplayers].updatedelay=0;
7720 player[numplayers].normalsupdatedelay=0;
7722 player[numplayers].aitype=passivetype;
7723 player[numplayers].aitarget=0;
7725 if(player[0].creature==wolftype){
7726 headprop=player[0].proportionhead.x/1.1;
7727 bodyprop=player[0].proportionbody.x/1.1;
7728 armprop=player[0].proportionarms.x/1.1;
7729 legprop=player[0].proportionlegs.x/1.1;
7732 if(player[0].creature==rabbittype){
7733 headprop=player[0].proportionhead.x/1.2;
7734 bodyprop=player[0].proportionbody.x/1.05;
7735 armprop=player[0].proportionarms.x/1.00;
7736 legprop=player[0].proportionlegs.x/1.1;
7739 if(player[numplayers].creature==wolftype){
7740 player[numplayers].proportionhead=1.1*headprop;
7741 player[numplayers].proportionbody=1.1*bodyprop;
7742 player[numplayers].proportionarms=1.1*armprop;
7743 player[numplayers].proportionlegs=1.1*legprop;
7746 if(player[numplayers].creature==rabbittype){
7747 player[numplayers].proportionhead=1.2*headprop;
7748 player[numplayers].proportionbody=1.05*bodyprop;
7749 player[numplayers].proportionarms=1.00*armprop;
7750 player[numplayers].proportionlegs=1.1*legprop;
7751 player[numplayers].proportionlegs.y=1.05*legprop;
7754 player[numplayers].headless=0;
7755 player[numplayers].onfire=0;
7758 player[numplayers].proportionhead.z=0;
7759 player[numplayers].proportionbody.z=0;
7760 player[numplayers].proportionarms.z=0;
7761 player[numplayers].proportionlegs.z=0;
7764 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7766 player[numplayers].damagetolerance=200;
7768 player[numplayers].protectionhead=player[0].protectionhead;
7769 player[numplayers].protectionhigh=player[0].protectionhigh;
7770 player[numplayers].protectionlow=player[0].protectionlow;
7771 player[numplayers].armorhead=player[0].armorhead;
7772 player[numplayers].armorhigh=player[0].armorhigh;
7773 player[numplayers].armorlow=player[0].armorlow;
7774 player[numplayers].metalhead=player[0].metalhead;
7775 player[numplayers].metalhigh=player[0].metalhigh;
7776 player[numplayers].metallow=player[0].metallow;
7778 player[numplayers].immobile=player[0].immobile;
7780 player[numplayers].numclothes=player[0].numclothes;
7781 if(player[numplayers].numclothes)
7782 for(i=0;i<player[numplayers].numclothes;i++){
7783 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
7784 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
7785 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
7786 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
7787 tintr=player[numplayers].clothestintr[i];
7788 tintg=player[numplayers].clothestintg[i];
7789 tintb=player[numplayers].clothestintb[i];
7790 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7792 if(player[numplayers].numclothes){
7793 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
7796 player[numplayers].power=player[0].power;
7797 player[numplayers].speedmult=player[0].speedmult;
7799 player[numplayers].damage=0;
7800 player[numplayers].permanentdamage=0;
7801 player[numplayers].superpermanentdamage=0;
7802 player[numplayers].deathbleeding=0;
7803 player[numplayers].bleeding=0;
7804 player[numplayers].numwaypoints=0;
7805 player[numplayers].waypoint=0;
7806 player[numplayers].jumppath=0;
7807 player[numplayers].weaponstuck=-1;
7808 player[numplayers].weaponactive=-1;
7809 player[numplayers].num_weapons=0;
7810 player[numplayers].bloodloss=0;
7811 player[numplayers].dead=0;
7813 player[numplayers].loaded=1;
7817 drawmodetogglekeydown=1;
7820 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
7821 if(player[numplayers-1].numwaypoints<90){
7822 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
7823 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
7824 player[numplayers-1].numwaypoints++;
7826 drawmodetogglekeydown=1;
7829 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7830 if(numpathpoints<30){
7831 bool connected,alreadyconnected;
7834 for(i=0;i<numpathpoints;i++){
7835 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
7837 for(j=0;j<numpathpointconnect[pathpointselected];j++){
7838 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
7840 if(!alreadyconnected){
7841 numpathpointconnect[pathpointselected]++;
7843 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
7849 pathpoint[numpathpoints-1]=player[0].coords;
7850 numpathpointconnect[numpathpoints-1]=0;
7851 if(numpathpoints>1&&pathpointselected!=-1){
7852 numpathpointconnect[pathpointselected]++;
7853 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
7855 pathpointselected=numpathpoints-1;
7858 drawmodetogglekeydown=1;
7861 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
7862 pathpointselected++;
7863 if(pathpointselected>=numpathpoints)pathpointselected=-1;
7864 drawmodetogglekeydown=1;
7866 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7867 pathpointselected--;
7868 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
7869 drawmodetogglekeydown=1;
7871 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7872 if(pathpointselected!=-1){
7874 pathpoint[pathpointselected]=pathpoint[numpathpoints];
7875 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
7876 for(i=0;i<numpathpointconnect[pathpointselected];i++){
7877 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
7879 for(i=0;i<numpathpoints;i++){
7880 for(j=0;j<numpathpointconnect[i];j++){
7881 if(pathpointconnect[i][j]==pathpointselected){
7882 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
7883 numpathpointconnect[i]--;
7885 if(pathpointconnect[i][j]==numpathpoints){
7886 pathpointconnect[i][j]=pathpointselected;
7890 pathpointselected=numpathpoints-1;
7892 drawmodetogglekeydown=1;
7895 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7896 editorenabled=1-editorenabled;
7898 player[0].damagetolerance=100000;
7900 player[0].superpermanentdamage=0;
7901 player[0].bloodloss=0;
7902 player[0].deathbleeding=0;
7905 player[0].damagetolerance=200;
7907 player[0].permanentdamage=0;
7908 player[0].superpermanentdamage=0;
7909 player[0].bloodloss=0;
7910 player[0].deathbleeding=0;
7912 drawmodetogglekeydown=1;
7915 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7917 if(editortype==treeleavestype||editortype==10)editortype--;
7918 if(editortype<0)editortype=firetype;
7919 drawmodetogglekeydown=1;
7922 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7924 if(editortype==treeleavestype||editortype==10)editortype++;
7925 if(editortype>firetype)editortype=0;
7926 drawmodetogglekeydown=1;
7929 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7930 editorrotation-=multiplier*100;
7931 if(editorrotation<-.01)editorrotation=-.01;
7932 drawmodetogglekeydown=1;
7935 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7936 editorrotation+=multiplier*100;
7937 drawmodetogglekeydown=1;
7940 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7941 editorsize+=multiplier;
7942 drawmodetogglekeydown=1;
7945 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7946 editorsize-=multiplier;
7947 if(editorsize<.1)editorsize=.1;
7948 drawmodetogglekeydown=1;
7952 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7953 mapradius-=multiplier*10;
7956 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7957 mapradius+=multiplier*10;
7960 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7961 mapcenter.x+=multiplier*20;
7964 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7965 mapcenter.x-=multiplier*20;
7968 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7969 mapcenter.z+=multiplier*20;
7972 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7973 mapcenter.z-=multiplier*20;
7976 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7977 editorrotation2+=multiplier*100;
7980 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7981 editorrotation2-=multiplier*100;
7982 if(editorrotation2<-.01)editorrotation2=-.01;
7984 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7986 float closestdist=-1;
7988 for(i=0;i<objects.numobjects;i++){
7989 distance=findDistancefast(&objects.position[i],&player[0].coords);
7990 if(closestdist==-1||distance<closestdist){
7991 closestdist=distance;
7995 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
7996 drawmodetogglekeydown=1;
8000 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)){
8001 drawmodetogglekeydown=0;
8004 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8005 //if(!player[0].skeleton.free)player[0].damage+=500;
8006 player[0].RagDoll(0);
8007 //player[0].spurt=1;
8008 //player[0].DoDamage(1000);
8012 gLoc[0]=player[0].coords.x;
8013 gLoc[1]=player[0].coords.y;
8014 gLoc[2]=player[0].coords.z;
8015 vel[0]=player[0].velocity.x;
8016 vel[1]=player[0].velocity.y;
8017 vel[2]=player[0].velocity.z;
8018 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
8019 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8020 OPENAL_SetVolume(channels[whooshsound], 128);
8021 OPENAL_SetPaused(channels[whooshsound], false);
8022 //OPENAL_SetPaused(channels[whooshsound], true);
8024 texturesizetogglekeydown=1;
8027 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8030 float closestdist=-1;
8032 for(i=0;i<objects.numobjects;i++){
8033 if(objects.type[i]==treeleavestype){
8034 objects.scale[i]*=.9;
8037 texturesizetogglekeydown=1;
8040 static XYZ relative;
8041 static int randattack;
8043 static bool playerrealattackkeydown=0;
8045 if(!buttons[0])oldbutton=0;
8046 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8047 if(oldattackkey)player[0].attackkeydown=0;
8048 if(oldattackkey)playerrealattackkeydown=0;
8049 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8050 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);
8051 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8052 for(k=0;k<numplayers;k++){
8053 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8054 player[k].Reverse();
8058 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8060 for(k=0;k<numplayers;k++){
8061 if(indialogue!=-1)player[k].attackkeydown=0;
8062 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8063 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
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 player[k].jumppower-=2;
8067 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)){
8068 for(i=0;i<numplayers;i++){
8070 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8071 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8072 player[k].targetanimation=dodgebackanim;
8074 player[k].targetframe=0;
8075 rotatetarget=player[i].coords-player[k].coords;
8076 Normalise(&rotatetarget);
8077 player[k].targetrotation=-asin(0-rotatetarget.x);
8078 player[k].targetrotation*=360/6.28;
8079 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8081 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8084 if(player[k].targetanimation!=dodgebackanim){
8085 if(k==0)numflipped++;
8086 player[k].targetanimation=backhandspringanim;
8088 player[k].targetframe=0;
8089 player[k].targetrotation=-rotation+180;
8090 if(player[k].leftkeydown)player[k].targetrotation-=45;
8091 if(player[k].rightkeydown)player[k].targetrotation+=45;
8092 player[k].rotation=player[k].targetrotation;
8093 player[k].jumppower-=2;
8096 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())){
8097 player[k].hasvictim=0;
8099 for(i=0;i<numplayers;i++){
8101 if(!player[k].hasvictim)
8102 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8103 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){
8104 player[k].victim=&player[i];
8105 player[k].hasvictim=1;
8106 if(player[k].aitype==playercontrolled){
8107 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;
8108 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;
8109 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;
8110 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;
8111 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;
8112 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;
8113 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;
8114 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;
8115 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;
8116 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;
8119 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8120 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8121 else randattack=abs(Random()%5);
8122 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8123 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8124 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8125 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8126 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8128 if(player[k].weaponactive!=-1){
8129 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;
8130 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;
8131 //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;
8132 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;
8133 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;
8134 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;
8135 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;
8136 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;
8140 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8142 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)){
8143 if(player[k].weaponactive==-1){
8144 player[i].targetanimation=sneakattackedanim;
8145 player[i].currentanimation=sneakattackedanim;
8146 player[k].currentanimation=sneakattackanim;
8147 player[k].targetanimation=sneakattackanim;
8148 player[k].oldcoords=player[k].coords;
8149 player[k].coords=player[i].coords;
8151 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8152 player[i].targetanimation=knifesneakattackedanim;
8153 player[i].currentanimation=knifesneakattackedanim;
8154 player[k].currentanimation=knifesneakattackanim;
8155 player[k].targetanimation=knifesneakattackanim;
8156 player[i].oldcoords=player[i].coords;
8157 player[i].coords=player[k].coords;
8159 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8160 player[i].targetanimation=swordsneakattackedanim;
8161 player[i].currentanimation=swordsneakattackedanim;
8162 player[k].currentanimation=swordsneakattackanim;
8163 player[k].targetanimation=swordsneakattackanim;
8164 player[i].oldcoords=player[i].coords;
8165 player[i].coords=player[k].coords;
8167 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8168 player[k].victim=&player[i];
8169 player[k].hasvictim=1;
8170 player[i].targettilt2=0;
8171 player[i].targetframe=1;
8172 player[i].currentframe=0;
8174 player[i].velocity=0;
8175 player[k].targettilt2=player[i].targettilt2;
8176 player[k].currentframe=player[i].currentframe;
8177 player[k].targetframe=player[i].targetframe;
8178 player[k].target=player[i].target;
8179 player[k].velocity=0;
8180 player[k].targetrotation=player[i].rotation;
8181 player[k].rotation=player[i].rotation;
8182 player[i].targetrotation=player[i].rotation;
8185 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8187 player[k].targetframe=0;
8189 //player[k].velocity=0;
8191 rotatetarget=player[i].coords-player[k].coords;
8192 Normalise(&rotatetarget);
8193 player[k].targetrotation=-asin(0-rotatetarget.x);
8194 player[k].targetrotation*=360/6.28;
8195 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8197 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8199 player[k].lastattack3=player[k].lastattack2;
8200 player[k].lastattack2=player[k].lastattack;
8201 player[k].lastattack=player[k].targetanimation;
8202 //player[k].targettilt2=0;
8206 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8207 rotatetarget=player[i].coords-player[k].coords;
8208 Normalise(&rotatetarget);
8209 player[k].targetrotation=-asin(0-rotatetarget.x);
8210 player[k].targetrotation*=360/6.28;
8211 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8212 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8214 player[k].victim=&player[i];
8215 player[k].hasvictim=1;
8216 player[i].targetanimation=knifefollowedanim;
8217 player[i].currentanimation=knifefollowedanim;
8218 player[i].targettilt2=0;
8219 player[i].targettilt2=player[k].targettilt2;
8220 player[i].targetframe=1;
8221 player[i].currentframe=0;
8223 player[i].velocity=0;
8224 player[k].currentanimation=knifefollowanim;
8225 player[k].targetanimation=knifefollowanim;
8226 player[k].targettilt2=player[i].targettilt2;
8227 player[k].currentframe=player[i].currentframe;
8228 player[k].targetframe=player[i].targetframe;
8229 player[k].target=player[i].target;
8230 player[k].velocity=0;
8231 player[k].oldcoords=player[k].coords;
8232 player[i].coords=player[k].coords;
8233 player[i].targetrotation=player[k].targetrotation;
8234 player[i].rotation=player[k].targetrotation;
8235 player[k].rotation=player[k].targetrotation;
8236 player[i].rotation=player[k].targetrotation;
8241 if(player[k].weaponactive!=-1){
8242 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8245 for(i=0;i<numplayers;i++){
8247 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8248 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8249 if(player[i].skeleton.free)
8250 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)))){
8251 player[k].victim=&player[i];
8252 player[k].hasvictim=1;
8253 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8254 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;
8255 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;
8256 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;
8258 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){
8259 player[k].targetanimation=killanim;
8260 for(j=0;j<terrain.numdecals;j++){
8261 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8262 terrain.DeleteDecal(j);
8265 for(l=0;l<objects.numobjects;l++){
8266 if(objects.model[l].type==decalstype)
8267 for(j=0;j<objects.model[l].numdecals;j++){
8268 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8269 objects.model[l].DeleteDecal(j);
8274 if(!player[i].dead||musictype!=2)
8275 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)){
8276 player[k].targetanimation=dropkickanim;
8277 for(j=0;j<terrain.numdecals;j++){
8278 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8279 terrain.DeleteDecal(j);
8282 for(l=0;l<objects.numobjects;l++){
8283 if(objects.model[l].type==decalstype)
8284 for(j=0;j<objects.model[l].numdecals;j++){
8285 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8286 objects.model[l].DeleteDecal(j);
8292 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)){
8294 player[k].targetframe=0;
8296 //player[k].velocity=0;
8298 rotatetarget=player[i].coords-player[k].coords;
8299 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8300 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;
8302 Normalise(&rotatetarget);
8303 player[k].targetrotation=-asin(0-rotatetarget.x);
8304 player[k].targetrotation*=360/6.28;
8305 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8307 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8308 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8311 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8312 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8314 player[k].lastattack3=player[k].lastattack2;
8315 player[k].lastattack2=player[k].lastattack;
8316 player[k].lastattack=player[k].targetanimation;
8318 if(player[k].targetanimation==swordgroundstabanim){
8319 player[k].targetrotation+=30;
8321 //player[k].targettilt2=0;
8327 if(!player[k].hasvictim){
8328 for(i=0;i<numplayers;i++){
8329 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8330 player[k].victim=&player[i];
8331 player[k].hasvictim=1;
8333 if(player[k].hasvictim&&!player[i].skeleton.free)
8334 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8335 player[k].victim=&player[i];
8339 if(player[k].aitype==playercontrolled)
8340 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)){
8342 player[k].targetanimation=rabbitkickanim;
8343 player[k].targetframe=0;
8346 if(animation[player[k].targetanimation].attack&&k==0){
8349 if(player[k].weaponactive!=-1){
8350 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8353 if(player[k].weaponactive!=-1){
8354 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8357 if(player[k].weaponactive!=-1){
8358 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8360 if(armedstaff)numstaffattack++;
8361 else if(armedsword)numswordattack++;
8362 else if(armedknife)numknifeattack++;
8363 else numunarmedattack++;
8370 static float collisionradius;
8372 for(k=0;k<numplayers;k++){
8373 for(i=k;i<numplayers;i++){
8376 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))
8377 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))
8378 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8379 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8380 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)
8381 if(player[i].coords.y>player[k].coords.y-3)
8382 if(player[i].coords.y<player[k].coords.y+3)
8383 if(player[i].coords.x>player[k].coords.x-3)
8384 if(player[i].coords.x<player[k].coords.x+3)
8385 if(player[i].coords.z>player[k].coords.z-3)
8386 if(player[i].coords.z<player[k].coords.z+3){
8387 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)){
8388 if(player[i].onfire||player[k].onfire){
8389 if(!player[i].onfire)player[i].CatchFire();
8390 if(!player[k].onfire)player[k].CatchFire();
8394 tempcoords1=player[i].coords;
8395 tempcoords2=player[k].coords;
8396 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8397 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8398 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8399 if(player[0].hasvictim)
8400 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8401 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8403 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)){
8404 player[k].coords.y=player[i].coords.y;
8405 player[i].velocity=player[k].velocity;
8406 player[i].skeleton.free=0;
8407 player[i].rotation=0;
8408 player[i].RagDoll(0);
8409 player[i].DoDamage(20);
8410 if(k==0)camerashake+=.3;
8411 player[i].skeleton.longdead=0;
8412 player[k].lastcollide=1;
8415 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)){
8416 player[i].coords.y=player[k].coords.y;
8417 player[k].velocity=player[i].velocity;
8418 player[k].skeleton.free=0;
8419 player[k].rotation=0;
8420 player[k].RagDoll(0);
8421 player[k].DoDamage(20);
8422 if(i==0)camerashake+=.3;
8423 player[k].skeleton.longdead=0;
8424 player[i].lastcollide=1;
8427 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)){
8428 rotatetarget=player[k].velocity-player[i].velocity;
8429 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))
8430 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))){
8432 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)){
8433 static float gLoc[3];
8434 static float vel[3];
8435 gLoc[0]=player[i].coords.x;
8436 gLoc[1]=player[i].coords.y;
8437 gLoc[2]=player[i].coords.z;
8438 vel[0]=player[i].velocity.x;
8439 vel[1]=player[i].velocity.y;
8440 vel[2]=player[i].velocity.z;
8441 if(tutoriallevel!=1){
8442 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8443 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8444 OPENAL_SetVolume(channels[heavyimpactsound], 256);
8445 OPENAL_SetPaused(channels[heavyimpactsound], false);
8447 //player[i].velocity=player[k].velocity;
8448 //player[k].velocity=player[i].velocity;
8450 player[i].RagDoll(0);
8451 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8456 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8457 player[k].RagDoll(0);
8458 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8463 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8465 //if(player[i].skeleton.oldfree){
8466 for(j=0;j<player[i].skeleton.num_joints;j++){
8467 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8470 //if(player[k].skeleton.oldfree){
8471 for(j=0;j<player[k].skeleton.num_joints;j++){
8472 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8478 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)){
8480 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8481 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)){
8482 rotatetarget=player[k].coords-player[i].coords;
8483 Normalise(&rotatetarget);
8484 player[k].coords=(player[k].coords+player[i].coords)/2;
8485 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);
8486 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8487 if(player[k].howactive==typeactive||hostile)
8488 if(player[k].isIdle()){
8489 if(player[k].howactive<typesleeping){
8490 player[k].targetanimation=player[k].getStop();
8491 player[k].targetframe=0;
8494 else if(player[k].howactive==typesleeping)
8496 player[k].targetanimation=getupfromfrontanim;
8497 player[k].targetframe=0;
8500 if(!editorenabled)player[k].howactive=typeactive;
8502 if(player[i].howactive==typeactive||hostile)
8503 if(player[i].isIdle()){
8504 if(player[i].howactive<typesleeping){
8505 player[i].targetanimation=player[i].getStop();
8506 player[i].targetframe=0;
8511 player[i].targetanimation=getupfromfrontanim;
8512 player[i].targetframe=0;
8515 if(!editorenabled)player[i].howactive=typeactive;
8519 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){
8520 player[i].velocity=player[k].velocity;
8521 player[k].velocity=player[k].velocity*-.5;
8522 //player[i].velocity.y-=10;
8523 player[k].velocity.y=player[i].velocity.y;
8524 player[i].DoDamage(20);
8525 player[i].RagDoll(0);
8526 player[k].lastcollide=1;
8533 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){
8534 player[k].velocity=player[i].velocity;
8535 player[i].velocity=player[i].velocity*-.3;
8536 //player[k].velocity.y-=10;
8537 player[i].velocity.y=player[k].velocity.y;
8538 player[k].DoDamage(20);
8539 player[k].RagDoll(0);
8540 player[i].lastcollide=1;
8551 player[i].CheckKick();
8552 player[k].CheckKick();
8558 for(k=0;k<numplayers;k++){
8559 for(i=k;i<numplayers;i++){
8561 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))){
8562 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)){
8563 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)){
8564 player[i].victim=&player[k];
8565 player[i].targetanimation=jumpreversedanim;
8566 player[i].currentanimation=jumpreversedanim;
8567 player[k].currentanimation=jumpreversalanim;
8568 player[k].targetanimation=jumpreversalanim;
8569 player[i].targettilt2=0;
8570 player[i].currentframe=0;
8571 player[i].targetframe=1;
8572 player[k].currentframe=0;
8573 player[k].targetframe=1;
8574 if(player[i].coords.y<player[k].coords.y+1){
8575 player[i].targetanimation=rabbitkickreversedanim;
8576 player[i].currentanimation=rabbitkickreversedanim;
8577 player[k].currentanimation=rabbitkickreversalanim;
8578 player[k].targetanimation=rabbitkickreversalanim;
8579 player[k].currentframe=1;
8580 player[k].targetframe=2;
8581 player[i].currentframe=1;
8582 player[i].targetframe=2;
8584 player[k].targettilt2=0;
8586 player[i].velocity=0;
8587 player[k].velocity=0;
8588 player[k].oldcoords=player[k].coords;
8589 player[i].coords=player[k].coords;
8590 player[k].targetrotation=player[i].targetrotation;
8591 player[k].rotation=player[i].targetrotation;
8592 player[k].victim=&player[i];
8593 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8595 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)){
8596 player[k].victim=&player[i];
8597 player[k].targetanimation=jumpreversedanim;
8598 player[k].currentanimation=jumpreversedanim;
8599 player[i].currentanimation=jumpreversalanim;
8600 player[i].targetanimation=jumpreversalanim;
8601 player[k].targettilt2=0;
8602 player[i].targettilt2=0;
8603 player[k].currentframe=0;
8604 player[k].targetframe=1;
8605 player[i].currentframe=0;
8606 player[i].targetframe=1;
8607 if(player[k].coords.y<player[i].coords.y+1){
8608 player[k].targetanimation=rabbitkickreversedanim;
8609 player[k].currentanimation=rabbitkickreversedanim;
8610 player[i].currentanimation=rabbitkickreversalanim;
8611 player[i].targetanimation=rabbitkickreversalanim;
8612 player[k].currentframe=1;
8613 player[k].targetframe=2;
8614 player[i].currentframe=1;
8615 player[i].targetframe=2;
8618 player[k].velocity=0;
8619 player[i].velocity=0;
8620 player[i].oldcoords=player[i].coords;
8621 player[k].coords=player[i].coords;
8622 player[i].targetrotation=player[k].targetrotation;
8623 player[i].rotation=player[k].targetrotation;
8624 player[i].victim=&player[k];
8625 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8632 for(k=0;k<numplayers;k++)
8633 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8642 static float checkdelay;
8643 checkdelay-=multiplier;
8645 static bool checkedcoll[maxplayers][maxplayers];
8646 static bool above[maxplayers];
8648 for(i=0;i<maxplayers;i++){
8649 for(j=0;j<maxplayers;j++){
8650 checkedcoll[i][j]=0;
8654 if(numplayers>1&&checkdelay<=0){
8656 for(k=0;k<numplayers;k++){
8657 if(player[k].skeleton.free!=2)above[k]=-1;
8659 for(i=k;i<numplayers;i++){
8662 if(!checkedcoll[i][k]){
8663 checkedcoll[i][k]=1;
8664 checkedcoll[k][i]=1;
8665 if(player[i].skeleton.free&&player[k].skeleton.free)
8666 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8667 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8668 if(player[i].coords.y>player[k].coords.y-3)
8669 if(player[i].coords.y<player[k].coords.y+3)
8670 if(player[i].coords.x>player[k].coords.x-3)
8671 if(player[i].coords.x<player[k].coords.x+3)
8672 if(player[i].coords.z>player[k].coords.z-3)
8673 if(player[i].coords.z<player[k].coords.z+3)
8674 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)){
8676 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8688 above[moving]=stuck;
8689 for(l=0;l<player[moving].skeleton.num_joints;l++){
8690 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8691 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8693 player[moving].skeleton.joints[l].position.y+=.003;
8694 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8708 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8709 texturesizetogglekeydown=0;
8712 for(k=0;k<numplayers;k++){
8713 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8714 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8715 player[k].DoDamage(1000);
8720 static bool respawnkeydown;
8721 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8722 targetlevel=whichlevel;
8726 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8727 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8732 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8734 if(targetlevel>numchallengelevels-1)targetlevel=0;
8737 slomotogglekeydown=1;
8741 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8743 OPENAL_SetPaused(channels[whooshsound], true);
8745 for(k=0;k<numplayers;k++){
8748 player[k].permanentdamage=0;
8749 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8750 player[k].aitype=passivetype;
8752 player[0].aitype=playercontrolled;
8756 static bool movekey;
8757 static bool connected;
8758 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8759 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8760 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8761 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8762 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8763 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8765 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
8767 for(int i=0;i<numplayers;i++){
8768 if(!player[i].skeleton.free){
8769 oldtargetrotation=player[i].targetrotation;
8770 if(i==0&&indialogue==-1){
8771 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){
8772 if(!cameramode)player[0].targetrotation=-rotation+180;
8773 if(cameramode)player[0].targetrotation=0;
8779 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8780 if(cameramode){facing=flatfacing;}
8782 facing=DoRotation(facing,-rotation2,0,0);
8783 facing=DoRotation(facing,0,0-rotation,0);
8786 player[0].lookrotation=-rotation;
8788 player[i].targetheadrotation=rotation;
8789 player[i].targetheadrotation2=rotation2;
8791 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
8792 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){
8793 player[i].targetrotation=-player[i].lookrotation+180;
8799 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8801 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
8802 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
8804 player[i].targetheadrotation=player[i].lookrotation;
8805 player[i].targetheadrotation2=player[i].lookrotation2;
8808 rotatetarget=participantfacing[whichdialogue][indialogue][i];
8809 Normalise(&rotatetarget);
8810 player[i].targetheadrotation=-asin(0-rotatetarget.x);
8811 player[i].targetheadrotation*=360/6.28;
8812 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
8814 player[i].targetheadrotation*=-1;
8815 player[i].targetheadrotation+=180;
8816 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
8824 player[i].avoidsomething=0;
8826 for(j=0;j<objects.numobjects;j++){
8827 if(objects.onfire[j]){
8828 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
8830 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
8831 player[i].collided=0;
8832 player[i].avoidcollided=1;
8833 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8834 player[i].avoidwhere=objects.position[j];
8840 //Add avoidwhere to players
8842 for(j=0;j<numplayers;j++){
8843 if(player[j].onfire){
8844 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
8846 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
8847 player[i].collided=0;
8848 player[i].avoidcollided=1;
8849 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8850 player[i].avoidwhere=objects.position[j];
8856 if(player[i].collided>.8)player[i].avoidcollided=0;
8857 if(player[i].aitype!=playercontrolled&&indialogue==-1){
8858 player[i].jumpclimb=0;
8860 if(editorenabled)player[i].stunned=1;
8863 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
8864 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;
8866 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
8867 player[i].forwardkeydown=0;
8868 player[i].leftkeydown=0;
8869 player[i].backkeydown=0;
8870 player[i].rightkeydown=0;
8871 player[i].crouchkeydown=0;
8872 player[i].attackkeydown=0;
8873 player[i].jumpkeydown=0;
8874 player[i].throwkeydown=0;
8877 if(player[i].aitype==pathfindtype){
8878 if(player[i].finalpathfindpoint==-1){
8879 float closestdistance;
8885 for(j=0;j<numpathpoints;j++){
8886 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
8887 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
8889 player[i].finaltarget=pathpoint[j];
8892 player[i].finalpathfindpoint=closest;
8893 for(j=0;j<numpathpoints;j++){
8894 if(numpathpointconnect[j])
8895 for(k=0;k<numpathpointconnect[j];k++){
8896 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8897 if(tempdist*tempdist<closestdistance){
8898 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8899 closestdistance=tempdist*tempdist;
8901 player[i].finaltarget=colpoint;
8906 player[i].finalpathfindpoint=closest;
8909 if(player[i].targetpathfindpoint==-1){
8910 float closestdistance;
8916 if(player[i].lastpathfindpoint==-1){
8917 for(j=0;j<numpathpoints;j++){
8918 if(j!=player[i].lastpathfindpoint)
8919 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
8920 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
8924 player[i].targetpathfindpoint=closest;
8925 for(j=0;j<numpathpoints;j++){
8926 if(j!=player[i].lastpathfindpoint)
8927 if(numpathpointconnect[j])
8928 for(k=0;k<numpathpointconnect[j];k++){
8929 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8930 if(tempdist*tempdist<closestdistance){
8931 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8932 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
8933 closestdistance=tempdist*tempdist;
8940 player[i].targetpathfindpoint=closest;
8944 for(j=0;j<numpathpoints;j++){
8945 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
8948 if(numpathpointconnect[j])
8949 for(k=0;k<numpathpointconnect[j];k++){
8950 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
8953 if(numpathpointconnect[player[i].lastpathfindpoint])
8954 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
8955 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
8958 tempdist=findPathDist(j,player[i].finalpathfindpoint);
8959 if(closest==-1||tempdist<closestdistance){
8960 closestdistance=tempdist;
8966 player[i].targetpathfindpoint=closest;
8969 player[i].losupdatedelay-=multiplier;
8971 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
8972 Normalise(&rotatetarget);
8973 player[i].targetrotation=-asin(0-rotatetarget.x);
8974 player[i].targetrotation*=360/6.28;
8975 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8976 player[i].lookrotation=player[i].targetrotation;
8977 //player[i].aiupdatedelay=.05;
8979 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
8980 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8981 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8982 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8983 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
8984 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8985 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8986 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8987 player[i].targetpathfindpoint=-1;
8989 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){
8990 player[i].aitype=passivetype;
8993 player[i].forwardkeydown=1;
8994 player[i].leftkeydown=0;
8995 player[i].backkeydown=0;
8996 player[i].rightkeydown=0;
8997 player[i].crouchkeydown=0;
8998 player[i].attackkeydown=0;
8999 player[i].throwkeydown=0;
9001 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9003 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9004 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9006 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9007 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))
9008 player[i].aitype=attacktypecutoff;
9009 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9010 player[i].aitype=attacktypecutoff;
9012 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9013 player[i].losupdatedelay=.2;
9014 for(j=0;j<numplayers;j++){
9015 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9016 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9017 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9018 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9019 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9020 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)){
9021 player[i].aitype=searchtype;
9022 player[i].lastchecktime=12;
9023 player[i].lastseen=player[j].coords;
9024 player[i].lastseentime=12;
9030 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9031 if(player[i].creature!=wolftype){
9032 player[i].stunned=.6;
9033 player[i].surprised=.6;
9038 if(player[i].aitype!=passivetype&&leveltime>.5){
9039 player[i].howactive=typeactive;
9042 if(player[i].aitype==passivetype){
9043 player[i].aiupdatedelay-=multiplier;
9044 player[i].losupdatedelay-=multiplier;
9045 player[i].lastseentime+=multiplier;
9046 player[i].pausetime-=multiplier;
9047 if(player[i].lastseentime>1)player[i].lastseentime=1;
9049 if(player[i].aiupdatedelay<0){
9050 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9051 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9052 Normalise(&rotatetarget);
9053 player[i].targetrotation=-asin(0-rotatetarget.x);
9054 player[i].targetrotation*=360/6.28;
9055 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9056 player[i].lookrotation=player[i].targetrotation;
9057 player[i].aiupdatedelay=.05;
9059 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9060 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9061 player[i].waypoint++;
9062 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9067 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9068 else player[i].forwardkeydown=0;
9069 player[i].leftkeydown=0;
9070 player[i].backkeydown=0;
9071 player[i].rightkeydown=0;
9072 player[i].crouchkeydown=0;
9073 player[i].attackkeydown=0;
9074 player[i].throwkeydown=0;
9076 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9077 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9079 XYZ leftpos,rightpos;
9080 float leftdist,rightdist;
9081 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9082 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9083 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9084 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9085 if(leftdist<rightdist)player[i].targetrotation+=90;
9086 else player[i].targetrotation-=90;
9090 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9091 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9095 if(player[i].howactive<typesleeping)
9096 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9097 for(j=0;j<numenvsounds;j++){
9098 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9099 player[i].aitype=attacktypecutoff;
9103 if(player[i].howactive==typesleeping)
9104 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9105 for(j=0;j<numenvsounds;j++){
9106 if(envsoundvol[j]>14)
9107 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9108 player[i].aitype=attacktypecutoff;
9112 if(player[i].aitype!=passivetype){
9113 if(player[i].howactive==typesleeping){
9114 player[i].targetanimation=getupfromfrontanim;
9115 player[i].targetframe=0;
9119 player[i].howactive=typeactive;
9123 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9124 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9125 player[i].aitype=attacktypecutoff;
9126 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9127 player[i].aitype=attacktypecutoff;
9129 if(player[i].creature==wolftype){
9131 float smelldistance;
9133 for(j=0;j<numplayers;j++){
9134 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9135 if(j==0&&player[j].num_weapons>0){
9136 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9137 if(player[j].num_weapons==2)
9138 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9143 windsmell=windvector;
9144 Normalise(&windsmell);
9145 windsmell=windsmell*2+player[j].coords;
9146 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9147 player[i].aitype=attacktypecutoff;
9152 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9153 player[i].losupdatedelay=.2;
9154 for(j=0;j<numplayers;j++){
9155 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9156 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9157 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9158 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9159 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)){
9160 player[i].lastseentime-=.2;
9161 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9162 else player[i].lastseentime-=.6;
9164 if(player[i].lastseentime<=0){
9165 player[i].aitype=searchtype;
9166 player[i].lastchecktime=12;
9167 player[i].lastseen=player[j].coords;
9168 player[i].lastseentime=12;
9174 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9175 if(player[i].creature!=wolftype){
9176 player[i].stunned=.6;
9177 player[i].surprised=.6;
9179 if(player[i].creature==wolftype){
9180 player[i].stunned=.47;
9181 player[i].surprised=.47;
9187 if(player[i].aitype==searchtype){
9188 player[i].aiupdatedelay-=multiplier;
9189 player[i].losupdatedelay-=multiplier;
9190 if(!player[i].pause)player[i].lastseentime-=multiplier;
9191 player[i].lastchecktime-=multiplier;
9193 if(player[i].isRun()&&!player[i].onground){
9194 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9195 test2=player[i].coords+player[i].facing;
9197 test=player[i].coords+player[i].facing;
9199 j=checkcollide(test2,test,player[i].laststanding);
9200 if(j==-1)j=checkcollide(test2,test);
9202 player[i].velocity=0;
9203 player[i].targetanimation=player[i].getStop();
9204 player[i].targetframe=0;
9206 player[i].targetrotation+=180;
9207 player[i].stunned=.5;
9208 //player[i].aitype=passivetype;
9209 player[i].aitype=pathfindtype;
9210 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9211 player[i].finalpathfindpoint=-1;
9212 player[i].targetpathfindpoint=-1;
9213 player[i].lastpathfindpoint=-1;
9214 player[i].lastpathfindpoint2=-1;
9215 player[i].lastpathfindpoint3=-1;
9216 player[i].lastpathfindpoint4=-1;
9218 else player[i].laststanding=j;
9221 if(player[i].aiupdatedelay<0){
9222 rotatetarget=player[i].lastseen-player[i].coords;
9223 Normalise(&rotatetarget);
9224 player[i].targetrotation=-asin(0-rotatetarget.x);
9225 player[i].targetrotation*=360/6.28;
9226 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9227 player[i].lookrotation=player[i].targetrotation;
9228 player[i].aiupdatedelay=.05;
9229 player[i].forwardkeydown=1;
9231 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9232 player[i].forwardkeydown=0;
9233 player[i].aiupdatedelay=1;
9234 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9235 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9236 player[i].lastchecktime=3;
9239 player[i].leftkeydown=0;
9240 player[i].backkeydown=0;
9241 player[i].rightkeydown=0;
9242 player[i].crouchkeydown=0;
9243 player[i].attackkeydown=0;
9244 player[i].throwkeydown=0;
9246 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9247 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9249 XYZ leftpos,rightpos;
9250 float leftdist,rightdist;
9251 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9252 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9253 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9254 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9255 if(leftdist<rightdist)player[i].targetrotation+=90;
9256 else player[i].targetrotation-=90;
9260 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9261 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9263 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9264 for(j=0;j<numenvsounds;j++){
9265 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9266 player[i].aitype=attacktypecutoff;
9270 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9271 player[i].losupdatedelay=.2;
9272 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9273 {player[i].aitype=attacktypecutoff;
9274 player[i].lastseentime=1;}
9275 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9276 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9277 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9278 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)){
9279 player[i].aitype=attacktypecutoff;
9280 player[i].lastseentime=1;
9283 if(player[i].lastseentime<0){
9284 //player[i].aitype=passivetype;
9286 player[i].aitype=pathfindtype;
9287 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9288 player[i].finalpathfindpoint=-1;
9289 player[i].targetpathfindpoint=-1;
9290 player[i].lastpathfindpoint=-1;
9291 player[i].lastpathfindpoint2=-1;
9292 player[i].lastpathfindpoint3=-1;
9293 player[i].lastpathfindpoint4=-1;
9297 if(player[i].aitype!=gethelptype){
9298 player[i].runninghowlong=0;
9301 if(player[i].aitype==gethelptype){
9302 player[i].runninghowlong+=multiplier;
9303 player[i].aiupdatedelay-=multiplier;
9305 if(player[i].aiupdatedelay<0||player[i].ally==0){
9306 player[i].aiupdatedelay=.2;
9314 if(!player[i].ally){
9315 for(j=0;j<numplayers;j++){
9316 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9317 distance=findDistancefast(&player[i].coords,&player[j].coords);
9318 if(closestdist==-1||distance<closestdist){
9319 closestdist=distance;
9325 if(closest!=-1)player[i].ally=closest;
9326 else player[i].ally=0;
9327 player[i].lastseen=player[0].coords;
9328 player[i].lastseentime=12;
9332 player[i].lastchecktime=12;
9333 //player[i].lastseentime-=.5;
9335 facing=player[i].coords;
9336 flatfacing=player[player[i].ally].coords;
9337 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9338 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9339 if(-1!=checkcollide(facing,flatfacing))
9340 player[i].lastseentime-=.1;
9342 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9343 player[i].aitype=searchtype;
9344 player[i].lastseentime=12;
9347 if(player[i].ally>0){
9348 rotatetarget=player[player[i].ally].coords-player[i].coords;
9349 Normalise(&rotatetarget);
9350 player[i].targetrotation=-asin(0-rotatetarget.x);
9351 player[i].targetrotation*=360/6.28;
9352 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9353 player[i].lookrotation=player[i].targetrotation;
9354 player[i].aiupdatedelay=.05;
9355 player[i].forwardkeydown=1;
9357 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9358 player[i].aitype=searchtype;
9359 player[i].lastseentime=12;
9360 player[player[i].ally].aitype=searchtype;
9361 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9362 player[player[i].ally].lastseen=player[i].lastseen;
9363 player[player[i].ally].lastseentime=player[i].lastseentime;
9364 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9368 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9369 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9371 XYZ leftpos,rightpos;
9372 float leftdist,rightdist;
9373 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9374 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9375 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9376 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9377 if(leftdist<rightdist)player[i].targetrotation+=90;
9378 else player[i].targetrotation-=90;
9383 player[i].leftkeydown=0;
9384 player[i].backkeydown=0;
9385 player[i].rightkeydown=0;
9386 player[i].crouchkeydown=0;
9387 player[i].attackkeydown=0;
9389 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9390 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9393 if(player[i].aitype==getweapontype){
9394 player[i].aiupdatedelay-=multiplier;
9395 player[i].lastchecktime-=multiplier;
9397 if(player[i].aiupdatedelay<0){
9398 player[i].aiupdatedelay=.2;
9406 if(player[i].ally<0){
9407 for(j=0;j<weapons.numweapons;j++){
9408 if(weapons.owner[j]==-1){
9409 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9410 if(closestdist==-1||distance<closestdist){
9411 closestdist=distance;
9417 if(closest!=-1)player[i].ally=closest;
9418 else player[i].ally=-1;
9421 player[i].lastseentime=12;
9423 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9424 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9425 player[i].aitype=attacktypecutoff;
9426 player[i].lastseentime=1;
9429 if(player[i].ally>=0){
9430 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9431 player[i].aitype=attacktypecutoff;
9432 player[i].lastseentime=1;
9434 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9435 Normalise(&rotatetarget);
9436 player[i].targetrotation=-asin(0-rotatetarget.x);
9437 player[i].targetrotation*=360/6.28;
9438 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9439 player[i].lookrotation=player[i].targetrotation;
9440 player[i].aiupdatedelay=.05;
9441 player[i].forwardkeydown=1;
9444 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9445 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9447 XYZ leftpos,rightpos;
9448 float leftdist,rightdist;
9449 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9450 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9451 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9452 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9453 if(leftdist<rightdist)player[i].targetrotation+=90;
9454 else player[i].targetrotation-=90;
9457 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9458 if(abs(Random()%6)){
9459 player[i].crouchkeydown=1;
9460 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9461 if(player[i].isRun()){
9462 player[i].targetframe=0;
9464 player[i].targetanimation=sneakanim;
9467 else player[i].forwardkeydown=0;
9469 else player[i].crouchkeydown=0;
9471 else player[i].crouchkeydown=0;*/
9474 player[i].leftkeydown=0;
9475 player[i].backkeydown=0;
9476 player[i].rightkeydown=0;
9477 player[i].attackkeydown=0;
9478 player[i].throwkeydown=1;
9479 player[i].crouchkeydown=0;
9480 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9481 player[i].drawkeydown=0;
9483 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9484 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9487 if(player[i].aitype==attacktypecutoff){
9488 player[i].aiupdatedelay-=multiplier;
9489 if(player[i].damage<player[i].damagetolerance*2/3)
9490 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)){
9491 player[i].attackkeydown=0;
9492 if(player[i].isIdle())player[i].crouchkeydown=1;
9493 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9494 if(weapons.type[player[0].weaponids[0]]==knife){
9495 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9496 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9497 else player[i].targetanimation=rollanim;
9499 player[i].targetframe=0;
9500 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9501 player[i].wentforweapon=0;
9503 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9504 player[i].targetanimation=flipanim;
9506 player[i].targetframe=0;
9510 player[i].forwardkeydown=0;
9511 player[i].aiupdatedelay=.02;
9513 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9514 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9515 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9517 if(player[i].wentforweapon<3)
9518 for(j=0;j<weapons.numweapons;j++){
9519 if(player[i].creature!=wolftype)
9520 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){
9521 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9522 player[i].wentforweapon++;
9523 player[i].lastchecktime=6;
9524 player[i].aitype=getweapontype;
9529 if(player[i].damage<player[i].damagetolerance/2)
9530 if(animation[player[i].targetanimation].height!=highheight)
9531 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)))){
9532 player[i].crouchkeydown=1;
9534 if(player[i].isRun()&&!player[i].onground){
9535 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9536 test2=player[i].coords+player[i].facing;
9538 test=player[i].coords+player[i].facing;
9540 j=checkcollide(test2,test,player[i].laststanding);
9541 if(j==-1)j=checkcollide(test2,test);
9543 player[i].velocity=0;
9544 player[i].targetanimation=player[i].getStop();
9545 player[i].targetframe=0;
9547 player[i].targetrotation+=180;
9548 player[i].stunned=.5;
9549 //player[i].aitype=passivetype;
9550 player[i].aitype=pathfindtype;
9551 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9552 player[i].finalpathfindpoint=-1;
9553 player[i].targetpathfindpoint=-1;
9554 player[i].lastpathfindpoint=-1;
9555 player[i].lastpathfindpoint2=-1;
9556 player[i].lastpathfindpoint3=-1;
9557 player[i].lastpathfindpoint4=-1;
9559 else player[i].laststanding=j;
9562 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9563 player[i].aitype=pathfindtype;
9564 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9565 player[i].finalpathfindpoint=-1;
9566 player[i].targetpathfindpoint=-1;
9567 player[i].lastpathfindpoint=-1;
9568 player[i].lastpathfindpoint2=-1;
9569 player[i].lastpathfindpoint3=-1;
9570 player[i].lastpathfindpoint4=-1;
9572 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){
9573 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9574 else player[i].drawkeydown=0;
9575 player[i].rabbitkickenabled=Random()%2;
9576 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9577 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9578 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;
9579 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9580 Normalise(&rotatetarget);
9581 player[i].targetrotation=-asin(0-rotatetarget.x);
9582 player[i].targetrotation*=360/6.28;
9583 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9584 player[i].lookrotation=player[i].targetrotation;
9585 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9587 oldkey=player[i].forwardkeydown;
9588 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9589 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;
9590 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9591 else player[i].forwardkeydown=0;
9593 player[i].forwardkeydown=0;
9594 if(Random()%10==0)player[i].forwardkeydown=1;
9595 if(Random()%100==0){
9596 player[i].aitype=pathfindtype;
9597 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9598 player[i].finalpathfindpoint=-1;
9599 player[i].targetpathfindpoint=-1;
9600 player[i].lastpathfindpoint=-1;
9601 player[i].lastpathfindpoint2=-1;
9602 player[i].lastpathfindpoint3=-1;
9603 player[i].lastpathfindpoint4=-1;
9606 player[i].leftkeydown=0;
9607 player[i].backkeydown=0;
9608 player[i].rightkeydown=0;
9609 player[i].crouchkeydown=0;
9610 player[i].throwkeydown=0;
9612 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9613 /*for(j=0;j<numplayers;j++){
9614 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9615 player[i].crouchkeydown=1;
9618 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9619 else player[i].attackkeydown=0;
9620 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9621 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9622 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9623 player[i].attackkeydown=0;
9624 if(player[i].isIdle())player[i].crouchkeydown=1;
9625 player[i].forwardkeydown=0;
9626 player[i].aiupdatedelay=.02;
9629 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9631 for(j=0;j<numplayers;j++){
9632 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)){
9633 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))))){
9634 if(target>=0)target=-1;
9639 if(target>=0)player[target].Reverse();
9642 if(player[i].collided<1)player[i].jumpkeydown=0;
9643 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;
9644 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9645 player[0].jumpkeydown=0;
9646 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9647 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9648 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9650 if(tutoriallevel==1){
9651 if(!canattack)player[i].attackkeydown=0;
9655 facing=player[i].coords;
9656 flatfacing=player[0].coords;
9657 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9658 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9659 if(player[i].occluded>=2)
9660 if(-1!=checkcollide(facing,flatfacing)){
9661 if(!player[i].pause)player[i].lastseentime-=.2;
9662 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9663 player[i].aitype=searchtype;
9664 player[i].lastchecktime=12;
9665 player[i].lastseen=player[0].coords;
9666 player[i].lastseentime=12;
9669 else player[i].lastseentime=1;
9672 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9673 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9674 test=player[0].coords;
9676 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9679 // NOTE: Ask about logic of this call : NOTE
9680 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9681 player[i].stunned>0 ||
9682 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9684 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9685 player[i].targetrotation=player[i].rotation;
9686 player[i].forwardkeydown=0;
9687 player[i].leftkeydown=0;
9688 player[i].backkeydown=0;
9689 player[i].rightkeydown=0;
9690 player[i].jumpkeydown=0;
9691 player[i].attackkeydown=0;
9692 player[i].crouchkeydown=0;
9693 player[i].throwkeydown=0;
9700 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9703 if(player[i].aitype==attacktypecutoff){
9704 rotatetarget=player[0].coords-player[i].coords;
9705 Normalise(&rotatetarget);
9706 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9707 player[i].targetheadrotation*=360/6.28;
9708 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9710 player[i].targetheadrotation*=-1;
9711 player[i].targetheadrotation+=180;
9712 //player[i].targetheadrotation2=0;
9713 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9715 else if(player[i].howactive>=typesleeping){
9716 player[i].targetheadrotation=player[i].targetrotation;
9717 player[i].targetheadrotation2=0;
9720 if(player[i].interestdelay<=0){
9721 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9722 player[i].headtarget=player[i].coords;
9723 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9724 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9725 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9726 player[i].headtarget+=player[i].facing*1.5;
9728 rotatetarget=player[i].headtarget-player[i].coords;
9729 Normalise(&rotatetarget);
9730 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9731 player[i].targetheadrotation*=360/6.28;
9732 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9734 player[i].targetheadrotation*=-1;
9735 player[i].targetheadrotation+=180;
9736 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9738 //if(whichlevel==2)player[i].jumpkeydown=0;
9740 if(animation[player[i].targetanimation].attack==reversed){
9741 //player[i].targetrotation=player[i].rotation;
9742 player[i].forwardkeydown=0;
9743 player[i].leftkeydown=0;
9744 player[i].backkeydown=0;
9745 player[i].rightkeydown=0;
9746 player[i].jumpkeydown=0;
9747 player[i].attackkeydown=0;
9748 //player[i].crouchkeydown=0;
9749 player[i].throwkeydown=0;
9753 player[i].forwardkeydown=0;
9754 player[i].leftkeydown=0;
9755 player[i].backkeydown=0;
9756 player[i].rightkeydown=0;
9757 player[i].jumpkeydown=0;
9758 player[i].crouchkeydown=0;
9759 player[i].drawkeydown=0;
9760 player[i].throwkeydown=0;
9763 if(player[i].collided<-.3)player[i].collided=-.3;
9764 if(player[i].collided>1)player[i].collided=1;
9765 player[i].collided-=multiplier*4;
9766 player[i].whichdirectiondelay-=multiplier;
9767 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
9768 player[i].avoidcollided=-.3;
9769 player[i].whichdirection=abs(Random()%2);
9770 player[i].whichdirectiondelay=.4;
9772 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
9773 player[i].avoidcollided-=multiplier/4;
9774 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
9775 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
9776 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;
9778 if(!player[i].throwkeydown){
9779 player[i].throwtogglekeydown=0;
9781 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
9782 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)){
9783 for(j=0;j<weapons.numweapons;j++){
9784 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)
9785 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
9786 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
9787 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
9788 player[i].throwtogglekeydown=1;
9789 player[i].targetanimation=crouchremoveknifeanim;
9791 player[i].targetframe=0;
9792 rotatetarget=weapons.position[j]-player[i].coords;
9793 Normalise(&rotatetarget);
9794 player[i].targetrotation=-asin(0-rotatetarget.x);
9795 player[i].targetrotation*=360/6.28;
9796 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9797 player[i].hasvictim=0;
9799 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9800 player[i].throwtogglekeydown=1;
9801 player[i].hasvictim=0;
9803 //for(i=0;i<weapons.numweapons;i++){
9804 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))
9805 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
9806 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
9809 gLoc[0]=player[i].coords.x;
9810 gLoc[1]=player[i].coords.y;
9811 gLoc[2]=player[i].coords.z;
9812 vel[0]=player[i].velocity.x;
9813 vel[1]=player[i].velocity.y;
9814 vel[2]=player[i].velocity.z;
9815 if(weapons.type[j]!=staff){
9816 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9817 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9818 OPENAL_SetVolume(channels[knifedrawsound], 128);
9819 OPENAL_SetPaused(channels[knifedrawsound], false);
9822 player[i].weaponactive=0;
9823 weapons.owner[j]=player[i].id;
9824 if(player[i].num_weapons>0){
9825 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9827 player[i].num_weapons++;
9828 player[i].weaponids[0]=j;
9834 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){
9835 if(!player[i].isFlip()){
9836 player[i].throwtogglekeydown=1;
9837 player[i].targetanimation=removeknifeanim;
9839 player[i].targetframe=0;
9840 rotatetarget=weapons.position[j]-player[i].coords;
9841 Normalise(&rotatetarget);
9842 player[i].targetrotation=-asin(0-rotatetarget.x);
9843 player[i].targetrotation*=360/6.28;
9844 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9846 if(player[i].isFlip()){
9847 player[i].throwtogglekeydown=1;
9848 player[i].hasvictim=0;
9850 for(k=0;k<weapons.numweapons;k++){
9851 if(player[i].weaponactive==-1)
9852 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))
9853 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
9856 gLoc[0]=player[i].coords.x;
9857 gLoc[1]=player[i].coords.y;
9858 gLoc[2]=player[i].coords.z;
9859 vel[0]=player[i].velocity.x;
9860 vel[1]=player[i].velocity.y;
9861 vel[2]=player[i].velocity.z;
9862 if(weapons.type[k]!=staff){
9863 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9864 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9865 OPENAL_SetVolume(channels[knifedrawsound], 128);
9866 OPENAL_SetPaused(channels[knifedrawsound], false);
9869 player[i].weaponactive=0;
9870 weapons.owner[k]=player[i].id;
9871 if(player[i].num_weapons>0){
9872 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9874 player[i].num_weapons++;
9875 player[i].weaponids[0]=k;
9882 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9884 for(j=0;j<numplayers;j++){
9885 if(player[i].weaponactive==-1)
9887 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)){
9888 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
9889 player[i].throwtogglekeydown=1;
9890 player[i].victim=&player[j];
9891 player[i].hasvictim=1;
9892 player[i].targetanimation=crouchremoveknifeanim;
9894 player[i].targetframe=0;
9895 rotatetarget=player[j].coords-player[i].coords;
9896 Normalise(&rotatetarget);
9897 player[i].targetrotation=-asin(0-rotatetarget.x);
9898 player[i].targetrotation*=360/6.28;
9899 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9901 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9902 player[i].throwtogglekeydown=1;
9903 player[i].victim=&player[j];
9904 player[i].hasvictim=1;
9905 int k = player[j].weaponids[0];
9906 if(player[i].hasvictim){
9909 gLoc[0]=player[i].coords.x;
9910 gLoc[1]=player[i].coords.y;
9911 gLoc[2]=player[i].coords.z;
9912 vel[0]=player[i].velocity.x;
9913 vel[1]=player[i].velocity.y;
9914 vel[2]=player[i].velocity.z;
9917 if(player[i].victim->weaponstuck!=-1){
9918 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9923 if(weapons.type[k]!=staff){
9924 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9925 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9926 OPENAL_SetVolume(channels[knifedrawsound], 128);
9927 OPENAL_SetPaused(channels[knifedrawsound], false);
9931 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
9932 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
9933 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
9934 OPENAL_SetPaused(channels[fleshstabremovesound], false);
9937 player[i].weaponactive=0;
9938 if(weapons.owner[k]!=-1){
9939 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
9940 else player[i].victim->num_weapons=1;
9942 player[i].victim->skeleton.longdead=0;
9943 player[i].victim->skeleton.free=1;
9944 player[i].victim->skeleton.broken=0;
9946 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
9947 player[i].victim->skeleton.joints[l].velchange=0;
9948 player[i].victim->skeleton.joints[l].locked=0;
9954 Normalise(&relative);
9955 XYZ footvel,footpoint;
9957 footpoint=weapons.position[k];
9958 if(player[i].victim->weaponstuck!=-1){
9959 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9960 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
9961 weapons.bloody[k]=2;
9962 weapons.blooddrip[k]=5;
9963 player[i].victim->weaponstuck=-1;
9964 player[i].victim->bloodloss+=2000;
9965 player[i].victim->DoDamage(2000);
9968 if(player[i].victim->num_weapons>0){
9969 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
9970 if(player[i].victim->weaponids[0]==k)
9971 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
9974 player[i].victim->weaponactive=-1;
9976 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
9977 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
9978 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
9979 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
9982 if(player[i].num_weapons>0){
9983 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9985 player[i].num_weapons++;
9986 player[i].weaponids[0]=k;
9993 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9994 if(weapons.type[player[i].weaponids[0]]==knife){
9995 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
9997 for(j=0;j<numplayers;j++){
9999 if(tutoriallevel!=1||tutorialstage==49)
10001 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)){
10002 if(!player[i].isFlip()){
10003 player[i].throwtogglekeydown=1;
10004 player[i].victim=&player[j];
10005 player[i].targetanimation=knifethrowanim;
10006 player[i].target=0;
10007 player[i].targetframe=0;
10008 rotatetarget=player[j].coords-player[i].coords;
10009 Normalise(&rotatetarget);
10010 player[i].targetrotation=-asin(0-rotatetarget.x);
10011 player[i].targetrotation*=360/6.28;
10012 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10014 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10016 if(player[i].isFlip()){
10017 if(player[i].weaponactive!=-1){
10018 player[i].throwtogglekeydown=1;
10019 player[i].victim=&player[j];
10021 weapons.owner[player[i].weaponids[0]]=-1;
10022 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);
10025 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10027 weapons.velocity[player[i].weaponids[0]]=aim*50;
10028 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10029 weapons.missed[player[i].weaponids[0]]=0;
10030 weapons.freetime[player[i].weaponids[0]]=0;
10031 weapons.firstfree[player[i].weaponids[0]]=1;
10032 weapons.physics[player[i].weaponids[0]]=0;
10033 player[i].num_weapons--;
10034 if(player[i].num_weapons){
10035 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10037 player[i].weaponactive=-1;
10044 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10045 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10047 player[i].throwtogglekeydown=1;
10048 weapons.owner[player[i].weaponids[0]]=-1;
10049 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10050 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10051 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10052 weapons.missed[player[i].weaponids[0]]=1;
10053 weapons.freetime[player[i].weaponids[0]]=0;
10054 weapons.firstfree[player[i].weaponids[0]]=1;
10055 weapons.physics[player[i].weaponids[0]]=1;
10056 player[i].num_weapons--;
10057 if(player[i].num_weapons){
10058 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10059 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10062 player[i].weaponactive=-1;
10063 for(j=0;j<numplayers;j++){
10064 player[j].wentforweapon=0;
10071 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10072 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)){
10073 //Setenvironment(1-environment);
10076 if(player[i].weaponactive!=-1){
10077 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10079 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10080 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10081 player[i].targetanimation=drawrightanim;
10082 player[i].targetframe=0;
10083 player[i].target=0;
10084 player[i].drawtogglekeydown=1;
10086 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){
10087 player[i].targetanimation=drawleftanim;
10088 player[i].targetframe=0;
10089 player[i].target=0;
10090 player[i].drawtogglekeydown=1;
10092 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10093 player[i].targetanimation=crouchdrawrightanim;
10094 player[i].targetframe=0;
10095 player[i].target=0;
10096 player[i].drawtogglekeydown=1;
10100 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){
10101 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10102 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10103 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10104 player[i].targetframe=0;
10105 player[i].target=0;
10106 player[i].hasvictim=0;
10107 //player[i].attacktogglekeydown=1;
10111 if(!player[i].drawkeydown){
10112 player[i].drawtogglekeydown=0;
10117 absflatfacing.z=-1;
10119 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10121 else absflatfacing=flatfacing;
10123 if(indialogue!=-1){
10124 player[i].forwardkeydown=0;
10125 player[i].leftkeydown=0;
10126 player[i].backkeydown=0;
10127 player[i].rightkeydown=0;
10128 player[i].jumpkeydown=0;
10129 player[i].crouchkeydown=0;
10130 player[i].drawkeydown=0;
10131 player[i].throwkeydown=0;
10135 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10136 if(!player[i].forwardkeydown){
10137 player[i].forwardstogglekeydown=0;
10139 if(player[i].crouchkeydown){
10143 player[i].superruntoggle=1;
10145 for(j=0;j<numplayers;j++){
10146 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10147 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10148 player[i].superruntoggle=0;
10155 for(j=0;j<numplayers;j++){
10156 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10157 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))){
10158 if(target>=0)target=-1;
10163 if(target>=0)player[target].Reverse();
10164 player[i].lowreversaldelay=.5;
10166 if(player[i].isIdle()){
10167 player[i].targetanimation=player[i].getCrouch();
10168 player[i].target=0;
10169 player[i].targetframe=0;
10170 player[i].transspeed=10;
10172 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10173 player[i].targetanimation=rollanim;
10174 player[i].target=0;
10175 player[i].targetframe=0;
10176 player[i].transspeed=20;
10179 if(!player[i].crouchkeydown){
10181 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10183 if(player[i].isCrouch()){
10185 for(j=0;j<numplayers;j++){
10186 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10187 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10188 if(target>=0)target=-1;
10193 if(target>=0)player[target].Reverse();
10194 player[i].highreversaldelay=.5;
10196 if(player[i].isCrouch()){
10197 if(!player[i].wasCrouch()){
10198 player[i].currentanimation=player[i].getCrouch();
10199 player[i].currentframe=0;
10201 player[i].target=0;
10202 player[i].targetanimation=player[i].getIdle();
10203 player[i].targetframe=0;
10204 player[i].transspeed=10;
10207 if(player[i].targetanimation==sneakanim){
10208 player[i].targetanimation=player[i].getIdle();
10209 player[i].target=0;
10210 player[i].targetframe=0;
10211 player[i].transspeed=10;
10214 if(player[i].forwardkeydown){
10215 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)){
10216 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10217 else player[i].targetanimation=player[i].getRun();
10218 player[i].target=0;
10219 player[i].targetframe=0;
10221 if(player[i].isCrouch()){
10222 player[i].targetanimation=sneakanim;
10223 if(player[i].wasCrouch())player[i].target=0;
10224 player[i].targetframe=0;
10226 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10227 player[i].targetanimation=climbanim;
10228 player[i].target=0;
10229 player[i].targetframe=1;
10230 player[i].jumpclimb=1;
10232 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10233 player[i].velocity+=absflatfacing*5*multiplier;
10235 player[i].forwardstogglekeydown=1;
10238 if (player[i].rightkeydown){
10239 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)){
10240 player[i].targetanimation=player[i].getRun();
10241 player[i].target=0;
10242 player[i].targetframe=0;
10244 if(player[i].isCrouch()){
10245 player[i].targetanimation=sneakanim;
10246 if(player[i].wasCrouch()) player[i].target=0;
10247 player[i].targetframe=0;
10249 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10250 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10252 player[i].targetrotation-=90;
10253 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10254 if(player[i].backkeydown)player[i].targetrotation-=45;
10257 if ( player[i].leftkeydown){
10258 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)){
10259 player[i].targetanimation=player[i].getRun();
10260 player[i].target=0;
10261 player[i].targetframe=0;
10263 if(player[i].isCrouch()){
10264 player[i].targetanimation=sneakanim;
10265 if(player[i].wasCrouch())player[i].target=0;
10266 player[i].targetframe=0;
10268 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10269 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10271 player[i].targetrotation+=90;
10272 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10273 if(player[i].backkeydown)player[i].targetrotation+=45;
10276 if(player[i].backkeydown){
10277 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)){
10278 player[i].targetanimation=player[i].getRun();
10279 player[i].target=0;
10280 player[i].targetframe=0;
10282 if(player[i].isCrouch()){
10283 player[i].targetanimation=sneakanim;
10284 if(player[i].wasCrouch())player[i].target=0;
10285 player[i].targetframe=0;
10287 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10288 player[i].velocity-=absflatfacing*5*multiplier;
10290 if(player[i].targetanimation==hanganim){
10291 player[i].currentanimation=jumpdownanim;
10292 player[i].targetanimation=jumpdownanim;
10293 player[i].target=0;
10294 player[i].currentframe=0;
10295 player[i].targetframe=1;
10296 player[i].velocity=0;
10297 player[i].velocity.y+=gravity;
10298 player[i].coords.y-=1.4;
10299 player[i].grabdelay=1;
10301 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10302 player[i].targetrotation+=180;
10305 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10306 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)){
10307 player[i].jumpstart=0;
10308 player[i].targetanimation=jumpupanim;
10309 player[i].target=0;
10310 player[i].targetframe=0;
10311 player[i].rotation=player[i].targetrotation;
10312 player[i].transspeed=20;
10313 player[i].FootLand(0,1);
10314 player[i].FootLand(1,1);
10318 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10320 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10321 if(!movekey)player[i].velocity=0;
10326 for(j=0;j<numplayers;j++){
10327 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10328 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10329 if(target>=0)target=-1;
10334 if(target>=0)player[i].velocity.y=1;
10335 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10336 player[i].velocity.y=7;
10337 player[i].crouchtogglekeydown=1;
10339 else player[i].velocity.y=5;
10341 if(mousejump&&i==0&&debugmode){
10342 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10343 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10346 player[i].coords.y+=.2;
10347 player[i].jumppower-=1;
10349 static float gLoc[3];
10350 static float vel[3];
10351 gLoc[0]=player[i].coords.x;
10352 gLoc[1]=player[i].coords.y;
10353 gLoc[2]=player[i].coords.z;
10354 vel[0]=player[i].velocity.x;
10355 vel[1]=player[i].velocity.y;
10356 vel[2]=player[i].velocity.z;
10359 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10360 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10361 OPENAL_SetVolume(channels[whooshsound], 128);
10362 OPENAL_SetPaused(channels[whooshsound], false);
10365 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10366 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10367 OPENAL_SetVolume(channels[jumpsound], 128);
10368 OPENAL_SetPaused(channels[jumpsound], false);
10370 if((player[i].isIdle())&&player[i].jumppower>1){
10371 player[i].targetanimation=player[i].getLanding();
10372 player[i].landhard=0;
10373 player[i].target=0;
10374 player[i].targetframe=2;
10375 player[i].jumpstart=1;
10376 player[i].tempdeltav=deltav;
10378 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10379 if(player[i].jumppower>multiplier*6){
10380 player[i].velocity.y+=multiplier*6;
10381 player[i].jumppower-=multiplier*6;
10383 if(player[i].jumppower<=multiplier*6){
10384 player[i].velocity.y+=player[i].jumppower;
10385 player[i].jumppower=0;
10388 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10392 if(player[i].isRun()||player[i].targetanimation==walkanim){
10393 player[i].targetanimation=player[i].getStop();
10394 player[i].target=0;
10395 player[i].targetframe=0;
10397 if(player[i].targetanimation==sneakanim){
10398 player[i].targetanimation=player[i].getCrouch();
10399 if(player[i].currentanimation==sneakanim)player[i].target=0;
10400 player[i].targetframe=0;
10403 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10404 player[i].targetanimation=player[i].getStop();
10405 player[i].target=0;
10406 player[i].targetframe=0;
10408 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10409 player[i].targetanimation=player[i].getStop();
10410 player[i].target=0;
10411 player[i].targetframe=0;
10415 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10419 for(k=0;k<numplayers;k++){
10420 if(abs(player[k].rotation-player[k].targetrotation)>180){
10421 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10422 else player[k].rotation+=360;
10425 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10426 player[k].targetanimation=player[k].getStop();
10427 player[k].targetframe=0;
10428 player[k].target=0;
10431 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10432 player[k].targettilt=0;
10434 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10435 player[k].targettilt=0;
10436 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10437 player[k].jumppower+=multiplier*7;
10438 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10439 //*(1-(player[k].damage/player[k].damagetolerance))
10440 if(player[k].jumppower>5)player[k].jumppower=5;
10443 if(player[k].isRun()){
10444 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10447 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10448 else if(player[k].tilt>player[k].targettilt){
10449 player[k].tilt-=multiplier*150;
10451 else if(player[k].tilt<player[k].targettilt){
10452 player[k].tilt+=multiplier*150;
10455 player[k].grabdelay-=multiplier;
10458 for(k=0;k<numplayers;k++){
10459 player[k].DoAnimations();
10460 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10461 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10466 player[0].righthandmorphstart=0;
10467 player[0].righthandmorphend=1;
10468 player[0].lefthandmorphstart=0;
10469 player[0].lefthandmorphend=1;
10470 player[0].headmorphstart=0;
10471 player[0].headmorphend=2;*/
10474 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10475 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10476 player[0].righthandmorphend=1;
10477 player[0].targetrighthandmorphness=1;
10479 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10480 player[0].lefthandmorphend=0;
10481 player[0].targetlefthandmorphness=1;
10483 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10484 player[0].headmorphend=2;
10485 player[0].targetheadmorphness=1;
10487 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10488 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10489 player[0].righthandmorphend=0;
10490 player[0].targetrighthandmorphness=1;
10492 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10493 player[0].lefthandmorphend=1;
10494 player[0].targetlefthandmorphness=1;
10496 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10497 player[0].headmorphend=0;
10498 player[0].targetheadmorphness=1;
10501 if(numenvsounds!=0)
10502 for(j=numenvsounds-1;j>=0;j--){
10503 envsoundlife[j]-=multiplier;
10504 if(envsoundlife[j]<0){
10506 envsoundlife[j]=envsoundlife[numenvsounds];
10507 envsound[j]=envsound[numenvsounds];
10510 if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
10511 if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
10513 if(tutoriallevel==1){
10530 if(tutorialstage>=51)
10531 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10532 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10533 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
10535 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10536 OPENAL_SetPaused(channels[stream_music3], false);
10537 OPENAL_SetVolume(channels[stream_music3], 256);
10542 float gLoc[3]={0,0,0};
10543 float vel[3]={0,0,0};
10544 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10545 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10546 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10547 OPENAL_SetVolume(channels[fireendsound], 256);
10548 OPENAL_SetPaused(channels[fireendsound], false);
10549 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10557 if(tutorialstage<51)
10558 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10561 gLoc[0]=player[0].coords.x;
10562 gLoc[1]=player[0].coords.y;
10563 gLoc[2]=player[0].coords.z;
10567 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10568 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10569 OPENAL_SetVolume(channels[fireendsound], 256);
10570 OPENAL_SetPaused(channels[fireendsound], false);
10572 player[0].coords=(oldtemp+oldtemp2)/2;
10580 if(tutorialstage>=14&&tutorialstage<50)
10581 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10584 gLoc[0]=player[1].coords.x;
10585 gLoc[1]=player[1].coords.y;
10586 gLoc[2]=player[1].coords.z;
10590 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10591 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10592 OPENAL_SetVolume(channels[fireendsound], 256);
10593 OPENAL_SetPaused(channels[fireendsound], false);
10595 for(int i=0;i<player[1].skeleton.num_joints;i++){
10597 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10598 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10599 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;
10600 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10601 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10605 player[1].coords=(oldtemp+oldtemp2)/2;
10606 for(int i=0;i<player[1].skeleton.num_joints;i++){
10607 player[1].skeleton.joints[i].velocity=0;
10609 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10610 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10611 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;
10612 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10613 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10621 static float gLoc[3];
10625 static float vel[3];
10626 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10627 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10628 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10630 //Set orientation with forward and up vectors
10631 static XYZ upvector;
10635 upvector=DoRotation(upvector,-rotation2+90,0,0);
10636 upvector=DoRotation(upvector,0,0-rotation,0);
10641 facing=DoRotation(facing,-rotation2,0,0);
10642 facing=DoRotation(facing,0,0-rotation,0);
10645 static float ori[6];
10646 ori[0] = -facing.x;
10648 ori[2] = -facing.z;
10649 ori[3] = -upvector.x;
10650 ori[4] = upvector.y;
10651 ori[5] = -upvector.z;
10653 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10660 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10662 freezetogglekeydown=1;
10666 void Game::TickOnce(){
10669 if(directing||indialogue==-1){
10670 rotation+=deltah*.7;
10671 if(!invertmouse)rotation2+=deltav*.7;
10672 if(invertmouse)rotation2-=deltav*.7;
10673 if(rotation2>90)rotation2=90;
10674 if(rotation2<-70)rotation2=-70;
10676 if(mainmenu)rotation+=multiplier*5;
10681 void Game::TickOnceAfter(){
10682 static XYZ colviewer;
10683 static XYZ coltarget;
10686 static float brotate;
10689 static float changedelay;
10690 static bool alldead;
10691 static float unseendelay;
10692 static float cameraspeed;
10696 if(environment==snowyenvironment)music1=stream_music1snow;
10697 if(environment==grassyenvironment)music1=stream_music1grass;
10698 if(environment==desertenvironment)music1=stream_music1desert;
10703 for(i=0;i<numplayers;i++){
10704 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)){
10705 musictype=stream_music2;
10709 if(player[0].dead)musictype=stream_music3;
10712 if(musictype==stream_music2){
10716 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10717 unseendelay-=multiplier;
10719 musictype=stream_music2;
10725 musictype=stream_music3;
10726 musicvolume[2]=512;
10733 if(musictype!=oldmusictype&&musictype==stream_music2){
10734 static float gLoc[3];
10735 static float vel[3];
10736 gLoc[0]=cameraloc.x;
10737 gLoc[1]=cameraloc.y;
10738 gLoc[2]=cameraloc.z;
10742 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
10743 OPENAL_SetVolume(channels[alarmsound], 512);
10744 OPENAL_SetPaused(channels[alarmsound], false);
10748 musicselected=musictype;
10750 if(musicselected==music1)musicvolume[0]+=multiplier*450;
10751 else musicvolume[0]-=multiplier*450;
10752 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
10753 else musicvolume[1]-=multiplier*450;
10754 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
10755 else musicvolume[2]-=multiplier*450;
10757 if(musicselected==music1)musicvolume[0]+=multiplier*100;
10758 else musicvolume[0]-=multiplier*450;
10759 if(musicselected==music2)musicvolume[1]+=multiplier*150;
10760 else if(player[0].dead)musicvolume[1]-=multiplier*450;
10761 else musicvolume[1]-=multiplier*100;
10762 if(musicselected==music3)musicvolume[2]+=multiplier*450;
10763 else musicvolume[2]-=multiplier*450;*/
10766 if(musicvolume[i]<0)musicvolume[i]=0;
10767 if(musicvolume[i]>512)musicvolume[i]=512;
10770 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
10773 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
10774 PlayStreamEx( music1, strm[music1], NULL, true);
10775 OPENAL_SetPaused(channels[music1], false);
10777 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
10778 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
10779 OPENAL_SetPaused(channels[stream_music2], false);
10781 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
10782 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10783 OPENAL_SetPaused(channels[stream_music3], false);
10788 OPENAL_SetPaused(channels[music1], true);
10789 OPENAL_SetPaused(channels[stream_music2], true);
10790 OPENAL_SetPaused(channels[stream_music3], true);
10793 oldmusicvolume[i]=0;
10799 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
10800 OPENAL_SetPaused(channels[music1], true);
10802 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
10803 OPENAL_SetPaused(channels[stream_music2], true);
10805 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
10806 OPENAL_SetPaused(channels[stream_music3], true);
10809 if(musicvolume[0]!=oldmusicvolume[0]){
10810 OPENAL_SetVolume(channels[music1], musicvolume[0]);
10812 if(musicvolume[1]!=oldmusicvolume[1]){
10813 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
10815 if(musicvolume[2]!=oldmusicvolume[2]){
10816 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
10820 oldmusicvolume[i]=musicvolume[i];
10826 for(i=0;i<numhotspots;i++){
10827 if(hotspottype[i]>10&&hotspottype[i]<20){
10828 if(player[hotspottype[i]-10].dead==0){
10831 else if(killhotspot==2)
10835 if(killhotspot==2)killhotspot=0;
10840 for(i=0;i<numhotspots;i++){
10841 if(hotspottype[i]==-1){
10842 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
10849 for(i=1;i<numplayers;i++){
10850 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
10852 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
10854 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
10855 if(player[0].dead&&changedelay<=0){
10857 targetlevel=whichlevel;
10861 for(i=1;i<numplayers;i++){
10862 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
10866 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
10868 targetlevel=whichlevel+1;
10869 if(targetlevel>numchallengelevels-1)targetlevel=0;
10871 if(winhotspot||windialogue){
10873 targetlevel=whichlevel+1;
10874 if(targetlevel>numchallengelevels-1)targetlevel=0;
10880 targetlevel=whichlevel+1;
10881 if(targetlevel>numchallengelevels-1)targetlevel=0;
10884 if(changedelay>0&&!player[0].dead&&!won){
10885 //high scores, awards, win
10888 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10889 accountcampaignchoicesmade[accountactive]++;
10890 accountcampaignscore[accountactive]+=bonustotal;
10892 accountcampaigntime[accountactive]+=leveltime;
10893 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
10895 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10901 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
10902 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
10904 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10920 if(!editorenabled&&gameon&&!mainmenu){
10921 if(changedelay!=-999)changedelay-=multiplier/7;
10922 if(player[0].dead)targetlevel=whichlevel;
10923 if(loading==2&&!campaign){
10931 float gLoc[3]={0,0,0};
10932 float vel[3]={0,0,0};
10933 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10934 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10935 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10936 OPENAL_SetVolume(channels[firestartsound], 256);
10937 OPENAL_SetPaused(channels[firestartsound], false);
10938 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10940 if(!player[0].dead&&targetlevel!=whichlevel){
10941 startbonustotal=bonustotal;
10943 if(!player[0].dead)Loadlevel(targetlevel);
10944 if(player[0].dead)Loadlevel(whichlevel);
10946 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10947 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10948 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10949 OPENAL_SetVolume(channels[fireendsound], 256);
10950 OPENAL_SetPaused(channels[fireendsound], false);
10951 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10955 if(loading==2&&targetlevel==whichlevel){
10963 float gLoc[3]={0,0,0};
10964 float vel[3]={0,0,0};
10965 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10966 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10967 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10968 OPENAL_SetVolume(channels[firestartsound], 256);
10969 OPENAL_SetPaused(channels[firestartsound], false);
10970 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10972 for(i=0;i<255;i++){
10986 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
10987 Loadlevel(mapname);
10989 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10990 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10991 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10992 OPENAL_SetVolume(channels[fireendsound], 256);
10993 OPENAL_SetPaused(channels[fireendsound], false);
10994 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10998 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
10999 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11001 if(whichlevel!=-2&&!loading&&!player[0].dead){
11005 if(player[0].dead)loading=1;
11011 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11012 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11016 else if(mainmenu==0&&winfreeze){
11017 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11019 else stealthloading=0;
11021 if(!stealthloading){
11022 float gLoc[3]={0,0,0};
11023 float vel[3]={0,0,0};
11024 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11025 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11026 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11027 OPENAL_SetVolume(channels[firestartsound], 256);
11028 OPENAL_SetPaused(channels[firestartsound], false);
11029 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11040 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11041 //campaignnumlevels=0;
11042 //accountcampaignchoicesmade[accountactive]=0;
11043 ipstream.ignore(256,':');
11044 ipstream >> campaignnumlevels;
11045 for(i=0;i<campaignnumlevels;i++){
11046 ipstream.ignore(256,':');
11047 ipstream.ignore(256,':');
11048 ipstream.ignore(256,' ');
11049 ipstream >> campaignmapname[i];
11050 ipstream.ignore(256,':');
11051 ipstream >> campaigndescription[i];
11052 for(j=0;j<256;j++){
11053 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11055 ipstream.ignore(256,':');
11056 ipstream >> campaignchoosenext[i];
11057 ipstream.ignore(256,':');
11058 ipstream >> campaignnumnext[i];
11059 if(campaignnumnext[i])
11060 for(j=0;j<campaignnumnext[i];j++){
11061 ipstream.ignore(256,':');
11062 ipstream >> campaignnextlevel[i][j];
11063 campaignnextlevel[i][j]-=1;
11065 ipstream.ignore(256,':');
11066 ipstream >> campaignlocationx[i];
11067 ipstream.ignore(256,':');
11068 ipstream >> campaignlocationy[i];
11072 for(i=0;i<campaignnumlevels;i++){
11074 levelhighlight[i]=0;
11078 for(i=0;i<campaignnumlevels;i++){
11080 levelhighlight[i]=0;
11085 if(accountcampaignchoicesmade[accountactive])
11086 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11087 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11088 levelvisible[levelorder[i+1]]=1;
11090 int whichlevelstart;
11091 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11092 if(whichlevelstart<0){
11093 campaignchoicenum=1;
11094 campaignchoicewhich[0]=0;
11098 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11099 if(campaignchoicenum)
11100 for(i=0;i<campaignchoicenum;i++){
11101 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11102 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11103 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11110 //if(firstload)TickOnceAfter();
11111 if(!firstload)LoadStuff();
11113 for(i=0;i<255;i++){
11128 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11129 //accountcampaignchoicesmade[accountactive]++;
11132 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11136 Loadlevel(mapname);
11140 OPENAL_SetPaused(channels[stream_music3], true);
11145 if(loading==3)loading=0;
11149 oldmusictype=musictype;
11155 facing=DoRotation(facing,-rotation2,0,0);
11156 facing=DoRotation(facing,0,0-rotation,0);
11157 viewerfacing=facing;
11161 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;
11162 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;
11164 if(player[0].skeleton.free){
11165 for(i=0;i<player[0].skeleton.num_joints;i++){
11166 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11167 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11171 if(player[0].skeleton.free!=2&&!autocam){
11173 if(findLengthfast(&player[0].velocity)>400){
11174 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11176 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11177 coltarget=target-cameraloc;
11178 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11180 Normalise(&coltarget);
11181 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11182 else cameraloc=cameraloc+coltarget*multiplier*8;
11184 if(editorenabled)cameraloc=target;
11185 cameradist+=multiplier*5;
11186 if(cameradist>2.3)cameradist=2.3;
11187 viewer=cameraloc-facing*cameradist;
11189 coltarget=cameraloc;
11190 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11191 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11192 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11193 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11195 coltarget=cameraloc;
11196 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11198 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11199 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11200 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11202 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11206 cameradist=findDistance(&viewer,&target);
11207 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11208 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11210 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11211 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11214 if(player[0].skeleton.free!=2&&autocam){
11216 if(findLengthfast(&player[0].velocity)>400){
11217 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11219 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11220 cameradist+=multiplier*5;
11221 if(cameradist>3.3)cameradist=3.3;
11222 coltarget=target-cameraloc;
11223 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11224 else if(findLengthfast(&coltarget)>1)
11226 Normalise(&coltarget);
11227 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11228 else cameraloc=cameraloc+coltarget*multiplier*8;
11230 if(editorenabled)cameraloc=target;
11233 coltarget=cameraloc;
11234 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11235 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11236 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11237 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11239 coltarget=cameraloc;
11240 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11242 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11243 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11244 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11246 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11250 cameradist=findDistance(&viewer,&target);
11251 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11252 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11254 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11255 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11258 if(camerashake>.8)camerashake=.8;
11259 //if(woozy>10)woozy=10;
11260 //woozy+=multiplier;
11262 if(player[0].dead)camerashake=0;
11263 if(player[0].dead)woozy=0;
11264 camerashake-=multiplier*2;
11265 blackout-=multiplier*2;
11266 //if(player[0].isCrouch())woozy-=multiplier*8;
11267 if(camerashake<0)camerashake=0;
11268 if(blackout<0)blackout=0;
11269 //if(woozy<0)woozy=0;
11271 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11272 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11273 viewer.z+=(float)(Random()%100)*.0005*camerashake;