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];
226 static const char *rabbitskin[] = {
227 ":Data:Textures:Fur3.jpg",
228 ":Data:Textures:Fur.jpg",
229 ":Data:Textures:Fur2.jpg",
230 ":Data:Textures:Lynx.jpg",
231 ":Data:Textures:Otter.jpg",
232 ":Data:Textures:Opal.jpg",
233 ":Data:Textures:Sable.jpg",
234 ":Data:Textures:Chocolate.jpg",
235 ":Data:Textures:BW2.jpg",
236 ":Data:Textures:WB2.jpg"
239 static const char *wolfskin[] = {
240 ":Data:Textures:Wolf.jpg",
241 ":Data:Textures:Darkwolf.jpg",
242 ":Data:Textures:Snowwolf.jpg"
245 #define STATIC_ASSERT(x) extern int s_a_dummy[2 * (!!(x)) - 1];
246 STATIC_ASSERT (rabbittype == 0 && wolftype == 1)
248 static const char **creatureskin[] = {rabbitskin, wolfskin};
250 /********************> Tick() <*****/
251 extern OPENAL_STREAM * strm[20];
252 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
253 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
255 extern void ScreenShot(const char * fname);
256 void Screenshot (void)
259 time_t t = time(NULL);
260 struct tm *tme = localtime(&t);
261 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);
264 mkdir("Screenshots");
266 mkdir("Screenshots", S_IRWXU);
269 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
272 GraphicsExportComponent QT_exporter;
273 OSErr MAC_error_code;
274 CGrafPtr MAC_currentPort;
275 GDHandle MAC_currentDevice;
276 unsigned char* MAC_pixels;
277 Rect MAC_picture_rectangle;
278 GWorldPtr MAC_offscreen_graphics_port;
280 static int numscreenshots=0;
283 static char buf[256];
284 if(numscreenshots==0){
315 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
316 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
317 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
318 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
339 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
340 //assert(MAC_gWorld != NULL);
342 // Allocate memory for loading image
343 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
344 if (MAC_pixels == NULL) {
345 //UTIL_Error("Could not create Texture data.");
350 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
352 // Make a picture Rectangle
353 MAC_picture_rectangle.left = 0;
354 MAC_picture_rectangle.right = screenwidth;
355 MAC_picture_rectangle.top = 0;
356 MAC_picture_rectangle.bottom = screenheight;
358 // Create new offscreen GWorld
359 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
360 if (MAC_error_code) {
361 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
363 //UTIL_Error("Could not create offscreen GWorld. ");
368 // Copy OpenGL Context to new GWorld
369 glReadBuffer(GL_FRONT);
370 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
373 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
374 unsigned char temp = MAC_pixels[byte+0];
375 MAC_pixels[byte+0] = MAC_pixels[byte+3];
376 MAC_pixels[byte+3] = MAC_pixels[byte+2];
377 MAC_pixels[byte+2] = MAC_pixels[byte+1];
378 MAC_pixels[byte+1] = temp;
381 // Flip the image :( This could probably be optimized
386 for (int horz = 0; horz < screenwidth; ++horz)
387 for (vert = 0; vert < screenheight / 2; ++vert) {
388 src_index = (screenwidth * vert + horz) * 4;
389 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
391 temp=MAC_pixels[src_index+0];
392 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
393 MAC_pixels[dst_index+0]=temp;
395 temp=MAC_pixels[src_index+1];
396 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
397 MAC_pixels[dst_index+1]=temp;
399 temp=MAC_pixels[src_index+2];
400 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
401 MAC_pixels[dst_index+2]=temp;
403 temp=MAC_pixels[src_index+3];
404 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
405 MAC_pixels[dst_index+3]=temp;
411 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
412 if (MAC_error_code) {
413 //UTIL_Warning("Unable to export screenshot.");
414 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
415 ::DisposeGWorld(MAC_offscreen_graphics_port);
420 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
421 if (MAC_error_code) {
422 ::CloseComponent(QT_exporter);
423 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
424 ::DisposeGWorld(MAC_offscreen_graphics_port);
426 //UTIL_Warning("Unable to export screenshot.");
430 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
431 if (MAC_error_code) {
432 ::CloseComponent(QT_exporter);
433 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
434 ::DisposeGWorld(MAC_offscreen_graphics_port);
436 //UTIL_Warning("Unable to export screenshot.");
440 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
441 if (MAC_error_code) {
442 ::CloseComponent(QT_exporter);
443 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
444 ::DisposeGWorld(MAC_offscreen_graphics_port);
446 //UTIL_Warning("Unable to export screenshot.");
450 ::CloseComponent(QT_exporter);
451 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
452 ::DisposeGWorld(MAC_offscreen_graphics_port);
459 void Game::SetUpLighting(){
460 if(environment==snowyenvironment){
466 light.ambient[2]=.44;
468 if(environment==desertenvironment){
473 light.ambient[1]=.35;
477 if(environment==grassyenvironment){
483 light.ambient[2]=.44;
494 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
495 light.color[0]*=(skyboxlightr+average)/2;
496 light.color[1]*=(skyboxlightg+average)/2;
497 light.color[2]*=(skyboxlightb+average)/2;
498 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
499 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
500 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
504 light.ambient[2]=0; */
507 int Game::findPathDist(int start,int end){
508 int i,j,k,smallestcount,count,connected;
509 int last,last2,last3,last4;
519 while(last!=end&&count<30){
521 for(j=0;j<numpathpoints;j++){
522 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
525 if(numpathpointconnect[j])
526 for(k=0;k<numpathpointconnect[j];k++){
527 if(pathpointconnect[j][k]==last)connected=1;
530 if(numpathpointconnect[last])
531 for(k=0;k<numpathpointconnect[last];k++){
532 if(pathpointconnect[last][k]==j)connected=1;
535 if(closest==-1||Random()%2==0){
546 if(count<smallestcount)smallestcount=count;
548 return smallestcount;
551 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
552 static XYZ colpoint,colviewer,coltarget;
553 static float minx,minz,maxx,maxz,miny,maxy;
562 if(minx>endpoint.x)minx=endpoint.x;
564 if(miny>endpoint.y)miny=endpoint.y;
566 if(minz>endpoint.z)minz=endpoint.z;
569 if(maxx<endpoint.x)maxx=endpoint.x;
571 if(maxy<endpoint.y)maxy=endpoint.y;
573 if(maxz<endpoint.z)maxz=endpoint.z;
582 for(i=0;i<objects.numobjects;i++){
583 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){
584 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
585 colviewer=startpoint;
587 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
592 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
597 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
598 static XYZ colpoint,colviewer,coltarget;
599 static float minx,minz,maxx,maxz,miny,maxy;
608 if(minx>endpoint.x)minx=endpoint.x;
610 if(miny>endpoint.y)miny=endpoint.y;
612 if(minz>endpoint.z)minz=endpoint.z;
615 if(maxx<endpoint.x)maxx=endpoint.x;
617 if(maxy<endpoint.y)maxy=endpoint.y;
619 if(maxz<endpoint.z)maxz=endpoint.z;
629 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){
630 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
631 colviewer=startpoint;
633 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
638 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
643 void Game::Setenvironment(int which)
647 LOG(" Setting environment...");
652 OPENAL_SetPaused(channels[music1snow], true);
653 OPENAL_SetPaused(channels[music1grass], true);
654 OPENAL_SetPaused(channels[music1desert], true);
655 OPENAL_SetPaused(channels[wind], true);
656 OPENAL_SetPaused(channels[desertambient], true);
658 OPENAL_SetPaused(channels[stream_music1snow], true);
659 OPENAL_SetPaused(channels[stream_music1grass], true);
660 OPENAL_SetPaused(channels[stream_music1desert], true);
661 OPENAL_SetPaused(channels[stream_wind], true);
662 OPENAL_SetPaused(channels[stream_desertambient], true);
665 if(environment==snowyenvironment){
669 //PlaySoundEx( wind, samp[wind], NULL, true);
670 PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
671 OPENAL_SetPaused(channels[stream_wind], false);
672 OPENAL_SetVolume(channels[stream_wind], 256);
675 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
676 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
677 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
678 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
680 OPENAL_Sample_Free(samp[footstepsound]);
681 OPENAL_Sample_Free(samp[footstepsound2]);
682 OPENAL_Sample_Free(samp[footstepsound3]);
683 OPENAL_Sample_Free(samp[footstepsound4]);
684 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
685 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
686 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
687 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
688 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
689 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
690 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
691 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
693 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
695 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
697 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
702 temptexdetail=texdetail;
703 if(texdetail>1)texdetail=4;
704 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
705 ":Data:Textures:Skybox(snow):Left.jpg",
706 ":Data:Textures:Skybox(snow):Back.jpg",
707 ":Data:Textures:Skybox(snow):Right.jpg",
708 ":Data:Textures:Skybox(snow):Up.jpg",
709 ":Data:Textures:Skybox(snow):Down.jpg",
710 ":Data:Textures:Skybox(snow):Cloud.jpg",
711 ":Data:Textures:Skybox(snow):Reflect.jpg");
716 texdetail=temptexdetail;
718 if(environment==desertenvironment){
721 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
722 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
723 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
724 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
728 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
729 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
730 OPENAL_SetPaused(channels[stream_desertambient], false);
731 OPENAL_SetVolume(channels[stream_desertambient], 256);
734 OPENAL_Sample_Free(samp[footstepsound]);
735 OPENAL_Sample_Free(samp[footstepsound2]);
736 OPENAL_Sample_Free(samp[footstepsound3]);
737 OPENAL_Sample_Free(samp[footstepsound4]);
738 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
739 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
740 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
741 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
742 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
743 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
744 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
745 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
747 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
749 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
751 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
755 temptexdetail=texdetail;
756 if(texdetail>1)texdetail=4;
757 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
758 ":Data:Textures:Skybox(sand):Left.jpg",
759 ":Data:Textures:Skybox(sand):Back.jpg",
760 ":Data:Textures:Skybox(sand):Right.jpg",
761 ":Data:Textures:Skybox(sand):Up.jpg",
762 ":Data:Textures:Skybox(sand):Down.jpg",
763 ":Data:Textures:Skybox(sand):Cloud.jpg",
764 ":Data:Textures:Skybox(sand):Reflect.jpg");
769 texdetail=temptexdetail;
771 if(environment==grassyenvironment){
774 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
775 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
776 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
777 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
780 PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
781 OPENAL_SetPaused(channels[stream_wind], false);
782 OPENAL_SetVolume(channels[stream_wind], 100);
785 OPENAL_Sample_Free(samp[footstepsound]);
786 OPENAL_Sample_Free(samp[footstepsound2]);
787 OPENAL_Sample_Free(samp[footstepsound3]);
788 OPENAL_Sample_Free(samp[footstepsound4]);
789 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass1.ogg"), OPENAL_HW3D, 0, 0);
790 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass2.ogg"), OPENAL_HW3D, 0, 0);
791 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
792 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
793 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
794 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
795 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
796 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
798 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
800 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
802 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
806 temptexdetail=texdetail;
807 if(texdetail>1)texdetail=4;
808 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
809 ":Data:Textures:Skybox(grass):Left.jpg",
810 ":Data:Textures:Skybox(grass):Back.jpg",
811 ":Data:Textures:Skybox(grass):Right.jpg",
812 ":Data:Textures:Skybox(grass):Up.jpg",
813 ":Data:Textures:Skybox(grass):Down.jpg",
814 ":Data:Textures:Skybox(grass):Cloud.jpg",
815 ":Data:Textures:Skybox(grass):Reflect.jpg");
819 texdetail=temptexdetail;
821 temptexdetail=texdetail;
823 terrain.load(":Data:Textures:heightmap.png");
825 texdetail=temptexdetail;
829 void Game::Loadlevel(int which){
832 if(which==0)Loadlevel((char *)":Data:Maps:map1");
833 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
834 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
835 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
836 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
837 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
838 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
839 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
840 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
841 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
842 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
843 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
844 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
845 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
846 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
847 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
848 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
849 else Loadlevel((char *)":Data:Maps:mapsave");
854 /*char * Game::MD5_string (unsigned char *string){
858 strcpy(temp2,(const char *)string);
859 strcat((char *)temp2,(const char *)"Lugaru");
860 sprintf (temp, "%d",strlen((char *)temp2));
861 strcat((char *)temp2,temp);
864 unsigned int len = strlen ( (char *)temp2);
866 context.update ((unsigned char *)temp2, len);
869 return context.hex_digest();
874 void Game::Loadlevel(char *name){
881 float headprop,legprop,armprop,bodyprop;
885 LOG(std::string("Loading level...") + name);
887 if(!gameon)visibleloading=1;
889 if(stealthloading)visibleloading=0;
891 if(!stillloading)loadtime=0;
896 if(tutoriallevel!=-1)tutoriallevel=0;
897 else tutoriallevel=1;
899 if(tutoriallevel==1)tutorialstage=0;
900 if(tutorialstage==0){
908 OPENAL_SetPaused(channels[whooshsound], true);
909 OPENAL_SetPaused(channels[stream_firesound], true);
911 // Change the map filename into something that is os specific
912 char *FixedFN = ConvertFileName(name);
916 tfile=fopen( FixedFN, "rb" );
919 OPENAL_SetPaused(channels[stream_firesound], true);
930 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
936 dialoguegonethrough[i]=0;
945 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
947 if(difficulty!=2)minimap=1;
984 bonustotal=startbonustotal;
990 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
991 OPENAL_SetVolume(channels[consolesuccesssound], 256);
992 OPENAL_SetPaused(channels[consolesuccesssound], false);
1000 sprites.numsprites=0;
1001 for(i=0;i<objects.numobjects;i++)
1003 objects.model[i].numdecals=0;
1006 j=objects.numobjects;
1009 objects.DeleteObject(0);
1010 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1013 for(i=0;i<subdivision;i++)
1015 for(j=0;j<subdivision;j++)
1017 terrain.patchobjectnum[i][j]=0;
1020 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1023 weapons.numweapons=0;
1025 funpackf(tfile, "Bi", &mapvers);
1026 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1028 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1029 else maptype=mapkilleveryone;
1030 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1032 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1038 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1046 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1049 skyboxlightr=skyboxr;
1050 skyboxlightg=skyboxg;
1051 skyboxlightb=skyboxb;
1053 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);
1054 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1055 player[0].originalcoords=player[0].coords;
1056 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1058 for(j=0;j<player[0].num_weapons;j++)
1060 player[0].weaponids[j]=weapons.numweapons;
1061 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1062 weapons.owner[weapons.numweapons]=0;
1063 weapons.numweapons++;
1067 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1069 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1070 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1071 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1072 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1074 funpackf(tfile, "Bi", &player[0].numclothes);
1078 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1082 player[0].whichskin=0;
1083 player[0].creature=rabbittype;
1086 for(i=0;i<max_dialogues;i++)
1088 for(j=0;j<max_dialoguelength;j++)
1092 dialoguetext[i][j][k]='\0';
1096 dialoguename[i][j][k]='\0';
1101 player[0].lastattack=-1;
1102 player[0].lastattack2=-1;
1103 player[0].lastattack3=-1;
1107 funpackf(tfile, "Bi", &numdialogues);
1110 for(k=0;k<numdialogues;k++)
1112 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1113 funpackf(tfile, "Bi", &dialoguetype[k]);
1116 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1117 funpackf(tfile, "Bf", &participantrotation[k][l]);
1119 if(numdialogueboxes)
1121 for(l=0;l<numdialogueboxes[k];l++)
1123 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1124 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1125 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1126 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1127 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1131 funpackf(tfile, "Bi",&templength);
1132 if(templength>128||templength<=0)templength=128;
1133 for(m=0;m<templength;m++){
1134 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1135 if(dialoguetext[k][l][m]=='\0')break;
1138 funpackf(tfile, "Bi",&templength);
1139 if(templength>64||templength<=0)templength=64;
1140 for(m=0;m<templength;m++){
1141 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1142 if(dialoguename[k][l][m]=='\0'){
1146 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1147 funpackf(tfile, "Bi", &participantfocus[k][l]);
1148 funpackf(tfile, "Bi", &participantaction[k][l]);
1151 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1153 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1159 else numdialogues=0;
1161 if(player[0].numclothes)
1163 for(k=0;k<player[0].numclothes;k++)
1165 funpackf(tfile, "Bi", &templength);
1166 for(l=0;l<templength;l++)
1167 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1168 player[0].clothes[k][templength]='\0';
1169 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1173 funpackf(tfile, "Bi", &environment);
1175 funpackf(tfile, "Bi", &objects.numobjects);
1176 if(objects.numobjects)
1178 for(i=0;i<objects.numobjects;i++)
1180 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]);
1181 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1187 funpackf(tfile, "Bi", &numhotspots);
1190 for(i=0;i<numhotspots;i++)
1192 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1193 funpackf(tfile, "Bi", &templength);
1195 for(l=0;l<templength;l++)
1196 funpackf(tfile, "Bb", &hotspottext[i][l]);
1197 hotspottext[i][templength]='\0';
1198 if(hotspottype[i]==-111)indemo=1;
1204 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1209 for(i=0;i<objects.numobjects;i++)
1211 objects.center+=objects.position[i];
1213 objects.center/=objects.numobjects;
1216 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1218 float maxdistance=0;
1221 for(i=0;i<objects.numobjects;i++)
1223 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1224 if(tempdist>maxdistance)
1227 maxdistance=tempdist;
1230 objects.radius=fast_sqrt(maxdistance);
1233 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1234 //mapcenter=objects.center;
1235 //mapradius=objects.radius;
1237 funpackf(tfile, "Bi", &numplayers);
1238 int howmanyremoved=0;
1239 bool removeanother=0;
1240 if(numplayers>1&&numplayers<maxplayers)
1242 for(i=1;i<numplayers;i++)
1244 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1247 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);
1248 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1249 else player[i-howmanyremoved].howactive=typeactive;
1250 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1251 else player[i-howmanyremoved].scale=-1;
1252 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1253 else player[i-howmanyremoved].immobile=0;
1254 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1255 else player[i-howmanyremoved].rotation=0;
1256 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1257 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1263 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1265 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1267 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1268 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1269 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1270 weapons.numweapons++;
1273 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1274 //player[i-howmanyremoved].numwaypoints=10;
1275 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1277 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1278 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1279 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1280 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1281 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1284 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1285 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1287 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1288 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1289 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1290 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1292 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1300 if(player[i-howmanyremoved].creature==wolftype)
1302 player[i-howmanyremoved].proportionhead=1.1*headprop;
1303 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1304 player[i-howmanyremoved].proportionarms=1.1*armprop;
1305 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1308 if(player[i-howmanyremoved].creature==rabbittype)
1310 player[i-howmanyremoved].proportionhead=1.2*headprop;
1311 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1312 player[i-howmanyremoved].proportionarms=1.00*armprop;
1313 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1314 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1317 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1318 if(player[i-howmanyremoved].numclothes)
1320 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1323 funpackf(tfile, "Bi", &templength);
1324 for(l=0;l<templength;l++)
1325 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1326 player[i-howmanyremoved].clothes[k][templength]='\0';
1327 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1333 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1335 numplayers-=howmanyremoved;
1336 funpackf(tfile, "Bi", &numpathpoints);
1337 if(numpathpoints>30||numpathpoints<0)
1341 for(j=0;j<numpathpoints;j++)
1343 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1344 for(k=0;k<numpathpointconnect[j];k++){
1345 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1349 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1351 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1354 if(environment!=oldenvironment)Setenvironment(environment);
1355 oldenvironment=environment;
1359 j=objects.numobjects;
1360 objects.numobjects=0;
1363 //if(objects.type[i]!=spiketype)
1364 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1365 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1368 //if(skyboxtexture){
1369 terrain.DoShadows();
1370 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1371 objects.DoShadows();
1372 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1374 else terrain.DoLighting();
1380 oldlevel=whichlevel;
1383 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1384 for(i=0;i<numplayers;i++)
1386 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1390 if(i==0||player[i].scale<0)player[i].scale=.2;
1391 player[i].skeleton.free=0;
1392 player[i].skeleton.id=i;
1393 //if(Random()%2==0)player[i].creature=wolftype;
1394 //else player[i].creature=rabbittype;
1395 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1396 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);
1399 if(player[i].creature!=wolftype){
1400 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);
1401 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1403 if(player[i].creature==wolftype){
1404 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);
1410 texsize=512*512*3/texdetail/texdetail;
1411 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1412 //player[i].skeleton.skinText.resize(texsize);
1414 LoadTextureSave(creatureskin[player[i].creature][player[i].whichskin],&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1416 if(player[i].numclothes)
1418 for(j=0;j<player[i].numclothes;j++)
1420 tintr=player[i].clothestintr[j];
1421 tintg=player[i].clothestintg[j];
1422 tintb=player[i].clothestintb[j];
1423 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1425 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1428 player[i].currentanimation=bounceidleanim;
1429 player[i].targetanimation=bounceidleanim;
1430 player[i].currentframe=0;
1431 player[i].targetframe=1;
1433 player[i].speed=1+(float)(Random()%100)/1000;
1434 if(difficulty==0)player[i].speed-=.2;
1435 if(difficulty==1)player[i].speed-=.1;
1437 player[i].velocity=0;
1438 player[i].oldcoords=player[i].coords;
1439 player[i].realoldcoords=player[i].coords;
1442 player[i].skeleton.id=i;
1443 player[i].updatedelay=0;
1444 player[i].normalsupdatedelay=0;
1446 player[i].aitype=passivetype;
1447 player[i].aitarget=0;
1448 player[i].madskills=0;
1452 player[i].proportionhead=1.2;
1453 player[i].proportionbody=1.05;
1454 player[i].proportionarms=1.00;
1455 player[i].proportionlegs=1.1;
1456 player[i].proportionlegs.y=1.05;
1458 player[i].headless=0;
1459 player[i].currentoffset=0;
1460 player[i].targetoffset=0;
1461 /*player[i].armorhead=1;
1462 player[i].armorhigh=1;
1463 player[i].armorlow=1;
1464 player[i].protectionhead=1;
1465 player[i].protectionhigh=1;
1466 player[i].protectionlow=1;
1467 player[i].metalhead=1;
1468 player[i].metalhigh=1;
1469 player[i].metallow=1;
1471 player[i].speedmult=1;*/
1473 player[i].damagetolerance=200;
1475 if(player[i].creature==wolftype)
1477 /*player[i].proportionhead=1.1;
1478 player[i].proportionbody=1.1;
1479 player[i].proportionarms=1.1;
1480 player[i].proportionlegs=1.1;
1481 player[i].proportionlegs.y=1.1;*/
1482 if(i==0||player[i].scale<0)player[i].scale=.23;
1484 player[i].damagetolerance=300;
1487 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1490 player[i].proportionhead.z=0;
1491 player[i].proportionbody.z=0;
1492 player[i].proportionarms.z=0;
1493 player[i].proportionlegs.z=0;
1496 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1498 player[i].headmorphness=0;
1499 player[i].targetheadmorphness=1;
1500 player[i].headmorphstart=0;
1501 player[i].headmorphend=0;
1503 player[i].pausetime=0;
1506 player[i].jumppower=5;
1508 player[i].permanentdamage=0;
1509 player[i].superpermanentdamage=0;
1511 player[i].forwardkeydown=0;
1512 player[i].leftkeydown=0;
1513 player[i].backkeydown=0;
1514 player[i].rightkeydown=0;
1515 player[i].jumpkeydown=0;
1516 player[i].crouchkeydown=0;
1517 player[i].throwkeydown=0;
1519 player[i].collided=-10;
1521 player[i].bloodloss=0;
1522 player[i].weaponactive=-1;
1523 player[i].weaponstuck=-1;
1524 player[i].bleeding=0;
1525 player[i].deathbleeding=0;
1526 player[i].stunned=0;
1527 player[i].hasvictim=0;
1528 player[i].wentforweapon=0;
1531 player[0].aitype=playercontrolled;
1532 player[0].weaponactive=-1;
1536 //player[0].speedmult=1/.9;
1537 player[0].power=1/.9;
1542 //player[0].speedmult=1/.8;
1543 player[0].power=1/.8;
1546 //player[0].weaponstuck=1;
1548 if(difficulty==1)player[0].damagetolerance=250;
1549 if(difficulty==0)player[0].damagetolerance=300;
1550 if(difficulty==0)player[0].armorhead*=1.5;
1551 if(difficulty==0)player[0].armorhigh*=1.5;
1552 if(difficulty==0)player[0].armorlow*=1.5;
1553 cameraloc=player[0].coords;
1555 rotation=player[0].rotation;
1557 hawkcoords=player[0].coords;
1560 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1561 //weapons.numweapons=numplayers;
1562 for(i=0;i<weapons.numweapons;i++)
1564 weapons.bloody[i]=0;
1565 weapons.blooddrip[i]=0;
1566 weapons.blooddripdelay[i]=0;
1567 weapons.onfire[i]=0;
1568 weapons.flamedelay[i]=0;
1569 weapons.damage[i]=0;
1570 //weapons.type[i]=sword;
1571 if(weapons.type[i]==sword){
1572 weapons.mass[i]=1.5;
1573 weapons.tipmass[i]=1;
1574 weapons.length[i]=.8;
1576 if(weapons.type[i]==staff){
1578 weapons.tipmass[i]=1;
1579 weapons.length[i]=1.5;
1581 if(weapons.type[i]==knife){
1583 weapons.tipmass[i]=1.2;
1584 weapons.length[i]=.25;
1586 weapons.position[i]=-1000;
1587 weapons.tippoint[i]=-1000;
1590 /* for(i=0;i<32;i++){
1592 OPENAL_StopSound(i);
1595 LOG("Starting background music...");
1597 OPENAL_StopSound(OPENAL_ALL);
1598 if(environment==snowyenvironment)
1602 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1603 OPENAL_SetPaused(channels[stream_wind], false);
1604 OPENAL_SetVolume(channels[stream_wind], 256);
1607 else if(environment==desertenvironment)
1611 //PlaySoundEx(desertambient,
1612 // samp[desertambient], NULL, true);
1613 PlayStreamEx(stream_desertambient,
1614 strm[stream_desertambient], NULL, true);
1615 OPENAL_SetPaused(channels[stream_desertambient], false);
1616 OPENAL_SetVolume(channels[stream_desertambient], 256);
1619 else if(environment==grassyenvironment)
1623 //PlaySoundEx(wind, samp[wind], NULL, true);
1624 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1625 OPENAL_SetPaused(channels[stream_wind], false);
1626 OPENAL_SetVolume(channels[stream_wind], 100);
1629 oldmusicvolume[0]=0;
1630 oldmusicvolume[1]=0;
1631 oldmusicvolume[2]=0;
1632 oldmusicvolume[3]=0;
1635 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1636 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1637 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1638 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1639 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1640 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1641 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1642 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1657 static int i,k,j,l,m;
1658 static XYZ facing,flatfacing,absflatfacing;
1659 static XYZ rotatetarget;
1661 static float oldtargetrotation;
1662 static int target, numgood;
1663 static XYZ tempcoords1,tempcoords2;
1666 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1667 static int whichhit;
1668 static bool donesomething;
1669 static bool oldjumpkeydown;
1673 float headprop,bodyprop,armprop,legprop;
1676 displaytime[i]+=multiplier;
1679 static unsigned char theKeyMap[16];
1680 GetKeys( theKeyMap );
1685 static bool mainmenutogglekeydown;
1687 if(mainmenu&&endgame==1)mainmenu=10;
1688 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1690 displaytext[0][j]=' ';
1695 mainmenutogglekeydown=1;
1697 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)){
1699 if(mainmenu==1||mainmenu==2||mainmenu==0){
1700 if(mainmenu==0&&!winfreeze)mainmenu=2;
1701 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1702 else if(mainmenu==0&&winfreeze){
1703 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1705 else stealthloading=0;
1707 if(!stealthloading){
1708 float gLoc[3]={0,0,0};
1709 float vel[3]={0,0,0};
1710 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1711 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1712 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1713 OPENAL_SetVolume(channels[firestartsound], 256);
1714 OPENAL_SetPaused(channels[firestartsound], false);
1715 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1726 for(i=0;i<campaignnumlevels;i++){
1728 levelhighlight[i]=0;
1733 if(accountcampaignchoicesmade[accountactive])
1734 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1735 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1736 levelvisible[levelorder[i+1]]=1;
1738 int whichlevelstart;
1739 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1740 if(whichlevelstart<0){
1741 campaignchoicenum=1;
1742 campaignchoicewhich[0]=0;
1746 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1747 if(campaignchoicenum)
1748 for(i=0;i<campaignchoicenum;i++){
1749 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1750 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1751 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1758 if(firstload)TickOnceAfter();
1759 if(!firstload)LoadStuff();
1776 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1777 //accountcampaignchoicesmade[accountactive]++;
1780 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1788 OPENAL_SetPaused(channels[music3], true);
1792 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1793 if(mainmenu&&musictoggle){
1794 if(mainmenu==1||mainmenu==2||mainmenu==100){
1795 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
1796 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1797 OPENAL_SetPaused(channels[stream_music3], false);
1798 OPENAL_SetVolume(channels[stream_music3], 256);
1799 OPENAL_SetPaused(channels[music1], true);
1803 OPENAL_SetPaused(channels[stream_music3], true);
1804 OPENAL_SetPaused(channels[music1], false);
1808 float gLoc[3]={0,0,0};
1809 float vel[3]={0,0,0};
1810 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1811 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1812 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1813 OPENAL_SetVolume(channels[fireendsound], 256);
1814 OPENAL_SetPaused(channels[fireendsound], false);
1815 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1823 if(newdetail>2)newdetail=detail;
1824 if(newdetail<0)newdetail=detail;
1825 if(newscreenwidth<0)newscreenwidth=screenwidth;
1826 if(newscreenheight<0)newscreenheight=screenheight;
1828 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1829 opstream << "Screenwidth:\n";
1830 opstream << newscreenwidth;
1831 opstream << "\nScreenheight:\n";
1832 opstream << newscreenheight;
1833 opstream << "\nMouse sensitivity:\n";
1834 opstream << usermousesensitivity;
1835 opstream << "\nBlur(0,1):\n";
1836 opstream << ismotionblur;
1837 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1838 opstream << newdetail;
1839 opstream << "\nFloating jump:\n";
1840 opstream << floatjump;
1841 opstream << "\nMouse jump:\n";
1842 opstream << mousejump;
1843 opstream << "\nAmbient sound:\n";
1844 opstream << ambientsound;
1845 opstream << "\nBlood (0,1,2):\n";
1846 opstream << bloodtoggle;
1847 opstream << "\nAuto slomo:\n";
1848 opstream << autoslomo;
1849 opstream << "\nFoliage:\n";
1850 opstream << foliage;
1851 opstream << "\nMusic:\n";
1852 opstream << musictoggle;
1853 opstream << "\nTrilinear:\n";
1854 opstream << trilinear;
1855 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1857 opstream << "\nInvert mouse:\n";
1858 opstream << invertmouse;
1859 opstream << "\nGamespeed:\n";
1860 if(oldgamespeed==0)oldgamespeed=1;
1861 opstream << oldgamespeed;
1862 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1863 opstream << difficulty;
1864 opstream << "\nDamage effects(blackout, doublevision):\n";
1865 opstream << damageeffects;
1866 opstream << "\nText:\n";
1867 opstream << texttoggle;
1868 opstream << "\nDebug:\n";
1869 opstream << debugmode;
1870 opstream << "\nVBL Sync:\n";
1871 opstream << vblsync;
1872 opstream << "\nShow Points:\n";
1873 opstream << showpoints;
1874 opstream << "\nAlways Blur:\n";
1875 opstream << alwaysblur;
1876 opstream << "\nImmediate mode (turn on on G5):\n";
1877 opstream << immediate;
1878 opstream << "\nVelocity blur:\n";
1879 opstream << velocityblur;
1880 opstream << "\nVolume:\n";
1882 opstream << "\nForward key:\n";
1883 opstream << KeyToChar(forwardkey);
1884 opstream << "\nBack key:\n";
1885 opstream << KeyToChar(backkey);
1886 opstream << "\nLeft key:\n";
1887 opstream << KeyToChar(leftkey);
1888 opstream << "\nRight key:\n";
1889 opstream << KeyToChar(rightkey);
1890 opstream << "\nJump key:\n";
1891 opstream << KeyToChar(jumpkey);
1892 opstream << "\nCrouch key:\n";
1893 opstream << KeyToChar(crouchkey);
1894 opstream << "\nDraw key:\n";
1895 opstream << KeyToChar(drawkey);
1896 opstream << "\nThrow key:\n";
1897 opstream << KeyToChar(throwkey);
1898 opstream << "\nAttack key:\n";
1899 opstream << KeyToChar(attackkey);
1900 opstream << "\nChat key:\n";
1901 opstream << KeyToChar(chatkey);
1904 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
1905 float gLoc[3]={0,0,0};
1906 float vel[3]={0,0,0};
1907 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1908 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1909 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1910 OPENAL_SetVolume(channels[fireendsound], 256);
1911 OPENAL_SetPaused(channels[fireendsound], false);
1912 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1920 if(mainmenu==3&&gameon)mainmenu=2;
1921 if(mainmenu==3&&!gameon)mainmenu=1;
1922 if(mainmenu==5&&gameon)mainmenu=2;
1923 if(mainmenu==5&&!gameon)mainmenu=1;
1924 if(mainmenu==4)mainmenu=3;
1925 if(mainmenu==6)mainmenu=5;
1926 if(mainmenu==7)mainmenu=1;
1927 if(mainmenu==9)mainmenu=5;
1928 if(mainmenu==11)mainmenu=5;
1929 if(mainmenu==13)mainmenu=12;
1930 if(mainmenu==10)mainmenu=5;
1936 mainmenutogglekeydown=1;
1938 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1939 mainmenutogglekeydown=0;
1943 /*static bool minimaptogglekeydown;
1944 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1946 minimaptogglekeydown=1;
1948 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1949 minimaptogglekeydown=0;
1953 static bool minimaptogglekeydown;
1954 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1955 if(tutorialstage!=51)
1956 tutorialstagetime=tutorialmaxtime;
1957 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
1958 OPENAL_SetVolume(channels[consolefailsound], 128);
1959 OPENAL_SetPaused(channels[consolefailsound], false);
1960 minimaptogglekeydown=1;
1962 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1963 minimaptogglekeydown=0;
1968 if(mainmenu==1||mainmenu==2){
1969 if(Button()&&!oldbutton&&selected==1){
1971 float gLoc[3]={0,0,0};
1972 float vel[3]={0,0,0};
1973 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1974 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1975 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1976 OPENAL_SetVolume(channels[firestartsound], 256);
1977 OPENAL_SetPaused(channels[firestartsound], false);
1978 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1987 if(accountactive!=-1)mainmenu=5;
1994 if(firstload)TickOnceAfter();
1995 if(!firstload)LoadStuff();
2001 OPENAL_SetPaused(channels[music3], true); */
2007 OPENAL_SetPaused(channels[stream_music3], true);
2008 OPENAL_SetPaused(channels[music1], false);
2012 if(Button()&&!oldbutton&&selected==2){
2013 float gLoc[3]={0,0,0};
2014 float vel[3]={0,0,0};
2015 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2016 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2017 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2018 OPENAL_SetVolume(channels[firestartsound], 256);
2019 OPENAL_SetPaused(channels[firestartsound], false);
2020 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2032 if(newdetail>2)newdetail=detail;
2033 if(newdetail<0)newdetail=detail;
2034 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2035 if(newscreenwidth<0)newscreenwidth=screenwidth;
2036 if(newscreenheight>3000)newscreenheight=screenheight;
2037 if(newscreenheight<0)newscreenheight=screenheight;
2040 if(Button()&&!oldbutton&&selected==3){
2041 float gLoc[3]={0,0,0};
2042 float vel[3]={0,0,0};
2043 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2044 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2045 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2046 OPENAL_SetVolume(channels[fireendsound], 256);
2047 OPENAL_SetPaused(channels[fireendsound], false);
2048 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2059 OPENAL_SetPaused(channels[stream_music3], true);
2067 if(Button())oldbutton=1;
2072 if(Button()&&!oldbutton&&selected!=-1){
2073 float gLoc[3]={0,0,0};
2074 float vel[3]={0,0,0};
2075 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2076 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2077 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2078 OPENAL_SetVolume(channels[firestartsound], 256);
2079 OPENAL_SetPaused(channels[firestartsound], false);
2080 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2082 if(Button()&&!oldbutton&&selected==0){
2084 extern SDL_Rect **resolutions;
2085 bool isCustomResolution = true;
2087 for (int i = 0; (!found) && (resolutions[i]); i++)
2089 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2090 isCustomResolution = false;
2092 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2095 if (resolutions[i] != NULL)
2097 newscreenwidth = (int) resolutions[i]->w;
2098 newscreenheight = (int) resolutions[i]->h;
2100 else if (isCustomResolution)
2102 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2104 newscreenwidth = (int) resolutions[0]->w;
2105 newscreenheight = (int) resolutions[0]->h;
2109 newscreenwidth = screenwidth;
2110 newscreenheight = screenheight;
2115 newscreenwidth = (int) resolutions[0]->w;
2116 newscreenheight = (int) resolutions[0]->h;
2124 newscreenwidth = (int) resolutions[0]->w;
2125 newscreenheight = (int) resolutions[0]->h;
2130 if(Button()&&!oldbutton&&selected==1){
2132 if(newdetail>2)newdetail=0;
2134 if(Button()&&!oldbutton&&selected==2){
2136 if(bloodtoggle>2)bloodtoggle=0;
2138 if(Button()&&!oldbutton&&selected==3){
2140 if(difficulty>2)difficulty=0;
2142 if(Button()&&!oldbutton&&selected==4){
2143 ismotionblur=1-ismotionblur;
2145 if(Button()&&!oldbutton&&selected==5){
2148 if(Button()&&!oldbutton&&selected==6){
2149 musictoggle=1-musictoggle;
2152 OPENAL_SetPaused(channels[music1], true);
2153 OPENAL_SetPaused(channels[stream_music2], true);
2154 OPENAL_SetPaused(channels[stream_music3], true);
2157 oldmusicvolume[i]=0;
2163 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2164 OPENAL_SetPaused(channels[stream_music3], false);
2165 OPENAL_SetVolume(channels[stream_music3], 256);
2168 if(Button()&&!oldbutton&&selected==9){
2169 invertmouse=1-invertmouse;
2171 if(Button()&&!oldbutton&&selected==10){
2172 usermousesensitivity+=.2;
2173 if(usermousesensitivity>2)usermousesensitivity=.2;
2175 if(Button()&&!oldbutton&&selected==11){
2177 if(volume>1.0001f)volume=0;
2178 OPENAL_SetSFXMasterVolume((int)(volume*255));
2180 if(Button()&&!oldbutton&&selected==7){
2181 /*float gLoc[3]={0,0,0};
2182 float vel[3]={0,0,0};
2183 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2184 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2185 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2186 OPENAL_SetVolume(channels[firestartsound], 256);
2187 OPENAL_SetPaused(channels[firestartsound], false);
2188 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2201 if(Button()&&!oldbutton&&selected==8){
2202 float gLoc[3]={0,0,0};
2203 float vel[3]={0,0,0};
2204 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2205 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2206 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2207 OPENAL_SetVolume(channels[fireendsound], 256);
2208 OPENAL_SetPaused(channels[fireendsound], false);
2209 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2217 if(newdetail>2)newdetail=detail;
2218 if(newdetail<0)newdetail=detail;
2219 if(newscreenwidth<0)newscreenwidth=screenwidth;
2220 if(newscreenheight<0)newscreenheight=screenheight;
2223 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2224 opstream << "Screenwidth:\n";
2225 opstream << newscreenwidth;
2226 opstream << "\nScreenheight:\n";
2227 opstream << newscreenheight;
2228 opstream << "\nMouse sensitivity:\n";
2229 opstream << usermousesensitivity;
2230 opstream << "\nBlur(0,1):\n";
2231 opstream << ismotionblur;
2232 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2233 opstream << newdetail;
2234 opstream << "\nFloating jump:\n";
2235 opstream << floatjump;
2236 opstream << "\nMouse jump:\n";
2237 opstream << mousejump;
2238 opstream << "\nAmbient sound:\n";
2239 opstream << ambientsound;
2240 opstream << "\nBlood (0,1,2):\n";
2241 opstream << bloodtoggle;
2242 opstream << "\nAuto slomo:\n";
2243 opstream << autoslomo;
2244 opstream << "\nFoliage:\n";
2245 opstream << foliage;
2246 opstream << "\nMusic:\n";
2247 opstream << musictoggle;
2248 opstream << "\nTrilinear:\n";
2249 opstream << trilinear;
2250 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2252 opstream << "\nInvert mouse:\n";
2253 opstream << invertmouse;
2254 opstream << "\nGamespeed:\n";
2255 if(oldgamespeed==0)oldgamespeed=1;
2256 opstream << oldgamespeed;
2257 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2258 opstream << difficulty;
2259 opstream << "\nDamage effects(blackout, doublevision):\n";
2260 opstream << damageeffects;
2261 opstream << "\nText:\n";
2262 opstream << texttoggle;
2263 opstream << "\nDebug:\n";
2264 opstream << debugmode;
2265 opstream << "\nVBL Sync:\n";
2266 opstream << vblsync;
2267 opstream << "\nShow Points:\n";
2268 opstream << showpoints;
2269 opstream << "\nAlways Blur:\n";
2270 opstream << alwaysblur;
2271 opstream << "\nImmediate mode (turn on on G5):\n";
2272 opstream << immediate;
2273 opstream << "\nVelocity blur:\n";
2274 opstream << velocityblur;
2275 opstream << "\nVolume:\n";
2277 opstream << "\nForward key:\n";
2278 opstream << KeyToChar(forwardkey);
2279 opstream << "\nBack key:\n";
2280 opstream << KeyToChar(backkey);
2281 opstream << "\nLeft key:\n";
2282 opstream << KeyToChar(leftkey);
2283 opstream << "\nRight key:\n";
2284 opstream << KeyToChar(rightkey);
2285 opstream << "\nJump key:\n";
2286 opstream << KeyToChar(jumpkey);
2287 opstream << "\nCrouch key:\n";
2288 opstream << KeyToChar(crouchkey);
2289 opstream << "\nDraw key:\n";
2290 opstream << KeyToChar(drawkey);
2291 opstream << "\nThrow key:\n";
2292 opstream << KeyToChar(throwkey);
2293 opstream << "\nAttack key:\n";
2294 opstream << KeyToChar(attackkey);
2295 opstream << "\nChat key:\n";
2296 opstream << KeyToChar(chatkey);
2299 if(mainmenu==3&&gameon)mainmenu=2;
2300 if(mainmenu==3&&!gameon)mainmenu=1;
2302 if(Button())oldbutton=1;
2306 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2307 float gLoc[3]={0,0,0};
2308 float vel[3]={0,0,0};
2309 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2310 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2311 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2312 OPENAL_SetVolume(channels[firestartsound], 256);
2313 OPENAL_SetPaused(channels[firestartsound], false);
2314 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2316 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2324 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2326 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2327 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2328 float gLoc[3]={0,0,0};
2329 float vel[3]={0,0,0};
2330 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2331 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2332 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2333 OPENAL_SetVolume(channels[fireendsound], 256);
2334 OPENAL_SetPaused(channels[fireendsound], false);
2335 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2339 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2340 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2344 if(keyselect==0)forwardkey=keynum;
2345 if(keyselect==1)backkey=keynum;
2346 if(keyselect==2)leftkey=keynum;
2347 if(keyselect==3)rightkey=keynum;
2348 if(keyselect==4)crouchkey=keynum;
2349 if(keyselect==5)jumpkey=keynum;
2350 if(keyselect==6)drawkey=keynum;
2351 if(keyselect==7)throwkey=keynum;
2352 if(keyselect==8)attackkey=keynum;
2357 if(Button()&&!oldbutton&&selected==9){
2358 float gLoc[3]={0,0,0};
2359 float vel[3]={0,0,0};
2360 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2361 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2362 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2363 OPENAL_SetVolume(channels[fireendsound], 256);
2364 OPENAL_SetPaused(channels[fireendsound], false);
2365 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2375 if(newdetail>2)newdetail=detail;
2376 if(newdetail<0)newdetail=detail;
2377 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2378 if(newscreenwidth<0)newscreenwidth=screenwidth;
2379 if(newscreenheight>3000)newscreenheight=screenheight;
2380 if(newscreenheight<0)newscreenheight=screenheight;
2387 accountcampaignchoicesmade[accountactive]=0;
2388 accountcampaignscore[accountactive]=0;
2389 accountcampaigntime[accountactive]=0;
2393 if(Button()&&!oldbutton&&selected==1){
2394 float gLoc[3]={0,0,0};
2395 float vel[3]={0,0,0};
2396 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2397 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2398 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2399 OPENAL_SetVolume(channels[firestartsound], 256);
2400 OPENAL_SetPaused(channels[firestartsound], false);
2401 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2414 if(firstload)TickOnceAfter();
2415 if(!firstload)LoadStuff();
2422 OPENAL_SetPaused(channels[stream_music3], true);
2424 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2425 float gLoc[3]={0,0,0};
2426 float vel[3]={0,0,0};
2427 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2428 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2429 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2430 OPENAL_SetVolume(channels[firestartsound], 256);
2431 OPENAL_SetPaused(channels[firestartsound], false);
2432 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2445 if(firstload)TickOnceAfter();
2446 if(!firstload)LoadStuff();
2462 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2463 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2467 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2472 OPENAL_SetPaused(channels[stream_music3], true);
2474 if(Button()&&!oldbutton&&selected==4){
2475 float gLoc[3]={0,0,0};
2476 float vel[3]={0,0,0};
2477 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2478 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2479 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2480 OPENAL_SetVolume(channels[fireendsound], 256);
2481 OPENAL_SetPaused(channels[fireendsound], false);
2482 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2490 if(mainmenu==5&&gameon)mainmenu=2;
2491 if(mainmenu==5&&!gameon)mainmenu=1;
2493 if(Button()&&!oldbutton&&selected==5){
2494 float gLoc[3]={0,0,0};
2495 float vel[3]={0,0,0};
2496 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2497 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2498 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2499 OPENAL_SetVolume(channels[fireendsound], 256);
2500 OPENAL_SetPaused(channels[fireendsound], false);
2501 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2511 if(Button()&&!oldbutton&&selected==3){
2512 float gLoc[3]={0,0,0};
2513 float vel[3]={0,0,0};
2514 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2515 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2516 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2517 OPENAL_SetVolume(channels[firestartsound], 256);
2518 OPENAL_SetPaused(channels[firestartsound], false);
2519 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2529 if(Button()&&!oldbutton&&selected==2){
2530 float gLoc[3]={0,0,0};
2531 float vel[3]={0,0,0};
2532 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2533 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2534 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2535 OPENAL_SetVolume(channels[firestartsound], 256);
2536 OPENAL_SetPaused(channels[firestartsound], false);
2537 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2547 if(Button())oldbutton=1;
2551 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2552 float gLoc[3]={0,0,0};
2553 float vel[3]={0,0,0};
2554 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2555 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2556 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2557 OPENAL_SetVolume(channels[firestartsound], 256);
2558 OPENAL_SetPaused(channels[firestartsound], false);
2559 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2571 targetlevel=selected;
2572 if(firstload)TickOnceAfter();
2573 if(!firstload)LoadStuff();
2575 Loadlevel(selected);
2581 OPENAL_SetPaused(channels[stream_music3], true);
2583 if(Button()&&!oldbutton&&selected==numchallengelevels){
2584 float gLoc[3]={0,0,0};
2585 float vel[3]={0,0,0};
2586 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2587 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2588 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2589 OPENAL_SetVolume(channels[fireendsound], 256);
2590 OPENAL_SetPaused(channels[fireendsound], false);
2591 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2601 if(Button())oldbutton=1;
2605 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2606 float gLoc[3]={0,0,0};
2607 float vel[3]={0,0,0};
2608 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2609 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2610 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2611 OPENAL_SetVolume(channels[firestartsound], 256);
2612 OPENAL_SetPaused(channels[firestartsound], false);
2613 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2625 targetlevel=selected;
2626 if(firstload)TickOnceAfter();
2627 if(!firstload)LoadStuff();
2629 Loadlevel(selected);
2635 OPENAL_SetPaused(channels[stream_music3], true);
2637 if(Button()&&!oldbutton&&selected==numchallengelevels){
2638 float gLoc[3]={0,0,0};
2639 float vel[3]={0,0,0};
2640 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2641 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2642 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2643 OPENAL_SetVolume(channels[fireendsound], 256);
2644 OPENAL_SetPaused(channels[fireendsound], false);
2645 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2655 if(Button())oldbutton=1;
2660 if(Button()&&!oldbutton&&selected==3){
2661 float gLoc[3]={0,0,0};
2662 float vel[3]={0,0,0};
2663 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2664 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2665 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2666 OPENAL_SetVolume(channels[fireendsound], 256);
2667 OPENAL_SetPaused(channels[fireendsound], false);
2668 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2678 if(Button())oldbutton=1;
2683 if(Button()&&!oldbutton&&selected!=-1){
2684 float gLoc[3]={0,0,0};
2685 float vel[3]={0,0,0};
2686 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2687 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2688 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2689 OPENAL_SetVolume(channels[firestartsound], 256);
2690 OPENAL_SetPaused(channels[firestartsound], false);
2691 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2693 if(Button()&&!oldbutton&&selected==1){
2694 float gLoc[3]={0,0,0};
2695 float vel[3]={0,0,0};
2696 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2697 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2698 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2699 OPENAL_SetVolume(channels[fireendsound], 256);
2700 OPENAL_SetPaused(channels[fireendsound], false);
2701 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2709 for(i=accountactive;i<numaccounts-1;i++){
2710 accountdifficulty[i]=accountdifficulty[i+1];
2711 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2712 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2713 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2715 accountpoints[i]=accountpoints[i+1];
2717 accounthighscore[i][j]=accounthighscore[i+1][j];
2718 accountfasttime[i][j]=accountfasttime[i+1][j];
2721 accountunlocked[i][j]=accountunlocked[i+1][j];
2724 accountname[i][j]=accountname[i+1][j];
2726 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2727 accountprogress[i]=accountprogress[i+1];
2728 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2729 accountcampaignscore[i]=accountcampaignscore[i+1];
2730 accountcampaigntime[i]=accountcampaigntime[i+1];
2739 if(Button()&&!oldbutton&&selected==2){
2740 float gLoc[3]={0,0,0};
2741 float vel[3]={0,0,0};
2742 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2743 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2744 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2745 OPENAL_SetVolume(channels[fireendsound], 256);
2746 OPENAL_SetPaused(channels[fireendsound], false);
2747 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2757 if(Button())oldbutton=1;
2761 if(Button()&&!oldbutton&&selected!=-1){
2762 float gLoc[3]={0,0,0};
2763 float vel[3]={0,0,0};
2764 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2765 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2766 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2767 OPENAL_SetVolume(channels[firestartsound], 256);
2768 OPENAL_SetPaused(channels[firestartsound], false);
2769 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2771 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2774 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2775 accountactive=selected-1;
2783 if(Button()&&!oldbutton&&selected==numaccounts+1){
2784 float gLoc[3]={0,0,0};
2785 float vel[3]={0,0,0};
2786 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2787 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2788 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2789 OPENAL_SetVolume(channels[fireendsound], 256);
2790 OPENAL_SetPaused(channels[fireendsound], false);
2791 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2802 displaytext[0][j]=' ';
2808 if(Button())oldbutton=1;
2812 if(Button()&&!oldbutton&&selected!=-1){
2813 float gLoc[3]={0,0,0};
2814 float vel[3]={0,0,0};
2815 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2816 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2817 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2818 OPENAL_SetVolume(channels[firestartsound], 256);
2819 OPENAL_SetPaused(channels[firestartsound], false);
2820 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2822 if(selected==0)accountdifficulty[accountactive]=0;
2823 if(selected==1)accountdifficulty[accountactive]=1;
2824 if(selected==2)accountdifficulty[accountactive]=2;
2835 if(Button())oldbutton=1;
2840 if(Button())oldbutton=1;
2843 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2846 if(newdetail>2)newdetail=detail;
2847 if(newdetail<0)newdetail=detail;
2848 if(newscreenwidth<0)newscreenwidth=screenwidth;
2849 if(newscreenheight<0)newscreenheight=screenheight;
2851 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2852 opstream << "Screenwidth:\n";
2853 opstream << newscreenwidth;
2854 opstream << "\nScreenheight:\n";
2855 opstream << newscreenheight;
2856 opstream << "\nMouse sensitivity:\n";
2857 opstream << usermousesensitivity;
2858 opstream << "\nBlur(0,1):\n";
2859 opstream << ismotionblur;
2860 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2861 opstream << newdetail;
2862 opstream << "\nFloating jump:\n";
2863 opstream << floatjump;
2864 opstream << "\nMouse jump:\n";
2865 opstream << mousejump;
2866 opstream << "\nAmbient sound:\n";
2867 opstream << ambientsound;
2868 opstream << "\nBlood (0,1,2):\n";
2869 opstream << bloodtoggle;
2870 opstream << "\nAuto slomo:\n";
2871 opstream << autoslomo;
2872 opstream << "\nFoliage:\n";
2873 opstream << foliage;
2874 opstream << "\nMusic:\n";
2875 opstream << musictoggle;
2876 opstream << "\nTrilinear:\n";
2877 opstream << trilinear;
2878 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2880 opstream << "\nInvert mouse:\n";
2881 opstream << invertmouse;
2882 opstream << "\nGamespeed:\n";
2883 if(oldgamespeed==0)oldgamespeed=1;
2884 opstream << oldgamespeed;
2885 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2886 opstream << difficulty;
2887 opstream << "\nDamage effects(blackout, doublevision):\n";
2888 opstream << damageeffects;
2889 opstream << "\nText:\n";
2890 opstream << texttoggle;
2891 opstream << "\nDebug:\n";
2892 opstream << debugmode;
2893 opstream << "\nVBL Sync:\n";
2894 opstream << vblsync;
2895 opstream << "\nShow Points:\n";
2896 opstream << showpoints;
2897 opstream << "\nAlways Blur:\n";
2898 opstream << alwaysblur;
2899 opstream << "\nImmediate mode (turn on on G5):\n";
2900 opstream << immediate;
2901 opstream << "\nVelocity blur:\n";
2902 opstream << velocityblur;
2903 opstream << "\nVolume:\n";
2905 opstream << "\nForward key:\n";
2906 opstream << KeyToChar(forwardkey);
2907 opstream << "\nBack key:\n";
2908 opstream << KeyToChar(backkey);
2909 opstream << "\nLeft key:\n";
2910 opstream << KeyToChar(leftkey);
2911 opstream << "\nRight key:\n";
2912 opstream << KeyToChar(rightkey);
2913 opstream << "\nJump key:\n";
2914 opstream << KeyToChar(jumpkey);
2915 opstream << "\nCrouch key:\n";
2916 opstream << KeyToChar(crouchkey);
2917 opstream << "\nDraw key:\n";
2918 opstream << KeyToChar(drawkey);
2919 opstream << "\nThrow key:\n";
2920 opstream << KeyToChar(throwkey);
2921 opstream << "\nAttack key:\n";
2922 opstream << KeyToChar(attackkey);
2923 opstream << "\nChat key:\n";
2924 opstream << KeyToChar(chatkey);
2929 if(mainmenu==1||mainmenu==2){
2930 if(loaddistrib>4)transition+=multiplier/8;
2938 OPENAL_SetFrequency(channels[stream_music3], 22050);
2942 if(IsKeyDown(theKeyMap, i)){
2943 togglekeydelay[i]+=multiplier;
2944 if(togglekeydelay[i]>.4){
2946 togglekeydelay[i]=.36;
2949 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
2950 for(j=255;j>=displayselected+1;j--){
2951 displaytext[0][j]=displaytext[0][j-1];
2953 displaytext[0][displayselected]=KeyToSingleChar(i);
2954 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
2958 if(i==MAC_DELETE_KEY&&displayselected!=0){
2959 for(j=displayselected-1;j<255;j++){
2960 displaytext[0][j]=displaytext[0][j+1];
2962 displaytext[0][255]=' ';
2966 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
2969 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
2972 if(i==MAC_RETURN_KEY&&entername){
2973 if(displaychars[0]){
2975 strcpy(accountname[numaccounts-1],displaytext[0]);
2976 accountactive=numaccounts-1;
2977 accountdifficulty[accountactive]=1;
2978 accountprogress[accountactive]=0;
2979 accountpoints[accountactive]=0;
2980 accountcampaigntime[accountactive]=0;
2981 accountcampaignscore[accountactive]=0;
2982 accountcampaignfasttime[accountactive]=0;
2983 accountcampaignhighscore[accountactive]=0;
2985 accounthighscore[accountactive][j]=0;
2986 accountfasttime[accountactive][j]=0;
2989 accountunlocked[accountactive][j]=0;
2991 accountcampaignchoicesmade[accountactive]=0;
2994 displaytext[0][j]=' ';
3008 float gLoc[3]={0,0,0};
3009 float vel[3]={0,0,0};
3010 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3011 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3012 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3013 OPENAL_SetVolume(channels[firestartsound], 256);
3014 OPENAL_SetPaused(channels[firestartsound], false);
3015 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3018 displaytext[0][j]=' ';
3026 if(i==MAC_RETURN_KEY&&mainmenu==13){
3027 if(displaychars[0]){
3028 sprintf (registrationname, "%s", displaytext[0]);
3029 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3039 float gLoc[3]={0,0,0};
3040 float vel[3]={0,0,0};
3041 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3042 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3043 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3044 OPENAL_SetVolume(channels[firestartsound], 256);
3045 OPENAL_SetPaused(channels[firestartsound], false);
3046 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3049 displaytext[0][j]=' ';
3060 togglekeydelay[i]=0;
3064 displayblinkdelay-=multiplier;
3065 if(displayblinkdelay<=0){
3066 displayblinkdelay=.3;
3067 displayblink=1-displayblink;
3073 if(hostile==1)hostiletime+=multiplier;
3075 if(!winfreeze)leveltime+=multiplier;
3076 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3083 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3085 chattogglekeydown=1;
3086 togglekey[chatkey]=1;
3087 togglekeydelay[chatkey]=-20;
3090 if(!IsKeyDown(theKeyMap, chatkey)){
3091 chattogglekeydown=0;
3096 if(IsKeyDown(theKeyMap, i)){
3097 togglekeydelay[i]+=multiplier;
3098 if(togglekeydelay[i]>.4){
3100 togglekeydelay[i]=.36;
3103 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3104 for(j=255;j>=displayselected+1;j--){
3105 displaytext[0][j]=displaytext[0][j-1];
3107 displaytext[0][displayselected]=KeyToSingleChar(i);
3108 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3112 if(i==MAC_DELETE_KEY&&displayselected!=0){
3113 for(j=displayselected-1;j<255;j++){
3114 displaytext[0][j]=displaytext[0][j+1];
3116 displaytext[0][255]=' ';
3120 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3123 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3126 if(i==MAC_RETURN_KEY){
3127 if(displaychars[0]){
3128 /*for(j=0;j<displaychars[0];j++){
3129 talkname[j]=displaytext[0][j];
3131 talkname[displaychars[0]]='\0';
3132 sprintf (chatname, "%s: %s",playerName,talkname);
3133 //NetworkSendInformation(chatname);
3136 displaytext[0][j]=' ';
3148 togglekeydelay[i]=0;
3152 displayblinkdelay-=multiplier;
3153 if(displayblinkdelay<=0){
3154 displayblinkdelay=.3;
3155 displayblink=1-displayblink;
3159 if(chatting)keyboardfrozen=1;
3161 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3164 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3166 freezetogglekeydown=1;
3169 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3170 freezetogglekeydown=0;
3173 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3175 if(!console)freeze=0;
3177 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3179 consoletogglekeydown=1;
3182 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3183 consoletogglekeydown=0;
3186 if(console)freeze=1;
3188 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3190 if(IsKeyDown(theKeyMap, i)){
3191 togglekeydelay[i]+=multiplier;
3192 if(togglekeydelay[i]>.4){
3194 togglekeydelay[i]=.36;
3197 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3198 for(j=255;j>=consoleselected+1;j--){
3199 consoletext[0][j]=consoletext[0][j-1];
3201 consoletext[0][consoleselected]=KeyToSingleChar(i);
3202 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3206 else if(i==MAC_ENTER_KEY){
3207 for(j=255;j>=consoleselected+1;j--){
3208 consoletext[0][j]=consoletext[0][j-1];
3210 consoletext[0][consoleselected]='\n';
3214 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3215 for(j=consoleselected-1;j<255;j++){
3216 consoletext[0][j]=consoletext[0][j+1];
3218 consoletext[0][255]=' ';
3222 if(i==MAC_ARROW_UP_KEY){
3223 if(archiveselected<14)archiveselected++;
3225 consolechars[0]=consolechars[archiveselected];
3226 consoletext[0][j]=consoletext[archiveselected][j];
3227 consoleselected=consolechars[0];
3230 if(i==MAC_ARROW_DOWN_KEY){
3231 if(archiveselected>0)archiveselected--;
3233 consolechars[0]=consolechars[archiveselected];
3234 consoletext[0][j]=consoletext[archiveselected][j];
3235 consoleselected=consolechars[0];
3238 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3241 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3244 if(i==MAC_RETURN_KEY){
3247 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3248 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3249 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3250 OPENAL_SetPaused(channels[consolesuccesssound], false);
3254 /*if(Compare(consoletext[0],"send ",0,4)){
3255 for(j=5;j<consolechars[0];j++){
3256 talkname[j-5]=consoletext[0][j];
3258 talkname[consolechars[0]-5]='\0';
3259 sprintf (chatname, "%s: %s",playerName,talkname);
3260 //NetworkSendInformation(chatname);
3263 if(Compare(consoletext[0],"name ",0,4)){
3265 numchars=consolechars[0]-5;
3266 if(numchars>32)numchars=32;
3267 for(j=5;j<numchars+5;j++){
3268 talkname[j-5]=consoletext[0][j];
3270 talkname[numchars]='\0';
3271 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3272 //NetworkSendInformation(chatname);
3273 sprintf (playerName, "%s",talkname);
3274 //NetworkSendName(playerName);
3277 if(Compare(consoletext[0],"map ",0,3)){
3289 for(j=4;j<consolechars[0];j++){
3290 mapname[j-4+11]=consoletext[0][j];
3292 mapname[consolechars[0]-4+11]='\0';
3298 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3300 unsigned char playerNameStr[32];
3301 char theIPAddress[256];
3303 NMUInt32 port = 25710;
3305 strcpy(playerName, "Client");
3306 GameC2PStr( playerName, playerNameStr );
3308 for(j=0;j<consolechars[0]-8;j++){
3309 theIPAddress[j]=consoletext[0][j+8];
3311 theIPAddress[consolechars[0]-8]='\0';
3313 sprintf( thePort, "%li", port );
3314 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3317 if(consolechars[0]>0){
3320 consoletext[k][j]=consoletext[k-1][j];
3322 consolechars[k]=consolechars[k-1];
3325 consoletext[0][j]=' ';
3327 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3328 else sprintf (consoletext[0], "Could not open connection");
3330 consolechars[0]=255;
3337 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3338 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3339 OPENAL_SetPaused(channels[consolesuccesssound], false);
3341 if(consolechars[0]>0){
3344 consoletext[k][j]=consoletext[k-1][j];
3346 consolechars[k]=consolechars[k-1];
3349 consoletext[0][j]=' ';
3351 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3353 consolechars[0]=255;
3359 if(Compare(consoletext[0],"host ",0,4)){
3360 unsigned char gameNameStr[32], playerNameStr[32];
3361 char gameName[32];//, playerName[32];
3369 strcpy(gameName, "Host's game");
3370 strcpy(playerName, "Host");
3371 GameC2PStr( gameName, gameNameStr );
3372 GameC2PStr( playerName, playerNameStr );
3374 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3377 if(consolechars[0]>0){
3380 consoletext[k][j]=consoletext[k-1][j];
3382 consolechars[k]=consolechars[k-1];
3385 consoletext[0][j]=' ';
3387 sprintf (consoletext[0], "Error #%d!!!",v);
3389 consolechars[0]=255;
3396 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3397 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3398 OPENAL_SetPaused(channels[consolesuccesssound], false);
3400 if(consolechars[0]>0){
3403 consoletext[k][j]=consoletext[k-1][j];
3405 consolechars[k]=consolechars[k-1];
3408 consoletext[0][j]=' ';
3410 sprintf (consoletext[0], "Game hosted");
3412 consolechars[0]=255;
3418 if(Compare(consoletext[0],"save ",0,4)){
3430 for(j=5;j<consolechars[0];j++){
3431 mapname[j-5+11]=consoletext[0][j];
3433 mapname[consolechars[0]-5+11]='\0';
3435 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3436 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3437 OPENAL_SetPaused(channels[consolesuccesssound], false);
3444 tfile=fopen( ConvertFileName(mapname), "wb" );
3445 fpackf(tfile, "Bi", mapvers);
3446 //fpackf(tfile, "Bi", indemo);
3447 fpackf(tfile, "Bi", maptype);
3448 fpackf(tfile, "Bi", hostile);
3449 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3450 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3451 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3452 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);
3453 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3454 for(j=0;j<player[0].num_weapons;j++){
3455 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3458 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3459 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3460 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3461 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3463 fpackf(tfile, "Bi", player[0].numclothes);
3465 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3467 fpackf(tfile, "Bi", numdialogues);
3469 for(k=0;k<numdialogues;k++){
3470 fpackf(tfile, "Bi", numdialogueboxes[k]);
3471 fpackf(tfile, "Bi", dialoguetype[k]);
3473 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3474 fpackf(tfile, "Bf", participantrotation[k][l]);
3476 if(numdialogueboxes)
3477 for(l=0;l<numdialogueboxes[k];l++){
3478 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3479 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3480 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3481 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3482 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3484 templength=strlen(dialoguetext[k][l]);
3485 fpackf(tfile, "Bi",(templength));
3486 for(m=0;m<templength;m++){
3487 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3488 if(dialoguetext[k][l][m]=='\0')break;
3491 templength=strlen(dialoguename[k][l]);
3492 fpackf(tfile, "Bi",templength);
3493 for(m=0;m<templength;m++){
3494 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3495 if(dialoguename[k][l][m]=='\0')break;
3498 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3499 fpackf(tfile, "Bi", participantfocus[k][l]);
3500 fpackf(tfile, "Bi", participantaction[k][l]);
3503 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3505 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3509 if(player[0].numclothes)
3510 for(k=0;k<player[0].numclothes;k++){
3511 templength=strlen(player[0].clothes[k]);
3512 fpackf(tfile, "Bi", templength);
3513 for(l=0;l<templength;l++)
3514 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3515 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3518 fpackf(tfile, "Bi", environment);
3520 fpackf(tfile, "Bi", objects.numobjects);
3522 if(objects.numobjects)
3523 for(k=0;k<objects.numobjects;k++){
3524 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]);
3527 fpackf(tfile, "Bi", numhotspots);
3529 for(i=0;i<numhotspots;i++){
3530 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3531 templength=strlen(hotspottext[i]);
3532 fpackf(tfile, "Bi",templength);
3533 for(l=0;l<templength;l++)
3534 fpackf(tfile, "Bb", hotspottext[i][l]);
3537 fpackf(tfile, "Bi", numplayers);
3538 if(numplayers>1&&numplayers<maxplayers)
3539 for(j=1;j<numplayers;j++){
3540 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);
3541 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3542 for(k=0;k<player[j].num_weapons;k++){
3543 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3545 if(player[j].numwaypoints<30){
3546 fpackf(tfile, "Bi", player[j].numwaypoints);
3547 for(k=0;k<player[j].numwaypoints;k++){
3548 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3549 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3550 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3551 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3553 fpackf(tfile, "Bi", player[j].waypoint);
3556 player[j].numwaypoints=0;
3557 player[j].waypoint=0;
3558 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3561 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3562 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3563 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3564 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3566 if(player[j].creature==wolftype){
3567 headprop=player[j].proportionhead.x/1.1;
3568 bodyprop=player[j].proportionbody.x/1.1;
3569 armprop=player[j].proportionarms.x/1.1;
3570 legprop=player[j].proportionlegs.x/1.1;
3573 if(player[j].creature==rabbittype){
3574 headprop=player[j].proportionhead.x/1.2;
3575 bodyprop=player[j].proportionbody.x/1.05;
3576 armprop=player[j].proportionarms.x/1.00;
3577 legprop=player[j].proportionlegs.x/1.1;
3580 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3584 fpackf(tfile, "Bi", player[j].numclothes);
3585 if(player[j].numclothes)
3586 for(k=0;k<player[j].numclothes;k++){
3588 templength=strlen(player[j].clothes[k]);
3589 fpackf(tfile, "Bi", templength);
3590 for(l=0;l<templength;l++)
3591 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3592 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3596 fpackf(tfile, "Bi", numpathpoints);
3598 for(j=0;j<numpathpoints;j++){
3599 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3600 for(k=0;k<numpathpointconnect[j];k++){
3601 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3605 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3613 tfile=fopen( mapname, "wb" );
3614 fwrite( &mapvers, 1, sizeof(int), tfile );
3615 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3616 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3617 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3618 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3619 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3620 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3621 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3622 for(j=0;j<player[0].num_weapons;j++){
3623 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3626 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3627 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3628 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3629 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3630 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3631 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3632 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3633 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3634 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3635 fwrite( &player[0].power, 1, sizeof(int), tfile );
3636 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3638 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3639 if(player[0].numclothes)
3640 for(k=0;k<player[0].numclothes;k++){
3642 templength=strlen(player[0].clothes[k]);
3643 fwrite( &templength,1,sizeof(int),tfile);
3644 for(l=0;l<templength;l++)
3645 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3646 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3647 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3648 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3651 fwrite( &environment, 1, sizeof(int), tfile );
3653 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3655 for(k=0;k<objects.numobjects;k++){
3656 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3657 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3658 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3659 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3660 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3661 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3662 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3665 fwrite( &numplayers, 1, sizeof(int), tfile );
3666 if(numplayers>1&&numplayers<maxplayers)
3667 for(j=1;j<numplayers;j++){
3668 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3669 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3670 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3671 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3672 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3673 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3674 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3675 for(k=0;k<player[j].num_weapons;k++){
3676 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3678 if(player[j].numwaypoints<30){
3679 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3680 for(k=0;k<player[j].numwaypoints;k++){
3681 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3682 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3683 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3685 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3686 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3689 player[j].numwaypoints=0;
3690 player[j].waypoint=0;
3691 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3692 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3693 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3695 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3696 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3697 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3698 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3699 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3700 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3701 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3702 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3703 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3704 fwrite( &player[j].power, 1, sizeof(int), tfile );
3705 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3707 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3708 if(player[j].numclothes)
3709 for(k=0;k<player[j].numclothes;k++){
3711 templength=strlen(player[j].clothes[k]);
3712 fwrite( &templength,1,sizeof(int),tfile);
3713 for(l=0;l<templength;l++)
3714 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3715 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3716 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3717 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3720 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3722 for(j=0;j<numpathpoints;j++){
3723 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3724 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3725 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3726 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3727 for(k=0;k<numpathpointconnect[j];k++){
3728 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3732 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3733 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3734 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3736 fwrite( &mapradius, 1, sizeof(float), tfile );
3742 if(Compare(consoletext[0],"save ",0,4)){
3754 for(j=5;j<consolechars[0];j++){
3755 mapname[j-5+11]=consoletext[0][j];
3757 mapname[consolechars[0]-5+11]='\0';
3759 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3760 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3761 OPENAL_SetPaused(channels[consolesuccesssound], false);
3764 tfile=fopen( mapname, "wb" );
3765 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
3766 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3767 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3768 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3769 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3770 for(j=0;j<player[0].num_weapons;j++){
3771 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3773 fwrite( &environment, 1, sizeof(int), tfile );
3775 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3776 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
3777 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
3778 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
3779 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
3781 fwrite( &numplayers, 1, sizeof(int), tfile );
3782 if(numplayers>1&&numplayers<maxplayers)
3783 for(j=1;j<numplayers;j++){
3784 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
3785 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3786 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3787 for(k=0;k<player[j].num_weapons;k++){
3788 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3790 if(player[j].numwaypoints<30){
3791 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3792 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
3793 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3794 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3797 player[j].numwaypoints=0;
3798 player[j].waypoint=0;
3799 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3800 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3801 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3804 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3806 for(j=0;j<numpathpoints;j++){
3807 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
3808 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3809 for(k=0;k<numpathpointconnect[j];k++){
3810 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3816 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
3817 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
3820 /*if(Compare(consoletext[0],"Pants ",0,5)){
3821 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
3822 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
3826 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
3827 for(j=6;j<consolechars[0];j++){
3828 mapname[j-6]=consoletext[0][j];
3831 tintr=atof(mapname);
3836 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
3837 for(j=6;j<consolechars[0];j++){
3838 mapname[j-6]=consoletext[0][j];
3841 player[0].speedmult=atof(mapname);
3846 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
3847 for(j=9;j<consolechars[0];j++){
3848 mapname[j-9]=consoletext[0][j];
3851 player[0].power=atof(mapname);
3856 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
3857 for(j=13;j<consolechars[0];j++){
3858 mapname[j-13]=consoletext[0][j];
3861 viewdistance=atof(mapname)*100;
3866 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
3867 for(j=10;j<consolechars[0];j++){
3868 mapname[j-10]=consoletext[0][j];
3871 fadestart=atof(mapname);
3876 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
3877 for(j=6;j<consolechars[0];j++){
3878 mapname[j-6]=consoletext[0][j];
3881 player[0].power=atof(mapname);
3886 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
3887 for(j=6;j<consolechars[0];j++){
3888 mapname[j-6]=consoletext[0][j];
3891 slomospeed=atof(mapname);
3898 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
3899 for(j=8;j<consolechars[0];j++){
3900 mapname[j-8]=consoletext[0][j];
3903 slomofreq=atoi(mapname);
3908 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
3909 for(j=5;j<consolechars[0];j++){
3910 mapname[j-5]=consoletext[0][j];
3913 player[0].scale=atof(mapname)*.2;
3918 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
3920 float closestdist=-1;
3923 for(i=1;i<numplayers;i++){
3924 distance=findDistancefast(&player[i].coords,&player[0].coords);
3925 if(closestdist==-1||distance<closestdist){
3926 closestdist=distance;
3931 for(j=9;j<consolechars[0];j++){
3932 mapname[j-9]=consoletext[0][j];
3935 player[closest].scale=atof(mapname)*.2;
3940 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
3945 float closestdist=-1;
3948 for(i=1;i<numplayers;i++){
3949 distance=findDistancefast(&player[i].coords,&player[0].coords);
3950 if(closestdist==-1||distance<closestdist){
3951 closestdist=distance;
3959 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3960 mapname[j-startpoint]=consoletext[0][j];
3962 if(consoletext[0][j]=='\0')alldone=1;
3964 mapname[j-startpoint]='\0';
3966 headprop=atof(mapname);
3970 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3971 mapname[j-startpoint]=consoletext[0][j];
3973 if(consoletext[0][j]=='\0')alldone=1;
3975 mapname[j-startpoint]='\0';
3977 bodyprop=atof(mapname);
3981 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3982 mapname[j-startpoint]=consoletext[0][j];
3984 if(consoletext[0][j]=='\0')alldone=1;
3986 mapname[j-startpoint]='\0';
3988 armprop=atof(mapname);
3992 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3993 mapname[j-startpoint]=consoletext[0][j];
3995 if(consoletext[0][j]=='\0')alldone=1;
3997 mapname[j-startpoint]='\0';
3999 legprop=atof(mapname);
4001 if(player[closest].creature==wolftype){
4002 player[closest].proportionhead=1.1*headprop;
4003 player[closest].proportionbody=1.1*bodyprop;
4004 player[closest].proportionarms=1.1*armprop;
4005 player[closest].proportionlegs=1.1*legprop;
4008 if(player[closest].creature==rabbittype){
4009 player[closest].proportionhead=1.2*headprop;
4010 player[closest].proportionbody=1.05*bodyprop;
4011 player[closest].proportionarms=1.00*armprop;
4012 player[closest].proportionlegs=1.1*legprop;
4013 player[closest].proportionlegs.y=1.05*legprop;
4020 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4021 for(i=1;i<numplayers;i++){
4022 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4028 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4029 for(j=9;j<consolechars[0];j++){
4030 mapname[j-9]=consoletext[0][j];
4033 tutoriallevel=atoi(mapname);
4039 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4040 for(j=6;j<consolechars[0];j++){
4041 mapname[j-6]=consoletext[0][j];
4044 tintg=atof(mapname);
4049 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4050 for(j=6;j<consolechars[0];j++){
4051 mapname[j-6]=consoletext[0][j];
4054 tintb=atof(mapname);
4059 if(Compare(consoletext[0],"hostile ",0,7)){
4060 for(j=8;j<consolechars[0];j++){
4061 mapname[j-8]=consoletext[0][j];
4064 hostile=atoi(mapname);
4070 if(Compare(consoletext[0],"type active ",0,11)){
4071 editoractive=typeactive;
4076 if(Compare(consoletext[0],"indemo ",0,6)){
4078 hotspot[numhotspots]=player[0].coords;
4079 hotspotsize[numhotspots]=0;
4080 hotspottype[numhotspots]=-111;
4082 strcpy(hotspottext[numhotspots],"mapname");
4088 if(Compare(consoletext[0],"notindemo ",0,9)){
4095 if(Compare(consoletext[0],"type sitting ",0,12)){
4096 editoractive=typesitting;
4101 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4102 editoractive=typesittingwall;
4107 if(Compare(consoletext[0],"type sleeping ",0,13)){
4108 editoractive=typesleeping;
4112 if(Compare(consoletext[0],"type dead1 ",0,10)){
4113 editoractive=typedead1;
4117 if(Compare(consoletext[0],"type dead2 ",0,10)){
4118 editoractive=typedead2;
4122 if(Compare(consoletext[0],"type dead3 ",0,10)){
4123 editoractive=typedead3;
4126 if(Compare(consoletext[0],"type dead4 ",0,10)){
4127 editoractive=typedead4;
4132 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4133 editorpathtype=wpkeepwalking;
4138 if(Compare(consoletext[0],"path pause ",0,10)){
4139 editorpathtype=wppause;
4144 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4145 maptype=mapkilleveryone;
4150 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4151 maptype=mapgosomewhere;
4156 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4157 maptype=mapkillsomeone;
4163 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4164 maptype=mapkillmost;
4170 if(Compare(consoletext[0],"hs ",0,2)){
4174 hotspot[numhotspots]=player[0].coords;
4179 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4180 mapname[j-startpoint]=consoletext[0][j];
4182 if(consoletext[0][j]=='\0')alldone=1;
4184 mapname[j-startpoint]='\0';
4186 hotspotsize[numhotspots]=atof(mapname);
4190 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4191 mapname[j-startpoint]=consoletext[0][j];
4193 if(consoletext[0][j]=='\0')alldone=1;
4195 mapname[j-startpoint]='\0';
4197 hotspottype[numhotspots]=atoi(mapname);
4201 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4202 mapname[j-startpoint]=consoletext[0][j];
4204 if(consoletext[0][j]=='\0')alldone=1;
4206 mapname[j-startpoint]='\n';
4207 mapname[j-startpoint+1]='\0';
4209 strcpy(hotspottext[numhotspots],mapname);
4216 if(Compare(consoletext[0],"dialogue ",0,8)){
4223 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4224 mapname[j-startpoint]=consoletext[0][j];
4226 if(consoletext[0][j]=='\0')alldone=1;
4228 mapname[j-startpoint]='\0';
4231 dialoguetype[numdialogues]=atoi(mapname);
4249 for(j=startpoint;j<consolechars[0];j++){
4250 mapname[j-startpoint+16]=consoletext[0][j];
4252 mapname[consolechars[0]-startpoint+16]='.';
4253 mapname[consolechars[0]-startpoint+17]='t';
4254 mapname[consolechars[0]-startpoint+18]='x';
4255 mapname[consolechars[0]-startpoint+19]='t';
4256 mapname[consolechars[0]-startpoint+20]='\0';
4258 for(j=0;j<max_dialoguelength;j++){
4260 dialoguetext[numdialogues][j][k]='\0';
4263 dialoguename[numdialogues][j][k]='\0';
4267 ifstream ipstream(ConvertFileName(mapname));
4268 ipstream.ignore(256,':');
4269 ipstream >> numdialogueboxes[numdialogues];
4270 for(i=0;i<numdialogueboxes[numdialogues];i++){
4271 ipstream.ignore(256,':');
4272 ipstream.ignore(256,':');
4273 ipstream.ignore(256,' ');
4274 ipstream >> dialogueboxlocation[numdialogues][i];
4275 ipstream.ignore(256,':');
4276 ipstream >> dialogueboxcolor[numdialogues][i][0];
4277 ipstream >> dialogueboxcolor[numdialogues][i][1];
4278 ipstream >> dialogueboxcolor[numdialogues][i][2];
4279 ipstream.ignore(256,':');
4280 ipstream.getline(dialoguename[numdialogues][i],64);
4281 ipstream.ignore(256,':');
4282 ipstream.ignore(256,' ');
4283 ipstream.getline(dialoguetext[numdialogues][i],128);
4285 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4287 ipstream.ignore(256,':');
4288 ipstream >> dialogueboxsound[numdialogues][i];
4291 for(i=0;i<numdialogueboxes[numdialogues];i++){
4292 for(j=0;j<numplayers;j++){
4293 participantfacing[numdialogues][i][j]=player[j].facing;
4300 whichdialogue=numdialogues;
4308 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4316 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4317 mapname[j-startpoint]=consoletext[0][j];
4319 if(consoletext[0][j]=='\0')alldone=1;
4321 mapname[j-startpoint]='\0';
4324 whichdi=atoi(mapname);
4342 for(j=startpoint;j<consolechars[0];j++){
4343 mapname[j-startpoint+16]=consoletext[0][j];
4345 mapname[consolechars[0]-startpoint+16]='.';
4346 mapname[consolechars[0]-startpoint+17]='t';
4347 mapname[consolechars[0]-startpoint+18]='x';
4348 mapname[consolechars[0]-startpoint+19]='t';
4349 mapname[consolechars[0]-startpoint+20]='\0';
4351 for(j=0;j<max_dialoguelength;j++){
4353 dialoguetext[whichdi][j][k]='\0';
4356 dialoguename[whichdi][j][k]='\0';
4360 ifstream ipstream(ConvertFileName(mapname));
4361 ipstream.ignore(256,':');
4362 ipstream >> numdialogueboxes[whichdi];
4363 for(i=0;i<numdialogueboxes[whichdi];i++){
4364 ipstream.ignore(256,':');
4365 ipstream.ignore(256,':');
4366 ipstream.ignore(256,' ');
4367 ipstream >> dialogueboxlocation[whichdi][i];
4368 ipstream.ignore(256,':');
4369 ipstream >> dialogueboxcolor[whichdi][i][0];
4370 ipstream >> dialogueboxcolor[whichdi][i][1];
4371 ipstream >> dialogueboxcolor[whichdi][i][2];
4372 ipstream.ignore(256,':');
4373 ipstream.getline(dialoguename[whichdi][i],64);
4374 ipstream.ignore(256,':');
4375 ipstream.ignore(256,' ');
4376 ipstream.getline(dialoguetext[whichdi][i],128);
4378 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4380 ipstream.ignore(256,':');
4381 ipstream >> dialogueboxsound[whichdi][i];
4389 if(Compare(consoletext[0],"fixtype ",0,7)){
4397 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4398 mapname[j-startpoint]=consoletext[0][j];
4400 if(consoletext[0][j]=='\0')alldone=1;
4402 mapname[j-startpoint]='\0';
4403 dialoguetype[0]=atoi(mapname);
4411 if(Compare(consoletext[0],"fixrotation ",0,11)){
4412 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4417 if(Compare(consoletext[0],"ddialogue ",0,9)){
4419 if(numdialogues<0)numdialogues=0;
4424 if(Compare(consoletext[0],"immobile ",0,8)){
4425 player[0].immobile=1;
4429 if(Compare(consoletext[0],"mobile ",0,6)){
4430 player[0].immobile=0;
4434 if(Compare(consoletext[0],"play ",0,4)){
4441 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4442 mapname[j-startpoint]=consoletext[0][j];
4444 if(consoletext[0][j]=='\0')alldone=1;
4446 mapname[j-startpoint]='\0';
4449 whichdialogue=atoi(mapname);
4451 if(numdialogues>whichdialogue){
4452 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4453 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4454 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4455 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4456 player[participantfocus[whichdialogue][i]].velocity=0;
4457 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4458 player[participantfocus[whichdialogue][i]].targetframe=0;
4466 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4470 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4471 temppos=temppos-viewer;
4472 Normalise(&temppos);
4482 whichsoundplay=rabbitchitter;
4483 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4484 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4485 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4486 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4487 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4488 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4489 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4490 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4491 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4492 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4493 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4494 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4495 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4496 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4497 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4498 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4499 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4500 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4501 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4502 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4503 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4504 OPENAL_SetVolume(channels[whichsoundplay], 256);
4505 OPENAL_SetPaused(channels[whichsoundplay], false);
4513 if(Compare(consoletext[0],"dhs ",0,3)){
4515 if(numhotspots<0)numhotspots=0;
4520 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4527 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4528 mapname[j-startpoint]=consoletext[0][j];
4530 if(consoletext[0][j]=='\0')alldone=1;
4532 mapname[j-startpoint]='\0';
4534 headprop=atof(mapname);
4538 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4539 mapname[j-startpoint]=consoletext[0][j];
4541 if(consoletext[0][j]=='\0')alldone=1;
4543 mapname[j-startpoint]='\0';
4545 bodyprop=atof(mapname);
4549 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4550 mapname[j-startpoint]=consoletext[0][j];
4552 if(consoletext[0][j]=='\0')alldone=1;
4554 mapname[j-startpoint]='\0';
4556 armprop=atof(mapname);
4560 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4561 mapname[j-startpoint]=consoletext[0][j];
4563 if(consoletext[0][j]=='\0')alldone=1;
4565 mapname[j-startpoint]='\0';
4567 legprop=atof(mapname);
4569 if(player[0].creature==wolftype){
4570 player[0].proportionhead=1.1*headprop;
4571 player[0].proportionbody=1.1*bodyprop;
4572 player[0].proportionarms=1.1*armprop;
4573 player[0].proportionlegs=1.1*legprop;
4576 if(player[0].creature==rabbittype){
4577 player[0].proportionhead=1.2*headprop;
4578 player[0].proportionbody=1.05*bodyprop;
4579 player[0].proportionarms=1.00*armprop;
4580 player[0].proportionlegs=1.1*legprop;
4581 player[0].proportionlegs.y=1.05*legprop;
4587 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4588 for(i=0;i<numplayers;i++){
4589 if(i>0)player[i].immobile=1;
4595 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4596 player[0].armorhead=1;
4597 player[0].armorhigh=1;
4598 player[0].armorlow=1;
4599 player[0].protectionhead=1;
4600 player[0].protectionhigh=1;
4601 player[0].protectionlow=1;
4602 player[0].metalhead=1;
4603 player[0].metalhigh=1;
4604 player[0].metallow=1;
4606 player[0].speedmult=1;
4609 if(player[0].creature==wolftype){
4610 player[0].proportionhead=1.1;
4611 player[0].proportionbody=1.1;
4612 player[0].proportionarms=1.1;
4613 player[0].proportionlegs=1.1;
4616 if(player[0].creature==rabbittype){
4617 player[0].proportionhead=1.2;
4618 player[0].proportionbody=1.05;
4619 player[0].proportionarms=1.00;
4620 player[0].proportionlegs=1.1;
4621 player[0].proportionlegs.y=1.05;
4624 player[0].numclothes=0;
4625 LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
4626 &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4628 editoractive=typeactive;
4629 player[0].immobile=0;
4636 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4642 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4643 mapname[j-startpoint]=consoletext[0][j];
4645 if(consoletext[0][j]=='\0')alldone=1;
4647 mapname[j-startpoint]='\0';
4649 tintr=atof(mapname);
4653 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4654 mapname[j-startpoint]=consoletext[0][j];
4656 if(consoletext[0][j]=='\0')alldone=1;
4658 mapname[j-startpoint]='\0';
4660 tintg=atof(mapname);
4664 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4665 mapname[j-startpoint]=consoletext[0][j];
4667 if(consoletext[0][j]=='\0')alldone=1;
4669 mapname[j-startpoint]='\0';
4671 tintb=atof(mapname);
4676 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4682 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4683 mapname[j-startpoint]=consoletext[0][j];
4685 if(consoletext[0][j]=='\0')alldone=1;
4687 mapname[j-startpoint]='\0';
4689 skyboxr=atof(mapname);
4693 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4694 mapname[j-startpoint]=consoletext[0][j];
4696 if(consoletext[0][j]=='\0')alldone=1;
4698 mapname[j-startpoint]='\0';
4700 skyboxg=atof(mapname);
4704 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4705 mapname[j-startpoint]=consoletext[0][j];
4707 if(consoletext[0][j]=='\0')alldone=1;
4709 mapname[j-startpoint]='\0';
4711 skyboxb=atof(mapname);
4713 skyboxlightr=skyboxr;
4714 skyboxlightg=skyboxg;
4715 skyboxlightb=skyboxb;
4719 //if(skyboxtexture){
4720 terrain.DoShadows();
4721 objects.DoShadows();
4723 else terrain.DoLighting();
4728 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
4734 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4735 mapname[j-startpoint]=consoletext[0][j];
4737 if(consoletext[0][j]=='\0')alldone=1;
4739 mapname[j-startpoint]='\0';
4741 skyboxlightr=atof(mapname);
4745 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4746 mapname[j-startpoint]=consoletext[0][j];
4748 if(consoletext[0][j]=='\0')alldone=1;
4750 mapname[j-startpoint]='\0';
4752 skyboxlightg=atof(mapname);
4756 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4757 mapname[j-startpoint]=consoletext[0][j];
4759 if(consoletext[0][j]=='\0')alldone=1;
4761 mapname[j-startpoint]='\0';
4763 skyboxlightb=atof(mapname);
4767 //if(skyboxtexture){
4768 terrain.DoShadows();
4769 objects.DoShadows();
4771 else terrain.DoLighting();
4776 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
4777 skyboxtexture=1-skyboxtexture;
4780 //if(skyboxtexture){
4781 terrain.DoShadows();
4782 objects.DoShadows();
4784 else terrain.DoLighting();
4789 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
4795 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4796 mapname[j-startpoint]=consoletext[0][j];
4798 if(consoletext[0][j]=='\0')alldone=1;
4800 mapname[j-startpoint]='\0';
4802 player[0].protectionhead=atof(mapname);
4806 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4807 mapname[j-startpoint]=consoletext[0][j];
4809 if(consoletext[0][j]=='\0')alldone=1;
4811 mapname[j-startpoint]='\0';
4813 player[0].protectionhigh=atof(mapname);
4817 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4818 mapname[j-startpoint]=consoletext[0][j];
4820 if(consoletext[0][j]=='\0')alldone=1;
4822 mapname[j-startpoint]='\0';
4824 player[0].protectionlow=atof(mapname);
4829 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
4835 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4836 mapname[j-startpoint]=consoletext[0][j];
4838 if(consoletext[0][j]=='\0')alldone=1;
4840 mapname[j-startpoint]='\0';
4842 player[0].armorhead=atof(mapname);
4846 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4847 mapname[j-startpoint]=consoletext[0][j];
4849 if(consoletext[0][j]=='\0')alldone=1;
4851 mapname[j-startpoint]='\0';
4853 player[0].armorhigh=atof(mapname);
4857 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4858 mapname[j-startpoint]=consoletext[0][j];
4860 if(consoletext[0][j]=='\0')alldone=1;
4862 mapname[j-startpoint]='\0';
4864 player[0].armorlow=atof(mapname);
4869 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
4870 for(i=0;i<numplayers;i++){
4871 player[i].protectionhead=1.0;
4872 player[i].protectionhigh=1.0;
4873 player[i].protectionlow=1.0;
4874 player[i].armorhead=1.0;
4875 player[i].armorhigh=1.0;
4876 player[i].armorlow=1.0;
4882 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
4884 float closestdist=-1;
4887 for(i=1;i<numplayers;i++){
4888 distance=findDistancefast(&player[i].coords,&player[0].coords);
4889 if(closestdist==-1||distance<closestdist){
4890 closestdist=distance;
4900 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4901 mapname[j-startpoint]=consoletext[0][j];
4903 if(consoletext[0][j]=='\0')alldone=1;
4905 mapname[j-startpoint]='\0';
4907 player[closest].protectionhead=atof(mapname);
4911 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4912 mapname[j-startpoint]=consoletext[0][j];
4914 if(consoletext[0][j]=='\0')alldone=1;
4916 mapname[j-startpoint]='\0';
4918 player[closest].protectionhigh=atof(mapname);
4922 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4923 mapname[j-startpoint]=consoletext[0][j];
4925 if(consoletext[0][j]=='\0')alldone=1;
4927 mapname[j-startpoint]='\0';
4929 player[closest].protectionlow=atof(mapname);
4934 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
4936 float closestdist=-1;
4939 for(i=1;i<numplayers;i++){
4940 distance=findDistancefast(&player[i].coords,&player[0].coords);
4941 if(closestdist==-1||distance<closestdist){
4942 closestdist=distance;
4951 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4952 mapname[j-startpoint]=consoletext[0][j];
4954 if(consoletext[0][j]=='\0')alldone=1;
4956 mapname[j-startpoint]='\0';
4958 player[closest].armorhead=atof(mapname);
4962 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4963 mapname[j-startpoint]=consoletext[0][j];
4965 if(consoletext[0][j]=='\0')alldone=1;
4967 mapname[j-startpoint]='\0';
4969 player[closest].armorhigh=atof(mapname);
4973 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4974 mapname[j-startpoint]=consoletext[0][j];
4976 if(consoletext[0][j]=='\0')alldone=1;
4978 mapname[j-startpoint]='\0';
4980 player[closest].armorlow=atof(mapname);
4986 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
4992 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4993 mapname[j-startpoint]=consoletext[0][j];
4995 if(consoletext[0][j]=='\0')alldone=1;
4997 mapname[j-startpoint]='\0';
4999 player[0].metalhead=atof(mapname);
5003 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5004 mapname[j-startpoint]=consoletext[0][j];
5006 if(consoletext[0][j]=='\0')alldone=1;
5008 mapname[j-startpoint]='\0';
5010 player[0].metalhigh=atof(mapname);
5014 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5015 mapname[j-startpoint]=consoletext[0][j];
5017 if(consoletext[0][j]=='\0')alldone=1;
5020 mapname[j-startpoint]='\0';
5022 player[0].metallow=atof(mapname);
5027 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5029 float closestdist=-1;
5032 for(i=1;i<numplayers;i++){
5033 distance=findDistancefast(&player[i].coords,&player[0].coords);
5034 if(closestdist==-1||distance<closestdist){
5035 closestdist=distance;
5039 player[closest].numclothes=0;
5040 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
5041 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5046 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5049 player[closest].numclothes=0;
5050 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
5051 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5055 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5071 for(j=8;j<consolechars[0];j++){
5072 mapname[j-8+15]=consoletext[0][j];
5074 mapname[consolechars[0]-8+15]='.';
5075 mapname[consolechars[0]-8+16]='p';
5076 mapname[consolechars[0]-8+17]='n';
5077 mapname[consolechars[0]-8+18]='g';
5078 mapname[consolechars[0]-8+19]='\0';
5080 //:Data:Textures:Pants.png
5082 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5083 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5084 strcpy(player[0].clothes[player[0].numclothes],mapname);
5085 player[0].clothestintr[player[0].numclothes]=tintr;
5086 player[0].clothestintg[player[0].numclothes]=tintg;
5087 player[0].clothestintb[player[0].numclothes]=tintb;
5088 player[0].numclothes++;
5094 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5095 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5100 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5101 cellophane=1-cellophane;
5104 for(i=0;i<numplayers;i++){
5105 player[i].proportionhead.z=0;
5106 player[i].proportionbody.z=0;
5107 player[i].proportionarms.z=0;
5108 player[i].proportionlegs.z=0;
5113 for(i=0;i<numplayers;i++){
5114 player[i].proportionhead.z=player[i].proportionhead.x;
5115 player[i].proportionbody.z=player[i].proportionbody.x;
5116 player[i].proportionarms.z=player[i].proportionarms.x;
5117 player[i].proportionlegs.z=player[i].proportionlegs.x;
5124 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5140 for(j=12;j<consolechars[0];j++){
5141 mapname[j-12+15]=consoletext[0][j];
5143 mapname[consolechars[0]-12+15]='.';
5144 mapname[consolechars[0]-12+16]='p';
5145 mapname[consolechars[0]-12+17]='n';
5146 mapname[consolechars[0]-12+18]='g';
5147 mapname[consolechars[0]-12+19]='\0';
5149 //:Data:Textures:Pants.png
5151 float closestdist=-1;
5154 for(i=1;i<numplayers;i++){
5155 distance=findDistancefast(&player[i].coords,&player[0].coords);
5156 if(closestdist==-1||distance<closestdist){
5157 closestdist=distance;
5162 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5163 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5164 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5165 player[closest].clothestintr[player[closest].numclothes]=tintr;
5166 player[closest].clothestintg[player[closest].numclothes]=tintg;
5167 player[closest].clothestintb[player[closest].numclothes]=tintb;
5168 player[closest].numclothes++;
5174 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5175 player[0].skeleton.id=0;
5176 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);
5177 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5178 player[0].creature=rabbittype;
5181 player[0].proportionhead=1.2;
5182 player[0].proportionbody=1.05;
5183 player[0].proportionarms=1.00;
5184 player[0].proportionlegs=1.1;
5185 player[0].proportionlegs.y=1.05;
5186 player[0].headless=0;
5188 player[0].damagetolerance=200;
5192 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5193 player[0].skeleton.id=0;
5194 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);
5195 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5196 player[0].creature=wolftype;
5198 player[0].proportionhead=1.1;
5199 player[0].proportionbody=1.1;
5200 player[0].proportionarms=1.1;
5201 player[0].proportionlegs=1.1;
5202 player[0].proportionlegs.y=1.1;
5203 player[0].scale=.23;
5205 player[0].damagetolerance=300;
5209 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5210 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5213 if(Compare(consoletext[0],"rambo ",0,5)){
5214 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5217 if(Compare(consoletext[0],"david ",0,5)){
5218 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5221 if(Compare(consoletext[0],"wolf ",0,4)){
5222 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5225 if(Compare(consoletext[0],"darkwolf ",0,8)){
5226 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5229 if(Compare(consoletext[0],"snowwolf ",0,8)){
5230 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5233 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5234 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5237 if(Compare(consoletext[0],"white ",0,5)){
5238 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5241 if(Compare(consoletext[0],"brown ",0,5)){
5242 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5245 if(Compare(consoletext[0],"black ",0,5)){
5246 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5249 if(consolechars[0]>0){
5252 consoletext[k][j]=consoletext[k-1][j];
5254 consolechars[k]=consolechars[k-1];
5257 consoletext[0][j]=' ';
5263 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5264 OPENAL_SetVolume(channels[consolefailsound], 256);
5265 OPENAL_SetPaused(channels[consolefailsound], false);
5274 togglekeydelay[i]=0;
5278 consoleblinkdelay-=multiplier;
5279 if(consoleblinkdelay<=0){
5280 consoleblinkdelay=.3;
5281 consoleblink=1-consoleblink;
5285 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5288 if(newdetail>2)newdetail=detail;
5289 if(newdetail<0)newdetail=detail;
5290 if(newscreenwidth<0)newscreenwidth=screenwidth;
5291 if(newscreenheight<0)newscreenheight=screenheight;
5293 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5294 opstream << "Screenwidth:\n";
5295 opstream << newscreenwidth;
5296 opstream << "\nScreenheight:\n";
5297 opstream << newscreenheight;
5298 opstream << "\nMouse sensitivity:\n";
5299 opstream << usermousesensitivity;
5300 opstream << "\nBlur(0,1):\n";
5301 opstream << ismotionblur;
5302 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5303 opstream << newdetail;
5304 opstream << "\nFloating jump:\n";
5305 opstream << floatjump;
5306 opstream << "\nMouse jump:\n";
5307 opstream << mousejump;
5308 opstream << "\nAmbient sound:\n";
5309 opstream << ambientsound;
5310 opstream << "\nBlood (0,1,2):\n";
5311 opstream << bloodtoggle;
5312 opstream << "\nAuto slomo:\n";
5313 opstream << autoslomo;
5314 opstream << "\nFoliage:\n";
5315 opstream << foliage;
5316 opstream << "\nMusic:\n";
5317 opstream << musictoggle;
5318 opstream << "\nTrilinear:\n";
5319 opstream << trilinear;
5320 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5322 opstream << "\nInvert mouse:\n";
5323 opstream << invertmouse;
5324 opstream << "\nGamespeed:\n";
5325 if(oldgamespeed==0)oldgamespeed=1;
5326 opstream << oldgamespeed;
5327 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5328 opstream << difficulty;
5329 opstream << "\nDamage effects(blackout, doublevision):\n";
5330 opstream << damageeffects;
5331 opstream << "\nText:\n";
5332 opstream << texttoggle;
5333 opstream << "\nDebug:\n";
5334 opstream << debugmode;
5335 opstream << "\nVBL Sync:\n";
5336 opstream << vblsync;
5337 opstream << "\nShow Points:\n";
5338 opstream << showpoints;
5339 opstream << "\nAlways Blur:\n";
5340 opstream << alwaysblur;
5341 opstream << "\nImmediate mode (turn on on G5):\n";
5342 opstream << immediate;
5343 opstream << "\nVelocity blur:\n";
5344 opstream << velocityblur;
5345 opstream << "\nVolume:\n";
5347 opstream << "\nForward key:\n";
5348 opstream << KeyToChar(forwardkey);
5349 opstream << "\nBack key:\n";
5350 opstream << KeyToChar(backkey);
5351 opstream << "\nLeft key:\n";
5352 opstream << KeyToChar(leftkey);
5353 opstream << "\nRight key:\n";
5354 opstream << KeyToChar(rightkey);
5355 opstream << "\nJump key:\n";
5356 opstream << KeyToChar(jumpkey);
5357 opstream << "\nCrouch key:\n";
5358 opstream << KeyToChar(crouchkey);
5359 opstream << "\nDraw key:\n";
5360 opstream << KeyToChar(drawkey);
5361 opstream << "\nThrow key:\n";
5362 opstream << KeyToChar(throwkey);
5363 opstream << "\nAttack key:\n";
5364 opstream << KeyToChar(attackkey);
5365 opstream << "\nChat key:\n";
5366 opstream << KeyToChar(chatkey);
5371 static int oldwinfreeze;
5372 if(winfreeze&&!oldwinfreeze){
5373 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
5374 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5375 OPENAL_SetVolume(channels[consolesuccesssound], 256);
5376 OPENAL_SetPaused(channels[consolesuccesssound], false);
5378 if(winfreeze==0)oldwinfreeze=winfreeze;
5379 else oldwinfreeze++;
5381 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5382 if(winfreeze)winfreeze=0;
5385 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5391 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5394 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5396 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5398 static bool oldbuttondialogue;
5400 if(indialogue!=-1)talkdelay=1;
5401 talkdelay-=multiplier;
5404 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5405 for(i=0;i<numdialogues;i++){
5406 int realdialoguetype;
5408 if(dialoguetype[i]>49){
5409 realdialoguetype=dialoguetype[i]-50;
5412 else if(dialoguetype[i]>39){
5413 realdialoguetype=dialoguetype[i]-40;
5416 else if(dialoguetype[i]>29){
5417 realdialoguetype=dialoguetype[i]-30;
5420 else if(dialoguetype[i]>19){
5421 realdialoguetype=dialoguetype[i]-20;
5424 else if(dialoguetype[i]>9){
5425 realdialoguetype=dialoguetype[i]-10;
5429 realdialoguetype=dialoguetype[i];
5432 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5433 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5435 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5436 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5437 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5438 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5439 player[participantfocus[whichdialogue][j]].velocity=0;
5440 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5441 player[participantfocus[whichdialogue][j]].targetframe=0;
5446 dialoguegonethrough[i]++;
5447 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5448 static float gLoc[3];
5449 static float vel[3];
5451 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5452 temppos=temppos-viewer;
5453 Normalise(&temppos);
5458 gLoc[2]=temppos.z;vel[0]=0;
5462 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5463 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5464 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5465 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5466 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5467 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5468 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5469 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5470 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5471 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5472 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5473 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5474 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5475 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5476 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5477 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5478 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5479 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5480 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5481 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5482 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5483 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5484 OPENAL_SetVolume(channels[whichsoundplay], 256);
5485 OPENAL_SetPaused(channels[whichsoundplay], false);
5487 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5492 windvar+=multiplier;
5493 smoketex+=multiplier;
5494 tutorialstagetime+=multiplier;
5496 static float hotspotvisual[40];
5500 for(i=0;i<numhotspots;i++)
5501 hotspotvisual[i]-=multiplier/320;
5503 for(i=0;i<numhotspots;i++){
5504 //if(hotspottype[i]<=10)
5505 while(hotspotvisual[i]<0){
5507 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5508 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5509 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5510 hotspotsprite+=hotspot[i];
5511 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5512 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5516 for(i=0;i<numhotspots;i++){
5517 if(hotspottype[i]<=10&&hotspottype[i]>0){
5518 hotspot[i]=player[hotspottype[i]].coords;
5524 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5527 if(tutorialstage<=1){
5532 if(tutorialstage==1){
5535 if(tutorialstage==2){
5538 if(tutorialstage==3){
5539 tutorialmaxtime=600;
5541 if(tutorialstage==4){
5542 tutorialmaxtime=1000;
5544 if(tutorialstage==5){
5545 tutorialmaxtime=600;
5547 if(tutorialstage==6){
5548 tutorialmaxtime=600;
5550 if(tutorialstage==7){
5551 tutorialmaxtime=600;
5553 if(tutorialstage==8){
5554 tutorialmaxtime=600;
5556 if(tutorialstage==9){
5557 tutorialmaxtime=600;
5559 if(tutorialstage==10){
5562 if(tutorialstage==11){
5563 tutorialmaxtime=1000;
5565 if(tutorialstage==12){
5566 tutorialmaxtime=1000;
5568 if(tutorialstage==13){
5571 if(tutorialstage==14){
5583 player[1].coords=(temp+temp2)/2;
5587 gLoc[0]=player[1].coords.x;
5588 gLoc[1]=player[1].coords.y;
5589 gLoc[2]=player[1].coords.z;
5593 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5594 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5595 OPENAL_SetVolume(channels[fireendsound], 256);
5596 OPENAL_SetPaused(channels[fireendsound], false);
5598 for(i=0;i<player[1].skeleton.num_joints;i++){
5600 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5601 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5602 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;
5603 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5604 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5609 if(tutorialstage==15){
5610 tutorialmaxtime=500;
5612 if(tutorialstage==16){
5613 tutorialmaxtime=500;
5615 if(tutorialstage==17){
5616 tutorialmaxtime=500;
5618 if(tutorialstage==18){
5619 tutorialmaxtime=500;
5621 if(tutorialstage==19){
5623 //tutorialmaxtime=500;
5625 if(tutorialstage==20){
5626 tutorialmaxtime=500;
5628 if(tutorialstage==21){
5629 tutorialmaxtime=500;
5636 if(tutorialstage==22){
5637 tutorialmaxtime=500;
5639 if(tutorialstage==23){
5640 tutorialmaxtime=500;
5642 if(tutorialstage==24){
5643 tutorialmaxtime=500;
5645 if(tutorialstage==25){
5646 tutorialmaxtime=500;
5648 if(tutorialstage==26){
5651 if(tutorialstage==27){
5655 player[1].aitype=attacktypecutoff;
5657 if(tutorialstage==28){
5658 tutorialmaxtime=400;
5660 if(tutorialstage==29){
5661 tutorialmaxtime=400;
5662 player[0].escapednum=0;
5664 if(tutorialstage==30){
5668 player[1].aitype=passivetype;
5670 if(tutorialstage==31){
5673 if(tutorialstage==32){
5676 if(tutorialstage==33){
5677 tutorialmaxtime=400;
5680 player[1].aitype=attacktypecutoff;
5682 if(tutorialstage==34){
5683 tutorialmaxtime=400;
5685 if(tutorialstage==35){
5686 tutorialmaxtime=400;
5688 if(tutorialstage==36){
5692 player[1].aitype=passivetype;
5694 if(tutorialstage==37){
5700 player[1].aitype=attacktypecutoff;
5702 if(tutorialstage==38){
5706 player[1].aitype=passivetype;
5708 if(tutorialstage==39){
5719 weapons.owner[weapons.numweapons]=-1;
5720 weapons.type[weapons.numweapons]=knife;
5721 weapons.damage[weapons.numweapons]=0;
5722 weapons.mass[weapons.numweapons]=1;
5723 weapons.tipmass[weapons.numweapons]=1.2;
5724 weapons.length[weapons.numweapons]=.25;
5725 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5726 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5728 weapons.velocity[weapons.numweapons]=0.1;
5729 weapons.tipvelocity[weapons.numweapons]=0.1;
5730 weapons.missed[weapons.numweapons]=1;
5731 weapons.hitsomething[weapons.numweapons]=0;
5732 weapons.freetime[weapons.numweapons]=0;
5733 weapons.firstfree[weapons.numweapons]=1;
5734 weapons.physics[weapons.numweapons]=1;
5736 weapons.numweapons++;
5738 if(tutorialstage==40){
5739 tutorialmaxtime=300;
5741 if(tutorialstage==41){
5742 tutorialmaxtime=300;
5744 if(tutorialstage==42){
5747 if(tutorialstage==43){
5748 tutorialmaxtime=300;
5750 if(tutorialstage==44){
5752 player[0].weaponactive=-1;
5753 player[0].num_weapons=0;
5754 player[1].weaponactive=0;
5755 player[1].num_weapons=1;
5756 player[1].weaponids[0]=0;
5760 player[1].aitype=attacktypecutoff;
5762 tutorialmaxtime=300;
5764 if(tutorialstage==45){
5766 player[0].weaponactive=-1;
5767 player[0].num_weapons=0;
5768 player[1].weaponactive=0;
5769 player[1].num_weapons=1;
5770 player[1].weaponids[0]=0;
5772 tutorialmaxtime=300;
5774 if(tutorialstage==46){
5776 player[0].weaponactive=-1;
5777 player[0].num_weapons=0;
5778 player[1].weaponactive=0;
5779 player[1].num_weapons=1;
5780 player[1].weaponids[0]=0;
5782 weapons.type[0]=sword;
5784 tutorialmaxtime=300;
5787 if(tutorialstage==47){
5799 weapons.owner[weapons.numweapons]=-1;
5800 weapons.type[weapons.numweapons]=sword;
5801 weapons.damage[weapons.numweapons]=0;
5802 weapons.mass[weapons.numweapons]=1;
5803 weapons.tipmass[weapons.numweapons]=1.2;
5804 weapons.length[weapons.numweapons]=.25;
5805 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5806 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5808 weapons.velocity[weapons.numweapons]=0.1;
5809 weapons.tipvelocity[weapons.numweapons]=0.1;
5810 weapons.missed[weapons.numweapons]=1;
5811 weapons.hitsomething[weapons.numweapons]=0;
5812 weapons.freetime[weapons.numweapons]=0;
5813 weapons.firstfree[weapons.numweapons]=1;
5814 weapons.physics[weapons.numweapons]=1;
5818 player[0].weaponactive=0;
5819 player[0].num_weapons=1;
5820 player[0].weaponids[0]=1;
5821 player[1].weaponactive=0;
5822 player[1].num_weapons=1;
5823 player[1].weaponids[0]=0;
5825 weapons.numweapons++;
5827 if(tutorialstage==48){
5830 player[1].aitype=passivetype;
5836 player[0].weaponactive=0;
5837 player[0].num_weapons=1;
5838 player[0].weaponids[0]=1;
5839 player[1].weaponactive=0;
5840 player[1].num_weapons=1;
5841 player[1].weaponids[0]=0;
5843 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
5844 else weapons.type[0]=staff;
5846 weapons.numweapons++;
5848 if(tutorialstage==49){
5851 player[1].aitype=passivetype;
5853 tutorialmaxtime=200;
5855 weapons.position[1]=1000;
5856 weapons.tippoint[1]=1000;
5858 weapons.numweapons=1;
5860 player[1].weaponactive=-1;
5861 player[1].num_weapons=0;
5862 player[0].weaponactive=0;
5863 player[0].num_weapons=1;
5864 player[0].weaponids[0]=0;
5866 weapons.type[0]=knife;
5868 weapons.numweapons++;
5870 if(tutorialstage==50){
5876 gLoc[0]=player[1].coords.x;
5877 gLoc[1]=player[1].coords.y;
5878 gLoc[2]=player[1].coords.z;
5882 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5883 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5884 OPENAL_SetVolume(channels[fireendsound], 256);
5885 OPENAL_SetPaused(channels[fireendsound], false);
5887 for(i=0;i<player[1].skeleton.num_joints;i++){
5889 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5890 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5891 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;
5892 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5893 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5897 player[1].num_weapons=0;
5898 player[1].weaponstuck=-1;
5899 player[1].weaponactive=-1;
5901 weapons.numweapons=0;
5903 weapons.owner[0]=-1;
5904 weapons.velocity[0]=0.1;
5905 weapons.tipvelocity[0]=-0.1;
5906 weapons.missed[0]=1;
5907 weapons.hitsomething[0]=0;
5908 weapons.freetime[0]=0;
5909 weapons.firstfree[0]=1;
5910 weapons.physics[0]=1;
5912 if(tutorialstage==51){
5913 tutorialmaxtime=80000;
5915 if(tutorialstage<=51)tutorialstagetime=0;
5919 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
5920 if(tutorialstage==3){
5921 if(deltah||deltav)tutorialsuccess+=multiplier;
5923 if(tutorialstage==4){
5924 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
5926 if(tutorialstage==5){
5927 if(player[0].jumpkeydown)tutorialsuccess=1;
5929 if(tutorialstage==6){
5930 if(player[0].isCrouch())tutorialsuccess=1;
5932 if(tutorialstage==7){
5933 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
5935 if(tutorialstage==8){
5936 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
5938 if(tutorialstage==9){
5939 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
5941 if(tutorialstage==11){
5942 if(player[0].isWallJump())tutorialsuccess=1;
5944 if(tutorialstage==12){
5945 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
5947 if(tutorialstage==15){
5948 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
5950 if(tutorialstage==16){
5951 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
5953 if(tutorialstage==17){
5954 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
5956 if(tutorialstage==18){
5957 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
5959 if(tutorialstage==19){
5960 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
5962 if(tutorialstage==20){
5963 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
5965 if(tutorialstage==21){
5966 if(bonus==cannon)tutorialsuccess=1;
5968 if(tutorialstage==22){
5969 if(bonus==spinecrusher)tutorialsuccess=1;
5971 if(tutorialstage==23){
5972 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
5974 if(tutorialstage==24){
5975 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
5977 if(tutorialstage==25){
5978 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
5980 if(tutorialstage==28){
5981 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
5983 if(tutorialstage==29){
5984 if(player[0].escapednum==2){
5988 player[1].aitype=passivetype;
5991 if(tutorialstage==33){
5992 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
5994 if(tutorialstage==34){
5995 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
5997 if(tutorialstage==35){
5998 if(animation[player[0].targetanimation].attack==reversal){
6002 player[1].aitype=passivetype;
6005 if(tutorialstage==40){
6006 if(player[0].num_weapons>0)tutorialsuccess=1;
6008 if(tutorialstage==41){
6009 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6011 if(tutorialstage==43){
6012 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6014 if(tutorialstage==44){
6015 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6017 if(tutorialstage==45){
6018 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6020 if(tutorialstage==46){
6021 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6023 if(tutorialstage==49){
6024 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6026 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6029 if(tutorialstagetime==tutorialmaxtime-3){
6030 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6031 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6032 OPENAL_SetPaused(channels[consolesuccesssound], false);
6035 if(tutorialsuccess>=1){
6036 if(tutorialstage==34||tutorialstage==35)
6037 tutorialstagetime=tutorialmaxtime-1;
6042 if(tutorialstage<14||tutorialstage>=50){
6043 player[1].coords.y=300;
6044 player[1].velocity=0;
6048 if(tutoriallevel!=1){
6049 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6050 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6051 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6052 OPENAL_SetPaused(channels[consolesuccesssound], false);
6057 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6058 OPENAL_SetVolume(channels[fireendsound], 256);
6059 OPENAL_SetPaused(channels[fireendsound], false);
6062 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6063 else bonusnum[bonus]+=0.15;
6064 if(tutoriallevel)bonusvalue=0;
6065 bonusvalue/=bonusnum[bonus];
6066 bonustotal+=bonusvalue;
6068 bonustime+=multiplier;
6070 if(environment==snowyenvironment){
6071 precipdelay-=multiplier;
6072 while(precipdelay<0){
6074 if(!detail)precipdelay+=.04;
6075 XYZ footvel,footpoint;
6078 footpoint=viewer+viewerfacing*6;
6079 footpoint.y+=((float)abs(Random()%1200))/100-6;
6080 footpoint.x+=((float)abs(Random()%1200))/100-6;
6081 footpoint.z+=((float)abs(Random()%1200))/100-6;
6082 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6085 for(k=0;k<numplayers;k++){
6086 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6087 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6089 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){
6090 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6091 else if(player[k].rotation>player[k].targetrotation){
6092 player[k].rotation-=multiplier*player[k].turnspeed;
6094 else if(player[k].rotation<player[k].targetrotation){
6095 player[k].rotation+=multiplier*player[k].turnspeed;
6100 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))){
6101 player[k].turnspeed*=2;
6102 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6103 else if(player[k].rotation>player[k].targetrotation){
6104 player[k].rotation-=multiplier*player[k].turnspeed;
6106 else if(player[k].rotation<player[k].targetrotation){
6107 player[k].rotation+=multiplier*player[k].turnspeed;
6109 player[k].turnspeed/=2;
6112 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6113 player[k].turnspeed*=4;
6114 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6115 else if(player[k].rotation>player[k].targetrotation){
6116 player[k].rotation-=multiplier*player[k].turnspeed;
6118 else if(player[k].rotation<player[k].targetrotation){
6119 player[k].rotation+=multiplier*player[k].turnspeed;
6121 player[k].turnspeed/=4;
6124 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6125 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6127 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6128 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6131 if(player[k].collide<-.3)player[k].collide=-.3;
6132 if(player[k].collide>1)player[k].collide=1;
6133 player[k].collide-=multiplier*30;
6135 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6136 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6138 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6139 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6140 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6141 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6142 lowpoint=player[k].coords;
6143 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6144 else lowpoint.y+=1.3;
6145 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){
6146 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6148 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6149 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6151 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6152 flatfacing=lowpoint-player[k].coords;
6153 player[k].coords=lowpoint;
6154 player[k].coords.y-=1.3;
6155 player[k].collide=1;
6157 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6158 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6159 tempcoords1=lowpoint;
6160 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6161 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6163 player[k].targetanimation=walljumpleftanim;
6164 player[k].targetframe=0;
6167 gLoc[0]=player[k].coords.x;
6168 gLoc[1]=player[k].coords.y;
6169 gLoc[2]=player[k].coords.z;
6173 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6174 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6175 OPENAL_SetVolume(channels[movewhooshsound], 256);
6176 OPENAL_SetPaused(channels[movewhooshsound], false);
6177 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6179 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6180 player[k].rotation=-asin(0-lowpointtarget.x);
6181 player[k].rotation*=360/6.28;
6182 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6183 player[k].targetrotation=player[k].rotation;
6184 player[k].lowrotation=player[k].rotation;
6185 if(k==0)numwallflipped++;
6189 lowpoint=tempcoords1;
6190 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6191 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6192 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6194 player[k].targetanimation=walljumprightanim;
6195 player[k].targetframe=0;
6198 gLoc[0]=player[k].coords.x;
6199 gLoc[1]=player[k].coords.y;
6200 gLoc[2]=player[k].coords.z;
6204 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6205 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6206 OPENAL_SetVolume(channels[movewhooshsound], 256);
6207 OPENAL_SetPaused(channels[movewhooshsound], false);
6208 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6210 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6211 player[k].rotation=-asin(0-lowpointtarget.x);
6212 player[k].rotation*=360/6.28;
6213 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6214 player[k].targetrotation=player[k].rotation;
6215 player[k].lowrotation=player[k].rotation;
6216 if(k==0)numwallflipped++;
6220 lowpoint=tempcoords1;
6221 lowpointtarget=lowpoint+player[k].facing*2;
6222 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6223 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6225 player[k].targetanimation=walljumpbackanim;
6226 player[k].targetframe=0;
6229 gLoc[0]=player[k].coords.x;
6230 gLoc[1]=player[k].coords.y;
6231 gLoc[2]=player[k].coords.z;
6235 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6236 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6237 OPENAL_SetVolume(channels[movewhooshsound], 256);
6238 OPENAL_SetPaused(channels[movewhooshsound], false);
6239 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6241 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6242 player[k].rotation=-asin(0-lowpointtarget.x);
6243 player[k].rotation*=360/6.28;
6244 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6245 player[k].targetrotation=player[k].rotation;
6246 player[k].lowrotation=player[k].rotation;
6247 if(k==0)numwallflipped++;
6251 lowpoint=tempcoords1;
6252 lowpointtarget=lowpoint-player[k].facing*2;
6253 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6254 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6256 player[k].targetanimation=walljumpfrontanim;
6257 player[k].targetframe=0;
6260 gLoc[0]=player[k].coords.x;
6261 gLoc[1]=player[k].coords.y;
6262 gLoc[2]=player[k].coords.z;
6266 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6267 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6268 OPENAL_SetVolume(channels[movewhooshsound], 256);
6269 OPENAL_SetPaused(channels[movewhooshsound], false);
6270 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6272 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6273 player[k].rotation=-asin(0-lowpointtarget.x);
6274 player[k].rotation*=360/6.28;
6275 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6276 player[k].rotation+=180;
6277 player[k].targetrotation=player[k].rotation;
6278 player[k].lowrotation=player[k].rotation;
6279 if(k==0)numwallflipped++;
6287 else if(objects.type[i]==rocktype){
6288 lowpoint2=player[k].coords;
6289 lowpoint=player[k].coords;
6291 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6292 player[k].coords=colpoint;
6293 player[k].collide=1;
6296 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6297 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6299 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6301 player[k].targetframe=0;
6302 player[k].onterrain=1;
6304 if(player[k].id==0){
6305 OPENAL_SetPaused(channels[whooshsound], true);
6306 OPENAL_SetVolume(channels[whooshsound], 0);
6309 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6310 if(player[k].isFlip())player[k].jumppower=-4;
6311 player[k].targetanimation=player[k].getLanding();
6314 gLoc[0]=player[k].coords.x;
6315 gLoc[1]=player[k].coords.y;
6316 gLoc[2]=player[k].coords.z;
6317 vel[0]=player[k].velocity.x;
6318 vel[1]=player[k].velocity.y;
6319 vel[2]=player[k].velocity.z;
6320 PlaySoundEx( landsound, samp[landsound], NULL, true);
6321 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6322 OPENAL_SetVolume(channels[landsound], 128);
6323 OPENAL_SetPaused(channels[landsound], false);
6325 envsound[numenvsounds]=player[k].coords;
6326 envsoundvol[numenvsounds]=16;
6327 envsoundlife[numenvsounds]=.4;
6336 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6337 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6338 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6339 lowpoint=player[k].coords;
6341 if(objects.type[i]!=rocktype)
6342 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6343 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6344 player[k].coords=lowpoint;
6345 player[k].coords.y-=1.35;
6346 player[k].collide=1;
6348 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)){
6349 lowpoint=player[k].coords;
6350 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6351 lowpoint=player[k].coords;
6355 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6356 lowpointtarget=lowpoint+facing*1.4;
6357 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6359 lowpoint=player[k].coords;
6361 lowpointtarget=lowpoint+facing*1.4;
6363 lowpointtarget2=lowpointtarget;
6365 lowpointtarget3=lowpointtarget;
6367 lowpointtarget4=lowpointtarget;
6369 lowpointtarget5=lowpointtarget;
6371 lowpointtarget6=lowpointtarget;
6373 lowpointtarget7=lowpoint;
6375 lowpointtarget2.x+=.1;
6377 lowpointtarget3.z+=.1;
6379 lowpointtarget4.x-=.1;
6381 lowpointtarget5.z-=.1;
6383 lowpointtarget6.y+=45/13;
6384 lowpointtarget6+=facing*.6;
6385 lowpointtarget7.y+=90/13;
6386 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6387 if(objects.friction[i]>.5)
6390 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6391 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6392 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6393 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)
6395 lowpoint=player[k].coords;
6396 lowpoint.y+=(float)j/13;
6397 lowpointtarget=lowpoint+facing*1.4;
6398 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6402 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6405 if(j<=25&&player[k].targetanimation==jumpdownanim){
6408 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6409 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6410 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)*/){
6411 lowpoint=player[k].coords;
6412 lowpoint.y+=(float)j/13;
6413 lowpointtarget=lowpoint+facing*1.3;
6414 flatfacing=player[k].coords;
6415 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6416 player[k].coords.y=lowpointtarget.y-.07;
6417 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6419 if(j>10||!player[k].isRun()){
6420 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6421 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6425 gLoc[0]=player[k].coords.x;
6426 gLoc[1]=player[k].coords.y;
6427 gLoc[2]=player[k].coords.z;
6428 vel[0]=player[k].velocity.x;
6429 vel[1]=player[k].velocity.y;
6430 vel[2]=player[k].velocity.z;
6431 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6432 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6433 OPENAL_SetVolume(channels[jumpsound], 128);
6434 OPENAL_SetPaused(channels[jumpsound], false);
6436 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6437 player[k].rotation=-asin(0-lowpointtarget.x);
6438 player[k].rotation*=360/6.28;
6439 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6440 player[k].targetrotation=player[k].rotation;
6441 player[k].lowrotation=player[k].rotation;
6443 //player[k].velocity=lowpointtarget*.03;
6444 player[k].velocity=0;
6446 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6447 //player[k].currentanimation=climbanim;
6448 player[k].targetanimation=climbanim;
6449 player[k].jumppower=0;
6450 player[k].jumpclimb=1;
6452 player[k].transspeed=6;
6455 //player[k].currentframe=1;
6456 player[k].targetframe=1;
6458 //player[k].currentframe=0;
6459 player[k].targetframe=0;
6460 //player[k].currentanimation=hanganim;
6461 player[k].targetanimation=hanganim;
6462 player[k].jumppower=0;
6476 if(player[k].collide<=0){
6477 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()){
6478 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)){
6479 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6480 player[k].targetanimation=jumpdownanim;
6481 player[k].targetframe=0;
6486 gLoc[0]=player[k].coords.x;
6487 gLoc[1]=player[k].coords.y;
6488 gLoc[2]=player[k].coords.z;
6489 vel[0]=player[k].velocity.x;
6490 vel[1]=player[k].velocity.y;
6491 vel[2]=player[k].velocity.z;
6493 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6494 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6495 OPENAL_SetVolume(channels[whooshsound], 128);
6496 OPENAL_SetPaused(channels[whooshsound], false);
6499 player[k].velocity.y+=gravity;
6504 player[k].realoldcoords=player[k].coords;
6507 static XYZ oldviewer;
6510 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6511 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6512 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6513 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6514 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6515 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6516 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6517 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6521 player[0].forwardkeydown=0;
6522 player[0].leftkeydown=0;
6523 player[0].backkeydown=0;
6524 player[0].rightkeydown=0;
6525 player[0].jumpkeydown=0;
6526 player[0].crouchkeydown=0;
6527 player[0].drawkeydown=0;
6528 player[0].throwkeydown=0;
6531 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6534 static bool endkeydown;
6541 facing=DoRotation(facing,-rotation2,0,0);
6542 facing=DoRotation(facing,0,0-rotation,0);
6547 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6549 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6550 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6551 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6552 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6553 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6554 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6555 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)
6556 ||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)
6557 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6559 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6560 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6561 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6562 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6563 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6564 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6565 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6566 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6567 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6568 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6569 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6571 participantfocus[whichdialogue][indialogue]=whichend;
6572 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6573 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6576 participantfocus[whichdialogue][indialogue]=-1;
6578 if(player[participantfocus[whichdialogue][indialogue]].dead){
6583 dialoguecamera[whichdialogue][indialogue]=viewer;
6584 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6585 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6587 if(indialogue<numdialogueboxes[whichdialogue]){
6588 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6589 static float gLoc[3];
6590 static float vel[3];
6592 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6593 temppos=temppos-viewer;
6594 Normalise(&temppos);
6599 gLoc[2]=temppos.z;vel[0]=0;
6603 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6604 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6605 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6606 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6607 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6608 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6609 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6610 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6611 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6612 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6613 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6614 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6615 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6616 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6617 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6618 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6619 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6620 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6621 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6622 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6623 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6624 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6625 OPENAL_SetVolume(channels[whichsoundplay], 256);
6626 OPENAL_SetPaused(channels[whichsoundplay], false);
6630 for(j=0;j<numplayers;j++){
6631 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6636 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)
6637 ||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)
6640 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6641 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6642 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6643 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6644 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6645 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6646 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6647 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6648 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6649 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6650 participantfacing[whichdialogue][indialogue][whichend]=facing;
6652 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)
6653 &&!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)
6654 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6657 if(indialogue>=numdialogueboxes[whichdialogue]){
6664 OPENAL_SetPaused(channels[whooshsound], true);
6665 viewer=dialoguecamera[whichdialogue][indialogue];
6666 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
6667 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
6669 rotation=dialoguecamerarotation[whichdialogue][indialogue];
6670 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
6671 if(dialoguetime>0.5)
6672 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)
6673 ||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)
6674 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
6677 if(indialogue<numdialogueboxes[whichdialogue]){
6678 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6679 static float gLoc[3];
6680 static float vel[3];
6682 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6683 temppos=temppos-viewer;
6684 Normalise(&temppos);
6689 gLoc[2]=temppos.z;vel[0]=0;
6693 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6694 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6695 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6696 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6697 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6698 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6699 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6700 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6701 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6702 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6703 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6704 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6705 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6706 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6707 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6708 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6709 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6710 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6711 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6712 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6713 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
6714 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
6715 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6716 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6717 OPENAL_SetVolume(channels[whichsoundplay], 256);
6718 OPENAL_SetPaused(channels[whichsoundplay], false);
6720 if(dialogueboxsound[whichdialogue][indialogue]==-5){
6721 hotspot[numhotspots]=player[0].coords;
6722 hotspotsize[numhotspots]=10;
6723 hotspottype[numhotspots]=-1;
6727 if(dialogueboxsound[whichdialogue][indialogue]==-6){
6731 if(player[participantfocus[whichdialogue][indialogue]].dead){
6739 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)
6740 &&!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)
6741 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6744 if(indialogue>=numdialogueboxes[whichdialogue]){
6748 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
6751 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
6754 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
6756 for(i=1;i<numplayers;i++){
6757 player[i].aitype = attacktypecutoff;
6764 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
6765 else oldbuttondialogue=1;
6767 static float keyrefreshdelay=0,bigrefreshdelay=0;
6771 /*keyrefreshdelay-=multiplier;
6772 bigrefreshdelay-=multiplier;
6774 if(keyrefreshdelay<=0){
6775 static int concat[4];
6777 concat[0]=player[0].forwardkeydown;
6778 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
6779 concat[0]=concat[0]*2+player[0].rightkeydown;
6780 concat[0]=concat[0]*2+player[0].leftkeydown;
6781 concat[0]=concat[0]*2+player[0].backkeydown;
6782 concat[0]=concat[0]*2+player[0].jumpkeydown;
6783 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
6784 concat[0]=concat[0]*2+player[0].crouchkeydown;
6786 concat[1]=player[0].crouchtogglekeydown;
6787 concat[1]=concat[1]*2+player[0].drawkeydown;
6788 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
6789 concat[1]=concat[1]*2+player[0].throwkeydown;
6790 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
6791 concat[1]=concat[1]*2+player[0].attackkeydown;
6793 //concat[2]=(char)((int)(rotation/2)%180);
6795 //concat[3]=(char)((int)(rotation2/2)%180);
6797 chatname[0]=concat[0]-128;
6798 chatname[1]=concat[1]-128;
6799 //chatname[2]=concat[2]-128;
6800 //chatname[3]=concat[3]-128;
6802 memcpy(chatname+temppoint,&rotation,sizeof(float));
6803 temppoint+=sizeof(float);
6804 memcpy(chatname+temppoint,&rotation2,sizeof(float));
6805 temppoint+=sizeof(float);
6807 chatname[temppoint]='\0';
6809 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
6810 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
6811 //keyrefreshdelay=.01;
6812 keyrefreshdelay=.03;
6815 if(bigrefreshdelay<=0){
6818 memcpy(chatname+temppoint,&i,sizeof(int));
6819 temppoint+=sizeof(int);
6820 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
6821 temppoint+=sizeof(float);
6822 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
6823 temppoint+=sizeof(float);
6824 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
6825 temppoint+=sizeof(float);
6826 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
6827 temppoint+=sizeof(float);
6828 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
6829 temppoint+=sizeof(float);
6830 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
6831 temppoint+=sizeof(int);
6832 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
6833 temppoint+=sizeof(int);
6834 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
6835 temppoint+=sizeof(float);
6836 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
6837 temppoint+=sizeof(float);
6838 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
6839 temppoint+=sizeof(float);
6840 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
6841 temppoint+=sizeof(int);
6842 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
6843 temppoint+=sizeof(int);
6844 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
6845 temppoint+=sizeof(float);
6846 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
6847 temppoint+=sizeof(float);
6848 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
6849 temppoint+=sizeof(float);
6850 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
6851 temppoint+=sizeof(int);
6852 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
6853 temppoint+=sizeof(int);
6854 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
6855 temppoint+=sizeof(int);
6856 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
6857 temppoint+=sizeof(int);
6858 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
6859 temppoint+=sizeof(int);
6860 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
6861 temppoint+=sizeof(int);
6862 chatname[temppoint]='\0';
6864 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);
6865 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
6866 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
6868 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);
6870 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
6871 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
6873 //bigrefreshdelay=.02;
6878 if(!player[0].jumpkeydown){
6879 player[0].jumptogglekeydown=0;
6881 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
6884 dialoguetime+=multiplier;
6885 skybox.cloudmove+=multiplier;
6886 hawkrotation+=multiplier*25;
6888 realhawkcoords.x=25;
6889 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
6890 hawkcalldelay-=multiplier/2;
6892 if(hawkcalldelay<=0)
6894 static float gLoc[3];
6895 static float vel[3];
6896 gLoc[0]=realhawkcoords.x;
6897 gLoc[1]=realhawkcoords.y;
6898 gLoc[2]=realhawkcoords.z;
6902 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
6903 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
6904 OPENAL_SetVolume(channels[hawksound], 128);
6905 OPENAL_SetPaused(channels[hawksound], false);
6907 hawkcalldelay=16+abs(Random()%8);
6909 static float temptexdetail;
6912 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
6913 player[0].damagetolerance=200000;
6916 player[0].permanentdamage=0;
6917 player[0].superpermanentdamage=0;
6920 whichchar = abs(Random()%7);
6921 registrationname[whichchar]+=1;
6925 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
6927 if(environment>2)environment=0;
6928 Setenvironment(environment);
6934 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
6938 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
6939 cameramode=1-cameramode;
6940 cameratogglekeydown=1;
6943 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
6944 cameratogglekeydown=0;
6947 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
6948 if(player[0].num_weapons>0){
6949 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
6950 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
6951 else weapons.type[player[0].weaponids[0]]=sword;
6952 if(weapons.type[player[0].weaponids[0]]==sword){
6953 weapons.mass[player[0].weaponids[0]]=1.5;
6954 weapons.tipmass[player[0].weaponids[0]]=1;
6955 weapons.length[player[0].weaponids[0]]=.8;
6957 if(weapons.type[player[0].weaponids[0]]==staff){
6958 weapons.mass[player[0].weaponids[0]]=2;
6959 weapons.tipmass[player[0].weaponids[0]]=1;
6960 weapons.length[player[0].weaponids[0]]=1.5;
6963 if(weapons.type[player[0].weaponids[0]]==knife){
6964 weapons.mass[player[0].weaponids[0]]=1;
6965 weapons.tipmass[player[0].weaponids[0]]=1.2;
6966 weapons.length[player[0].weaponids[0]]=.25;
6970 /*for(i=0;i<objects.numobjects;i++){
6971 if(objects.type[i]==treeleavestype){
6972 for(j=0;j<objects.numobjects;j++){
6973 if(objects.type[j]==treetrunktype)
6974 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
6975 objects.scale[i]=objects.scale[j];
6979 detailtogglekeydown=1;
6982 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
6984 float closestdist=-1;
6987 for(i=1;i<numplayers;i++){
6988 distance=findDistancefast(&player[i].coords,&player[0].coords);
6989 if(closestdist==-1||distance<closestdist){
6990 closestdist=distance;
6995 if(player[closest].num_weapons)
6997 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
6998 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
6999 else weapons.type[player[closest].weaponids[0]]=sword;
7000 if(weapons.type[player[closest].weaponids[0]]==sword){
7001 weapons.mass[player[closest].weaponids[0]]=1.5;
7002 weapons.tipmass[player[closest].weaponids[0]]=1;
7003 weapons.length[player[closest].weaponids[0]]=.8;
7005 if(weapons.type[player[0].weaponids[0]]==staff){
7006 weapons.mass[player[0].weaponids[0]]=2;
7007 weapons.tipmass[player[0].weaponids[0]]=1;
7008 weapons.length[player[0].weaponids[0]]=1.5;
7010 if(weapons.type[player[closest].weaponids[0]]==knife){
7011 weapons.mass[player[closest].weaponids[0]]=1;
7012 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7013 weapons.length[player[closest].weaponids[0]]=.25;
7016 if(!player[closest].num_weapons)
7018 player[closest].weaponids[0]=weapons.numweapons;
7019 weapons.owner[weapons.numweapons]=closest;
7020 weapons.type[weapons.numweapons]=knife;
7021 weapons.damage[weapons.numweapons]=0;
7022 weapons.numweapons++;
7023 player[closest].num_weapons=1;
7024 if(weapons.type[player[closest].weaponids[0]]==sword){
7025 weapons.mass[player[closest].weaponids[0]]=1.5;
7026 weapons.tipmass[player[closest].weaponids[0]]=1;
7027 weapons.length[player[closest].weaponids[0]]=.8;
7029 if(weapons.type[player[closest].weaponids[0]]==knife){
7030 weapons.mass[player[closest].weaponids[0]]=1;
7031 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7032 weapons.length[player[closest].weaponids[0]]=.25;
7036 detailtogglekeydown=1;
7039 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7041 float closestdist=-1;
7044 for(i=1;i<numplayers;i++){
7045 distance=findDistancefast(&player[i].coords,&player[0].coords);
7046 if(closestdist==-1||distance<closestdist){
7047 closestdist=distance;
7052 player[closest].rotation+=multiplier*50;
7053 player[closest].targetrotation=player[closest].rotation;
7057 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7059 float closestdist=-1;
7062 for(i=1;i<numplayers;i++){
7063 distance=findDistancefast(&player[i].coords,&player[0].coords);
7064 if(closestdist==-1||distance<closestdist){
7065 closestdist=distance;
7069 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7072 player[closest].whichskin++;
7073 if(player[closest].whichskin>9)player[closest].whichskin=0;
7074 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7076 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
7077 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7080 if(player[closest].numclothes){
7081 for(i=0;i<player[closest].numclothes;i++){
7082 tintr=player[closest].clothestintr[i];
7083 tintg=player[closest].clothestintg[i];
7084 tintb=player[closest].clothestintb[i];
7085 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7087 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7090 detailtogglekeydown=1;
7093 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7095 float closestdist=-1;
7098 for(i=1;i<numplayers;i++){
7099 distance=findDistancefast(&player[i].coords,&player[0].coords);
7100 if(closestdist==-1||distance<closestdist){
7101 closestdist=distance;
7106 if(player[closest].creature==wolftype){
7107 headprop=player[closest].proportionhead.x/1.1;
7108 bodyprop=player[closest].proportionbody.x/1.1;
7109 armprop=player[closest].proportionarms.x/1.1;
7110 legprop=player[closest].proportionlegs.x/1.1;
7113 if(player[closest].creature==rabbittype){
7114 headprop=player[closest].proportionhead.x/1.2;
7115 bodyprop=player[closest].proportionbody.x/1.05;
7116 armprop=player[closest].proportionarms.x/1.00;
7117 legprop=player[closest].proportionlegs.x/1.1;
7121 if(player[closest].creature==rabbittype){
7122 player[closest].skeleton.id=closest;
7123 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);
7124 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7125 player[closest].whichskin=0;
7126 player[closest].creature=wolftype;
7128 player[closest].proportionhead=1.1;
7129 player[closest].proportionbody=1.1;
7130 player[closest].proportionarms=1.1;
7131 player[closest].proportionlegs=1.1;
7132 player[closest].proportionlegs.y=1.1;
7133 player[closest].scale=.23*5*player[0].scale;
7135 player[closest].damagetolerance=300;
7139 player[closest].skeleton.id=closest;
7140 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);
7141 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7142 player[closest].whichskin=0;
7143 player[closest].creature=rabbittype;
7145 player[closest].proportionhead=1.2;
7146 player[closest].proportionbody=1.05;
7147 player[closest].proportionarms=1.00;
7148 player[closest].proportionlegs=1.1;
7149 player[closest].proportionlegs.y=1.05;
7150 player[closest].scale=.2*5*player[0].scale;
7152 player[closest].damagetolerance=200;
7155 if(player[closest].creature==wolftype){
7156 player[closest].proportionhead=1.1*headprop;
7157 player[closest].proportionbody=1.1*bodyprop;
7158 player[closest].proportionarms=1.1*armprop;
7159 player[closest].proportionlegs=1.1*legprop;
7162 if(player[closest].creature==rabbittype){
7163 player[closest].proportionhead=1.2*headprop;
7164 player[closest].proportionbody=1.05*bodyprop;
7165 player[closest].proportionarms=1.00*armprop;
7166 player[closest].proportionlegs=1.1*legprop;
7167 player[closest].proportionlegs.y=1.05*legprop;
7171 detailtogglekeydown=1;
7174 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7175 detailtogglekeydown=0;
7178 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7181 slomotogglekeydown=1;
7185 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7187 float closestdist=-1;
7189 XYZ flatfacing2,flatvelocity2;
7192 for(i=1;i<numplayers;i++){
7193 distance=findDistancefast(&player[i].coords,&player[0].coords);
7194 if(distance<144&&!player[i].headless)
7195 if(closestdist==-1||distance<closestdist){
7196 closestdist=distance;
7198 blah = player[i].coords;
7203 XYZ headspurtdirection;
7204 int i = player[closest].skeleton.jointlabels[head];
7205 for(k=0;k<player[closest].skeleton.num_joints; k++){
7206 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7207 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7208 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;
7209 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7210 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7211 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7212 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7213 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7214 Normalise(&headspurtdirection);
7215 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7216 flatvelocity2+=headspurtdirection*8;
7217 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7219 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7229 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7230 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7231 OPENAL_SetVolume(channels[splattersound], 256);
7232 OPENAL_SetPaused(channels[splattersound], false);
7234 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7235 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7236 OPENAL_SetVolume(channels[breaksound2], 100);
7237 OPENAL_SetPaused(channels[breaksound2], false);
7239 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7240 player[closest].RagDoll(0);
7241 player[closest].dead=2;
7242 player[closest].headless=1;
7243 player[closest].DoBloodBig(3,165);
7248 explodetogglekeydown=1;
7251 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7253 float closestdist=-1;
7255 XYZ flatfacing2,flatvelocity2;
7258 for(i=1;i<numplayers;i++){
7259 distance=findDistancefast(&player[i].coords,&player[0].coords);
7261 if(closestdist==-1||distance<closestdist){
7262 closestdist=distance;
7264 blah=player[i].coords;
7278 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7279 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7280 OPENAL_SetVolume(channels[splattersound], 256);
7281 OPENAL_SetPaused(channels[splattersound], false);
7283 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7284 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7285 OPENAL_SetVolume(channels[breaksound2], 600);
7286 OPENAL_SetPaused(channels[breaksound2], false);
7288 for(i=0;i<player[closest].skeleton.num_joints; i++){
7289 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7290 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7291 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;
7292 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7293 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7294 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7295 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7296 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7297 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7298 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7301 for(i=0;i<player[closest].skeleton.num_joints; i++){
7302 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7303 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7304 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;
7305 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7306 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7307 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7308 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7309 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7310 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7313 for(i=0;i<player[closest].skeleton.num_joints; i++){
7314 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7315 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7316 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;
7317 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7318 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7319 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7320 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7321 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7322 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7325 for(i=0;i<player[closest].skeleton.num_joints; i++){
7326 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7327 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7328 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;
7329 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7330 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7331 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7332 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7333 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7334 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7338 for(j=0;j<numplayers; j++){
7340 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7341 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7342 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7343 player[j].skeleton.longdead=0;
7344 player[j].RagDoll(0);
7345 for(i=0;i<player[j].skeleton.num_joints; i++){
7346 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7347 if(findDistancefast(&temppos,&player[closest].coords)<25){
7348 flatvelocity2=temppos-player[closest].coords;
7349 Normalise(&flatvelocity2);
7350 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7357 player[closest].DoDamage(10000);
7358 player[closest].RagDoll(0);
7359 player[closest].dead=2;
7360 player[closest].coords=20;
7361 player[closest].skeleton.free=2;
7367 explodetogglekeydown=1;
7370 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7371 explodetogglekeydown=0;
7375 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7377 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7378 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7379 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7380 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7381 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7382 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7383 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7385 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7386 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7387 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7388 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7389 for(j=0;j<player[0].num_weapons;j++){
7390 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7392 fwrite( &environment, 1, sizeof(int), tfile );
7394 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7395 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7396 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7397 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7398 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7400 fwrite( &numplayers, 1, sizeof(int), tfile );
7401 if(numplayers>1&&numplayers<maxplayers)
7402 for(i=1;i<numplayers;i++){
7403 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7404 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7405 for(j=0;j<player[i].num_weapons;j++){
7406 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7408 if(player[i].numwaypoints<30){
7409 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7410 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7411 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7412 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7415 player[i].numwaypoints=0;
7416 player[i].waypoint=0;
7417 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7418 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7419 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7425 slomotogglekeydown=1;
7428 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7429 slomotogglekeydown=0;
7433 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7434 player[0].onfire=1-player[0].onfire;
7435 if(player[0].onfire){
7436 player[0].CatchFire();
7438 if(!player[0].onfire){
7441 gLoc[0]=player[0].coords.x;
7442 gLoc[1]=player[0].coords.y;
7443 gLoc[2]=player[0].coords.z;
7447 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7448 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7449 OPENAL_SetVolume(channels[fireendsound], 256);
7450 OPENAL_SetPaused(channels[fireendsound], false);
7451 OPENAL_SetPaused(channels[stream_firesound], true);
7453 slomotogglekeydown=1;
7456 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7457 if(player[0].bleeding<=0)
7458 player[0].DoBlood(1,255);
7462 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7464 float closestdist=-1;
7467 for(i=1;i<numplayers;i++){
7468 distance=findDistancefast(&player[i].coords,&player[0].coords);
7469 if(closestdist==-1||distance<closestdist){
7470 closestdist=distance;
7474 if(closestdist>0&&closest>=0){
7475 //player[closest]=player[numplayers-1];
7476 //player[closest].skeleton=player[numplayers-1].skeleton;
7479 drawmodetogglekeydown=1;
7482 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7484 float closestdist=-1;
7487 for(i=1;i<max_objects;i++){
7488 distance=findDistancefast(&objects.position[i],&player[0].coords);
7489 if(closestdist==-1||distance<closestdist){
7490 closestdist=distance;
7494 if(closestdist>0&&closest>=0){
7495 objects.position[closest].y-=500;
7497 drawmodetogglekeydown=1;
7500 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7502 //if(drawmode>2)drawmode=0;
7503 if(objects.numobjects<max_objects-1){
7505 boxcoords.x=player[0].coords.x;
7506 boxcoords.z=player[0].coords.z;
7507 boxcoords.y=player[0].coords.y-3;
7508 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7509 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7510 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7511 float temprotat,temprotat2;
7512 temprotat=editorrotation;
7513 temprotat2=editorrotation2;
7514 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7515 if(temprotat2<0)temprotat2=Random()%360;
7517 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7518 if(editortype==treetrunktype)
7519 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7522 drawmodetogglekeydown=1;
7525 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7526 if(numplayers<maxplayers-1){
7527 player[numplayers].scale=.2*5*player[0].scale;
7528 player[numplayers].creature=rabbittype;
7529 player[numplayers].howactive=editoractive;
7530 player[numplayers].skeleton.id=numplayers;
7531 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);
7533 //texsize=512*512*3/texdetail/texdetail;
7534 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7535 //player[numplayers].skeleton.skinText.resize(texsize);
7537 k=abs(Random()%2)+1;
7539 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7540 player[numplayers].whichskin=0;
7543 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7544 player[numplayers].whichskin=1;
7547 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7548 player[numplayers].whichskin=2;
7551 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7552 player[numplayers].power=1;
7553 player[numplayers].speedmult=1;
7554 player[numplayers].currentanimation=bounceidleanim;
7555 player[numplayers].targetanimation=bounceidleanim;
7556 player[numplayers].currentframe=0;
7557 player[numplayers].targetframe=1;
7558 player[numplayers].target=0;
7559 player[numplayers].bled=0;
7560 player[numplayers].speed=1+(float)(Random()%100)/1000;
7562 player[numplayers].targetrotation=player[0].targetrotation;
7563 player[numplayers].rotation=player[0].rotation;
7565 player[numplayers].velocity=0;
7566 player[numplayers].coords=player[0].coords;
7567 player[numplayers].oldcoords=player[numplayers].coords;
7568 player[numplayers].realoldcoords=player[numplayers].coords;
7570 player[numplayers].id=numplayers;
7571 player[numplayers].skeleton.id=numplayers;
7572 player[numplayers].updatedelay=0;
7573 player[numplayers].normalsupdatedelay=0;
7575 player[numplayers].aitype=passivetype;
7576 player[numplayers].aitarget=0;
7578 if(player[0].creature==wolftype){
7579 headprop=player[0].proportionhead.x/1.1;
7580 bodyprop=player[0].proportionbody.x/1.1;
7581 armprop=player[0].proportionarms.x/1.1;
7582 legprop=player[0].proportionlegs.x/1.1;
7585 if(player[0].creature==rabbittype){
7586 headprop=player[0].proportionhead.x/1.2;
7587 bodyprop=player[0].proportionbody.x/1.05;
7588 armprop=player[0].proportionarms.x/1.00;
7589 legprop=player[0].proportionlegs.x/1.1;
7592 if(player[numplayers].creature==wolftype){
7593 player[numplayers].proportionhead=1.1*headprop;
7594 player[numplayers].proportionbody=1.1*bodyprop;
7595 player[numplayers].proportionarms=1.1*armprop;
7596 player[numplayers].proportionlegs=1.1*legprop;
7599 if(player[numplayers].creature==rabbittype){
7600 player[numplayers].proportionhead=1.2*headprop;
7601 player[numplayers].proportionbody=1.05*bodyprop;
7602 player[numplayers].proportionarms=1.00*armprop;
7603 player[numplayers].proportionlegs=1.1*legprop;
7604 player[numplayers].proportionlegs.y=1.05*legprop;
7607 player[numplayers].headless=0;
7608 player[numplayers].onfire=0;
7611 player[numplayers].proportionhead.z=0;
7612 player[numplayers].proportionbody.z=0;
7613 player[numplayers].proportionarms.z=0;
7614 player[numplayers].proportionlegs.z=0;
7617 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7619 player[numplayers].damagetolerance=200;
7621 player[numplayers].protectionhead=player[0].protectionhead;
7622 player[numplayers].protectionhigh=player[0].protectionhigh;
7623 player[numplayers].protectionlow=player[0].protectionlow;
7624 player[numplayers].armorhead=player[0].armorhead;
7625 player[numplayers].armorhigh=player[0].armorhigh;
7626 player[numplayers].armorlow=player[0].armorlow;
7627 player[numplayers].metalhead=player[0].metalhead;
7628 player[numplayers].metalhigh=player[0].metalhigh;
7629 player[numplayers].metallow=player[0].metallow;
7631 player[numplayers].immobile=player[0].immobile;
7633 player[numplayers].numclothes=player[0].numclothes;
7634 if(player[numplayers].numclothes)
7635 for(i=0;i<player[numplayers].numclothes;i++){
7636 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
7637 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
7638 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
7639 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
7640 tintr=player[numplayers].clothestintr[i];
7641 tintg=player[numplayers].clothestintg[i];
7642 tintb=player[numplayers].clothestintb[i];
7643 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7645 if(player[numplayers].numclothes){
7646 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
7649 player[numplayers].power=player[0].power;
7650 player[numplayers].speedmult=player[0].speedmult;
7652 player[numplayers].damage=0;
7653 player[numplayers].permanentdamage=0;
7654 player[numplayers].superpermanentdamage=0;
7655 player[numplayers].deathbleeding=0;
7656 player[numplayers].bleeding=0;
7657 player[numplayers].numwaypoints=0;
7658 player[numplayers].waypoint=0;
7659 player[numplayers].jumppath=0;
7660 player[numplayers].weaponstuck=-1;
7661 player[numplayers].weaponactive=-1;
7662 player[numplayers].num_weapons=0;
7663 player[numplayers].bloodloss=0;
7664 player[numplayers].dead=0;
7666 player[numplayers].loaded=1;
7670 drawmodetogglekeydown=1;
7673 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
7674 if(player[numplayers-1].numwaypoints<90){
7675 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
7676 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
7677 player[numplayers-1].numwaypoints++;
7679 drawmodetogglekeydown=1;
7682 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7683 if(numpathpoints<30){
7684 bool connected,alreadyconnected;
7687 for(i=0;i<numpathpoints;i++){
7688 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
7690 for(j=0;j<numpathpointconnect[pathpointselected];j++){
7691 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
7693 if(!alreadyconnected){
7694 numpathpointconnect[pathpointselected]++;
7696 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
7702 pathpoint[numpathpoints-1]=player[0].coords;
7703 numpathpointconnect[numpathpoints-1]=0;
7704 if(numpathpoints>1&&pathpointselected!=-1){
7705 numpathpointconnect[pathpointselected]++;
7706 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
7708 pathpointselected=numpathpoints-1;
7711 drawmodetogglekeydown=1;
7714 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
7715 pathpointselected++;
7716 if(pathpointselected>=numpathpoints)pathpointselected=-1;
7717 drawmodetogglekeydown=1;
7719 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7720 pathpointselected--;
7721 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
7722 drawmodetogglekeydown=1;
7724 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7725 if(pathpointselected!=-1){
7727 pathpoint[pathpointselected]=pathpoint[numpathpoints];
7728 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
7729 for(i=0;i<numpathpointconnect[pathpointselected];i++){
7730 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
7732 for(i=0;i<numpathpoints;i++){
7733 for(j=0;j<numpathpointconnect[i];j++){
7734 if(pathpointconnect[i][j]==pathpointselected){
7735 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
7736 numpathpointconnect[i]--;
7738 if(pathpointconnect[i][j]==numpathpoints){
7739 pathpointconnect[i][j]=pathpointselected;
7743 pathpointselected=numpathpoints-1;
7745 drawmodetogglekeydown=1;
7748 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7749 editorenabled=1-editorenabled;
7751 player[0].damagetolerance=100000;
7753 player[0].superpermanentdamage=0;
7754 player[0].bloodloss=0;
7755 player[0].deathbleeding=0;
7758 player[0].damagetolerance=200;
7760 player[0].permanentdamage=0;
7761 player[0].superpermanentdamage=0;
7762 player[0].bloodloss=0;
7763 player[0].deathbleeding=0;
7765 drawmodetogglekeydown=1;
7768 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7770 if(editortype==treeleavestype||editortype==10)editortype--;
7771 if(editortype<0)editortype=firetype;
7772 drawmodetogglekeydown=1;
7775 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7777 if(editortype==treeleavestype||editortype==10)editortype++;
7778 if(editortype>firetype)editortype=0;
7779 drawmodetogglekeydown=1;
7782 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7783 editorrotation-=multiplier*100;
7784 if(editorrotation<-.01)editorrotation=-.01;
7785 drawmodetogglekeydown=1;
7788 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7789 editorrotation+=multiplier*100;
7790 drawmodetogglekeydown=1;
7793 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7794 editorsize+=multiplier;
7795 drawmodetogglekeydown=1;
7798 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7799 editorsize-=multiplier;
7800 if(editorsize<.1)editorsize=.1;
7801 drawmodetogglekeydown=1;
7805 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7806 mapradius-=multiplier*10;
7809 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7810 mapradius+=multiplier*10;
7813 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7814 mapcenter.x+=multiplier*20;
7817 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7818 mapcenter.x-=multiplier*20;
7821 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7822 mapcenter.z+=multiplier*20;
7825 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7826 mapcenter.z-=multiplier*20;
7829 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7830 editorrotation2+=multiplier*100;
7833 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7834 editorrotation2-=multiplier*100;
7835 if(editorrotation2<-.01)editorrotation2=-.01;
7837 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7839 float closestdist=-1;
7841 for(i=0;i<objects.numobjects;i++){
7842 distance=findDistancefast(&objects.position[i],&player[0].coords);
7843 if(closestdist==-1||distance<closestdist){
7844 closestdist=distance;
7848 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
7849 drawmodetogglekeydown=1;
7853 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)){
7854 drawmodetogglekeydown=0;
7857 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
7858 //if(!player[0].skeleton.free)player[0].damage+=500;
7859 player[0].RagDoll(0);
7860 //player[0].spurt=1;
7861 //player[0].DoDamage(1000);
7865 gLoc[0]=player[0].coords.x;
7866 gLoc[1]=player[0].coords.y;
7867 gLoc[2]=player[0].coords.z;
7868 vel[0]=player[0].velocity.x;
7869 vel[1]=player[0].velocity.y;
7870 vel[2]=player[0].velocity.z;
7871 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
7872 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
7873 OPENAL_SetVolume(channels[whooshsound], 128);
7874 OPENAL_SetPaused(channels[whooshsound], false);
7875 //OPENAL_SetPaused(channels[whooshsound], true);
7877 texturesizetogglekeydown=1;
7880 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
7883 float closestdist=-1;
7885 for(i=0;i<objects.numobjects;i++){
7886 if(objects.type[i]==treeleavestype){
7887 objects.scale[i]*=.9;
7890 texturesizetogglekeydown=1;
7893 static XYZ relative;
7894 static int randattack;
7896 static bool playerrealattackkeydown=0;
7898 if(!buttons[0])oldbutton=0;
7899 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
7900 if(oldattackkey)player[0].attackkeydown=0;
7901 if(oldattackkey)playerrealattackkeydown=0;
7902 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
7903 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);
7904 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
7905 for(k=0;k<numplayers;k++){
7906 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
7907 player[k].Reverse();
7911 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
7913 for(k=0;k<numplayers;k++){
7914 if(indialogue!=-1)player[k].attackkeydown=0;
7915 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
7916 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
7917 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)){
7918 player[k].jumppower-=2;
7920 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)){
7921 for(i=0;i<numplayers;i++){
7923 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
7924 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
7925 player[k].targetanimation=dodgebackanim;
7927 player[k].targetframe=0;
7928 rotatetarget=player[i].coords-player[k].coords;
7929 Normalise(&rotatetarget);
7930 player[k].targetrotation=-asin(0-rotatetarget.x);
7931 player[k].targetrotation*=360/6.28;
7932 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
7934 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
7937 if(player[k].targetanimation!=dodgebackanim){
7938 if(k==0)numflipped++;
7939 player[k].targetanimation=backhandspringanim;
7941 player[k].targetframe=0;
7942 player[k].targetrotation=-rotation+180;
7943 if(player[k].leftkeydown)player[k].targetrotation-=45;
7944 if(player[k].rightkeydown)player[k].targetrotation+=45;
7945 player[k].rotation=player[k].targetrotation;
7946 player[k].jumppower-=2;
7949 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())){
7950 player[k].hasvictim=0;
7952 for(i=0;i<numplayers;i++){
7954 if(!player[k].hasvictim)
7955 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
7956 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){
7957 player[k].victim=&player[i];
7958 player[k].hasvictim=1;
7959 if(player[k].aitype==playercontrolled){
7960 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;
7961 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;
7962 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;
7963 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;
7964 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;
7965 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;
7966 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;
7967 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;
7968 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;
7969 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;
7972 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
7973 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
7974 else randattack=abs(Random()%5);
7975 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
7976 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
7977 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
7978 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
7979 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
7981 if(player[k].weaponactive!=-1){
7982 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;
7983 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;
7984 //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;
7985 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;
7986 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;
7987 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;
7988 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;
7989 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;
7993 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
7995 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)){
7996 if(player[k].weaponactive==-1){
7997 player[i].targetanimation=sneakattackedanim;
7998 player[i].currentanimation=sneakattackedanim;
7999 player[k].currentanimation=sneakattackanim;
8000 player[k].targetanimation=sneakattackanim;
8001 player[k].oldcoords=player[k].coords;
8002 player[k].coords=player[i].coords;
8004 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8005 player[i].targetanimation=knifesneakattackedanim;
8006 player[i].currentanimation=knifesneakattackedanim;
8007 player[k].currentanimation=knifesneakattackanim;
8008 player[k].targetanimation=knifesneakattackanim;
8009 player[i].oldcoords=player[i].coords;
8010 player[i].coords=player[k].coords;
8012 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8013 player[i].targetanimation=swordsneakattackedanim;
8014 player[i].currentanimation=swordsneakattackedanim;
8015 player[k].currentanimation=swordsneakattackanim;
8016 player[k].targetanimation=swordsneakattackanim;
8017 player[i].oldcoords=player[i].coords;
8018 player[i].coords=player[k].coords;
8020 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8021 player[k].victim=&player[i];
8022 player[k].hasvictim=1;
8023 player[i].targettilt2=0;
8024 player[i].targetframe=1;
8025 player[i].currentframe=0;
8027 player[i].velocity=0;
8028 player[k].targettilt2=player[i].targettilt2;
8029 player[k].currentframe=player[i].currentframe;
8030 player[k].targetframe=player[i].targetframe;
8031 player[k].target=player[i].target;
8032 player[k].velocity=0;
8033 player[k].targetrotation=player[i].rotation;
8034 player[k].rotation=player[i].rotation;
8035 player[i].targetrotation=player[i].rotation;
8038 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8040 player[k].targetframe=0;
8042 //player[k].velocity=0;
8044 rotatetarget=player[i].coords-player[k].coords;
8045 Normalise(&rotatetarget);
8046 player[k].targetrotation=-asin(0-rotatetarget.x);
8047 player[k].targetrotation*=360/6.28;
8048 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8050 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8052 player[k].lastattack3=player[k].lastattack2;
8053 player[k].lastattack2=player[k].lastattack;
8054 player[k].lastattack=player[k].targetanimation;
8055 //player[k].targettilt2=0;
8059 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8060 rotatetarget=player[i].coords-player[k].coords;
8061 Normalise(&rotatetarget);
8062 player[k].targetrotation=-asin(0-rotatetarget.x);
8063 player[k].targetrotation*=360/6.28;
8064 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8065 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8067 player[k].victim=&player[i];
8068 player[k].hasvictim=1;
8069 player[i].targetanimation=knifefollowedanim;
8070 player[i].currentanimation=knifefollowedanim;
8071 player[i].targettilt2=0;
8072 player[i].targettilt2=player[k].targettilt2;
8073 player[i].targetframe=1;
8074 player[i].currentframe=0;
8076 player[i].velocity=0;
8077 player[k].currentanimation=knifefollowanim;
8078 player[k].targetanimation=knifefollowanim;
8079 player[k].targettilt2=player[i].targettilt2;
8080 player[k].currentframe=player[i].currentframe;
8081 player[k].targetframe=player[i].targetframe;
8082 player[k].target=player[i].target;
8083 player[k].velocity=0;
8084 player[k].oldcoords=player[k].coords;
8085 player[i].coords=player[k].coords;
8086 player[i].targetrotation=player[k].targetrotation;
8087 player[i].rotation=player[k].targetrotation;
8088 player[k].rotation=player[k].targetrotation;
8089 player[i].rotation=player[k].targetrotation;
8094 if(player[k].weaponactive!=-1){
8095 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8098 for(i=0;i<numplayers;i++){
8100 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8101 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8102 if(player[i].skeleton.free)
8103 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)))){
8104 player[k].victim=&player[i];
8105 player[k].hasvictim=1;
8106 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8107 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;
8108 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;
8109 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;
8111 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){
8112 player[k].targetanimation=killanim;
8113 for(j=0;j<terrain.numdecals;j++){
8114 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8115 terrain.DeleteDecal(j);
8118 for(l=0;l<objects.numobjects;l++){
8119 if(objects.model[l].type==decalstype)
8120 for(j=0;j<objects.model[l].numdecals;j++){
8121 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8122 objects.model[l].DeleteDecal(j);
8127 if(!player[i].dead||musictype!=2)
8128 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)){
8129 player[k].targetanimation=dropkickanim;
8130 for(j=0;j<terrain.numdecals;j++){
8131 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8132 terrain.DeleteDecal(j);
8135 for(l=0;l<objects.numobjects;l++){
8136 if(objects.model[l].type==decalstype)
8137 for(j=0;j<objects.model[l].numdecals;j++){
8138 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8139 objects.model[l].DeleteDecal(j);
8145 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)){
8147 player[k].targetframe=0;
8149 //player[k].velocity=0;
8151 rotatetarget=player[i].coords-player[k].coords;
8152 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8153 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;
8155 Normalise(&rotatetarget);
8156 player[k].targetrotation=-asin(0-rotatetarget.x);
8157 player[k].targetrotation*=360/6.28;
8158 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8160 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8161 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8164 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8165 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8167 player[k].lastattack3=player[k].lastattack2;
8168 player[k].lastattack2=player[k].lastattack;
8169 player[k].lastattack=player[k].targetanimation;
8171 if(player[k].targetanimation==swordgroundstabanim){
8172 player[k].targetrotation+=30;
8174 //player[k].targettilt2=0;
8180 if(!player[k].hasvictim){
8181 for(i=0;i<numplayers;i++){
8182 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8183 player[k].victim=&player[i];
8184 player[k].hasvictim=1;
8186 if(player[k].hasvictim&&!player[i].skeleton.free)
8187 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8188 player[k].victim=&player[i];
8192 if(player[k].aitype==playercontrolled)
8193 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)){
8195 player[k].targetanimation=rabbitkickanim;
8196 player[k].targetframe=0;
8199 if(animation[player[k].targetanimation].attack&&k==0){
8202 if(player[k].weaponactive!=-1){
8203 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8206 if(player[k].weaponactive!=-1){
8207 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8210 if(player[k].weaponactive!=-1){
8211 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8213 if(armedstaff)numstaffattack++;
8214 else if(armedsword)numswordattack++;
8215 else if(armedknife)numknifeattack++;
8216 else numunarmedattack++;
8223 static float collisionradius;
8225 for(k=0;k<numplayers;k++){
8226 for(i=k;i<numplayers;i++){
8229 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))
8230 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))
8231 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8232 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8233 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)
8234 if(player[i].coords.y>player[k].coords.y-3)
8235 if(player[i].coords.y<player[k].coords.y+3)
8236 if(player[i].coords.x>player[k].coords.x-3)
8237 if(player[i].coords.x<player[k].coords.x+3)
8238 if(player[i].coords.z>player[k].coords.z-3)
8239 if(player[i].coords.z<player[k].coords.z+3){
8240 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)){
8241 if(player[i].onfire||player[k].onfire){
8242 if(!player[i].onfire)player[i].CatchFire();
8243 if(!player[k].onfire)player[k].CatchFire();
8247 tempcoords1=player[i].coords;
8248 tempcoords2=player[k].coords;
8249 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8250 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8251 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8252 if(player[0].hasvictim)
8253 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8254 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8256 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)){
8257 player[k].coords.y=player[i].coords.y;
8258 player[i].velocity=player[k].velocity;
8259 player[i].skeleton.free=0;
8260 player[i].rotation=0;
8261 player[i].RagDoll(0);
8262 player[i].DoDamage(20);
8263 if(k==0)camerashake+=.3;
8264 player[i].skeleton.longdead=0;
8265 player[k].lastcollide=1;
8268 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)){
8269 player[i].coords.y=player[k].coords.y;
8270 player[k].velocity=player[i].velocity;
8271 player[k].skeleton.free=0;
8272 player[k].rotation=0;
8273 player[k].RagDoll(0);
8274 player[k].DoDamage(20);
8275 if(i==0)camerashake+=.3;
8276 player[k].skeleton.longdead=0;
8277 player[i].lastcollide=1;
8280 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)){
8281 rotatetarget=player[k].velocity-player[i].velocity;
8282 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))
8283 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))){
8285 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)){
8286 static float gLoc[3];
8287 static float vel[3];
8288 gLoc[0]=player[i].coords.x;
8289 gLoc[1]=player[i].coords.y;
8290 gLoc[2]=player[i].coords.z;
8291 vel[0]=player[i].velocity.x;
8292 vel[1]=player[i].velocity.y;
8293 vel[2]=player[i].velocity.z;
8294 if(tutoriallevel!=1){
8295 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8296 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8297 OPENAL_SetVolume(channels[heavyimpactsound], 256);
8298 OPENAL_SetPaused(channels[heavyimpactsound], false);
8300 //player[i].velocity=player[k].velocity;
8301 //player[k].velocity=player[i].velocity;
8303 player[i].RagDoll(0);
8304 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8309 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8310 player[k].RagDoll(0);
8311 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8316 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8318 //if(player[i].skeleton.oldfree){
8319 for(j=0;j<player[i].skeleton.num_joints;j++){
8320 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8323 //if(player[k].skeleton.oldfree){
8324 for(j=0;j<player[k].skeleton.num_joints;j++){
8325 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8331 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)){
8333 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8334 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)){
8335 rotatetarget=player[k].coords-player[i].coords;
8336 Normalise(&rotatetarget);
8337 player[k].coords=(player[k].coords+player[i].coords)/2;
8338 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);
8339 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8340 if(player[k].howactive==typeactive||hostile)
8341 if(player[k].isIdle()){
8342 if(player[k].howactive<typesleeping){
8343 player[k].targetanimation=player[k].getStop();
8344 player[k].targetframe=0;
8347 else if(player[k].howactive==typesleeping)
8349 player[k].targetanimation=getupfromfrontanim;
8350 player[k].targetframe=0;
8353 if(!editorenabled)player[k].howactive=typeactive;
8355 if(player[i].howactive==typeactive||hostile)
8356 if(player[i].isIdle()){
8357 if(player[i].howactive<typesleeping){
8358 player[i].targetanimation=player[i].getStop();
8359 player[i].targetframe=0;
8364 player[i].targetanimation=getupfromfrontanim;
8365 player[i].targetframe=0;
8368 if(!editorenabled)player[i].howactive=typeactive;
8372 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){
8373 player[i].velocity=player[k].velocity;
8374 player[k].velocity=player[k].velocity*-.5;
8375 //player[i].velocity.y-=10;
8376 player[k].velocity.y=player[i].velocity.y;
8377 player[i].DoDamage(20);
8378 player[i].RagDoll(0);
8379 player[k].lastcollide=1;
8386 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){
8387 player[k].velocity=player[i].velocity;
8388 player[i].velocity=player[i].velocity*-.3;
8389 //player[k].velocity.y-=10;
8390 player[i].velocity.y=player[k].velocity.y;
8391 player[k].DoDamage(20);
8392 player[k].RagDoll(0);
8393 player[i].lastcollide=1;
8404 player[i].CheckKick();
8405 player[k].CheckKick();
8411 for(k=0;k<numplayers;k++){
8412 for(i=k;i<numplayers;i++){
8414 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))){
8415 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)){
8416 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)){
8417 player[i].victim=&player[k];
8418 player[i].targetanimation=jumpreversedanim;
8419 player[i].currentanimation=jumpreversedanim;
8420 player[k].currentanimation=jumpreversalanim;
8421 player[k].targetanimation=jumpreversalanim;
8422 player[i].targettilt2=0;
8423 player[i].currentframe=0;
8424 player[i].targetframe=1;
8425 player[k].currentframe=0;
8426 player[k].targetframe=1;
8427 if(player[i].coords.y<player[k].coords.y+1){
8428 player[i].targetanimation=rabbitkickreversedanim;
8429 player[i].currentanimation=rabbitkickreversedanim;
8430 player[k].currentanimation=rabbitkickreversalanim;
8431 player[k].targetanimation=rabbitkickreversalanim;
8432 player[k].currentframe=1;
8433 player[k].targetframe=2;
8434 player[i].currentframe=1;
8435 player[i].targetframe=2;
8437 player[k].targettilt2=0;
8439 player[i].velocity=0;
8440 player[k].velocity=0;
8441 player[k].oldcoords=player[k].coords;
8442 player[i].coords=player[k].coords;
8443 player[k].targetrotation=player[i].targetrotation;
8444 player[k].rotation=player[i].targetrotation;
8445 player[k].victim=&player[i];
8446 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8448 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)){
8449 player[k].victim=&player[i];
8450 player[k].targetanimation=jumpreversedanim;
8451 player[k].currentanimation=jumpreversedanim;
8452 player[i].currentanimation=jumpreversalanim;
8453 player[i].targetanimation=jumpreversalanim;
8454 player[k].targettilt2=0;
8455 player[i].targettilt2=0;
8456 player[k].currentframe=0;
8457 player[k].targetframe=1;
8458 player[i].currentframe=0;
8459 player[i].targetframe=1;
8460 if(player[k].coords.y<player[i].coords.y+1){
8461 player[k].targetanimation=rabbitkickreversedanim;
8462 player[k].currentanimation=rabbitkickreversedanim;
8463 player[i].currentanimation=rabbitkickreversalanim;
8464 player[i].targetanimation=rabbitkickreversalanim;
8465 player[k].currentframe=1;
8466 player[k].targetframe=2;
8467 player[i].currentframe=1;
8468 player[i].targetframe=2;
8471 player[k].velocity=0;
8472 player[i].velocity=0;
8473 player[i].oldcoords=player[i].coords;
8474 player[k].coords=player[i].coords;
8475 player[i].targetrotation=player[k].targetrotation;
8476 player[i].rotation=player[k].targetrotation;
8477 player[i].victim=&player[k];
8478 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8485 for(k=0;k<numplayers;k++)
8486 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8495 static float checkdelay;
8496 checkdelay-=multiplier;
8498 static bool checkedcoll[maxplayers][maxplayers];
8499 static bool above[maxplayers];
8501 for(i=0;i<maxplayers;i++){
8502 for(j=0;j<maxplayers;j++){
8503 checkedcoll[i][j]=0;
8507 if(numplayers>1&&checkdelay<=0){
8509 for(k=0;k<numplayers;k++){
8510 if(player[k].skeleton.free!=2)above[k]=-1;
8512 for(i=k;i<numplayers;i++){
8515 if(!checkedcoll[i][k]){
8516 checkedcoll[i][k]=1;
8517 checkedcoll[k][i]=1;
8518 if(player[i].skeleton.free&&player[k].skeleton.free)
8519 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8520 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8521 if(player[i].coords.y>player[k].coords.y-3)
8522 if(player[i].coords.y<player[k].coords.y+3)
8523 if(player[i].coords.x>player[k].coords.x-3)
8524 if(player[i].coords.x<player[k].coords.x+3)
8525 if(player[i].coords.z>player[k].coords.z-3)
8526 if(player[i].coords.z<player[k].coords.z+3)
8527 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)){
8529 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8541 above[moving]=stuck;
8542 for(l=0;l<player[moving].skeleton.num_joints;l++){
8543 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8544 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8546 player[moving].skeleton.joints[l].position.y+=.003;
8547 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8561 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8562 texturesizetogglekeydown=0;
8565 for(k=0;k<numplayers;k++){
8566 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8567 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8568 player[k].DoDamage(1000);
8573 static bool respawnkeydown;
8574 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8575 targetlevel=whichlevel;
8579 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8580 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8585 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8587 if(targetlevel>numchallengelevels-1)targetlevel=0;
8590 slomotogglekeydown=1;
8594 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8596 OPENAL_SetPaused(channels[whooshsound], true);
8598 for(k=0;k<numplayers;k++){
8601 player[k].permanentdamage=0;
8602 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8603 player[k].aitype=passivetype;
8605 player[0].aitype=playercontrolled;
8609 static bool movekey;
8610 static bool connected;
8611 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8612 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8613 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8614 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8615 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8616 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8618 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
8620 for(int i=0;i<numplayers;i++){
8621 if(!player[i].skeleton.free){
8622 oldtargetrotation=player[i].targetrotation;
8623 if(i==0&&indialogue==-1){
8624 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){
8625 if(!cameramode)player[0].targetrotation=-rotation+180;
8626 if(cameramode)player[0].targetrotation=0;
8632 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8633 if(cameramode){facing=flatfacing;}
8635 facing=DoRotation(facing,-rotation2,0,0);
8636 facing=DoRotation(facing,0,0-rotation,0);
8639 player[0].lookrotation=-rotation;
8641 player[i].targetheadrotation=rotation;
8642 player[i].targetheadrotation2=rotation2;
8644 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
8645 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){
8646 player[i].targetrotation=-player[i].lookrotation+180;
8652 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8654 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
8655 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
8657 player[i].targetheadrotation=player[i].lookrotation;
8658 player[i].targetheadrotation2=player[i].lookrotation2;
8661 rotatetarget=participantfacing[whichdialogue][indialogue][i];
8662 Normalise(&rotatetarget);
8663 player[i].targetheadrotation=-asin(0-rotatetarget.x);
8664 player[i].targetheadrotation*=360/6.28;
8665 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
8667 player[i].targetheadrotation*=-1;
8668 player[i].targetheadrotation+=180;
8669 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
8677 player[i].avoidsomething=0;
8679 for(j=0;j<objects.numobjects;j++){
8680 if(objects.onfire[j]){
8681 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
8683 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
8684 player[i].collided=0;
8685 player[i].avoidcollided=1;
8686 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8687 player[i].avoidwhere=objects.position[j];
8693 //Add avoidwhere to players
8695 for(j=0;j<numplayers;j++){
8696 if(player[j].onfire){
8697 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
8699 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
8700 player[i].collided=0;
8701 player[i].avoidcollided=1;
8702 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8703 player[i].avoidwhere=objects.position[j];
8709 if(player[i].collided>.8)player[i].avoidcollided=0;
8710 if(player[i].aitype!=playercontrolled&&indialogue==-1){
8711 player[i].jumpclimb=0;
8713 if(editorenabled)player[i].stunned=1;
8716 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
8717 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;
8719 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
8720 player[i].forwardkeydown=0;
8721 player[i].leftkeydown=0;
8722 player[i].backkeydown=0;
8723 player[i].rightkeydown=0;
8724 player[i].crouchkeydown=0;
8725 player[i].attackkeydown=0;
8726 player[i].jumpkeydown=0;
8727 player[i].throwkeydown=0;
8730 if(player[i].aitype==pathfindtype){
8731 if(player[i].finalpathfindpoint==-1){
8732 float closestdistance;
8738 for(j=0;j<numpathpoints;j++){
8739 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
8740 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
8742 player[i].finaltarget=pathpoint[j];
8745 player[i].finalpathfindpoint=closest;
8746 for(j=0;j<numpathpoints;j++){
8747 if(numpathpointconnect[j])
8748 for(k=0;k<numpathpointconnect[j];k++){
8749 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8750 if(tempdist*tempdist<closestdistance){
8751 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8752 closestdistance=tempdist*tempdist;
8754 player[i].finaltarget=colpoint;
8759 player[i].finalpathfindpoint=closest;
8762 if(player[i].targetpathfindpoint==-1){
8763 float closestdistance;
8769 if(player[i].lastpathfindpoint==-1){
8770 for(j=0;j<numpathpoints;j++){
8771 if(j!=player[i].lastpathfindpoint)
8772 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
8773 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
8777 player[i].targetpathfindpoint=closest;
8778 for(j=0;j<numpathpoints;j++){
8779 if(j!=player[i].lastpathfindpoint)
8780 if(numpathpointconnect[j])
8781 for(k=0;k<numpathpointconnect[j];k++){
8782 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8783 if(tempdist*tempdist<closestdistance){
8784 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8785 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
8786 closestdistance=tempdist*tempdist;
8793 player[i].targetpathfindpoint=closest;
8797 for(j=0;j<numpathpoints;j++){
8798 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
8801 if(numpathpointconnect[j])
8802 for(k=0;k<numpathpointconnect[j];k++){
8803 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
8806 if(numpathpointconnect[player[i].lastpathfindpoint])
8807 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
8808 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
8811 tempdist=findPathDist(j,player[i].finalpathfindpoint);
8812 if(closest==-1||tempdist<closestdistance){
8813 closestdistance=tempdist;
8819 player[i].targetpathfindpoint=closest;
8822 player[i].losupdatedelay-=multiplier;
8824 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
8825 Normalise(&rotatetarget);
8826 player[i].targetrotation=-asin(0-rotatetarget.x);
8827 player[i].targetrotation*=360/6.28;
8828 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8829 player[i].lookrotation=player[i].targetrotation;
8830 //player[i].aiupdatedelay=.05;
8832 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
8833 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8834 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8835 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8836 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
8837 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8838 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8839 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8840 player[i].targetpathfindpoint=-1;
8842 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){
8843 player[i].aitype=passivetype;
8846 player[i].forwardkeydown=1;
8847 player[i].leftkeydown=0;
8848 player[i].backkeydown=0;
8849 player[i].rightkeydown=0;
8850 player[i].crouchkeydown=0;
8851 player[i].attackkeydown=0;
8852 player[i].throwkeydown=0;
8854 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
8856 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
8857 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
8859 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
8860 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))
8861 player[i].aitype=attacktypecutoff;
8862 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
8863 player[i].aitype=attacktypecutoff;
8865 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
8866 player[i].losupdatedelay=.2;
8867 for(j=0;j<numplayers;j++){
8868 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
8869 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
8870 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
8871 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
8872 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
8873 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)){
8874 player[i].aitype=searchtype;
8875 player[i].lastchecktime=12;
8876 player[i].lastseen=player[j].coords;
8877 player[i].lastseentime=12;
8883 if(player[i].aitype==attacktypecutoff&&musictype!=2){
8884 if(player[i].creature!=wolftype){
8885 player[i].stunned=.6;
8886 player[i].surprised=.6;
8891 if(player[i].aitype!=passivetype&&leveltime>.5){
8892 player[i].howactive=typeactive;
8895 if(player[i].aitype==passivetype){
8896 player[i].aiupdatedelay-=multiplier;
8897 player[i].losupdatedelay-=multiplier;
8898 player[i].lastseentime+=multiplier;
8899 player[i].pausetime-=multiplier;
8900 if(player[i].lastseentime>1)player[i].lastseentime=1;
8902 if(player[i].aiupdatedelay<0){
8903 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
8904 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
8905 Normalise(&rotatetarget);
8906 player[i].targetrotation=-asin(0-rotatetarget.x);
8907 player[i].targetrotation*=360/6.28;
8908 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8909 player[i].lookrotation=player[i].targetrotation;
8910 player[i].aiupdatedelay=.05;
8912 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
8913 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
8914 player[i].waypoint++;
8915 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
8920 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
8921 else player[i].forwardkeydown=0;
8922 player[i].leftkeydown=0;
8923 player[i].backkeydown=0;
8924 player[i].rightkeydown=0;
8925 player[i].crouchkeydown=0;
8926 player[i].attackkeydown=0;
8927 player[i].throwkeydown=0;
8929 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
8930 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
8932 XYZ leftpos,rightpos;
8933 float leftdist,rightdist;
8934 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
8935 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
8936 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
8937 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
8938 if(leftdist<rightdist)player[i].targetrotation+=90;
8939 else player[i].targetrotation-=90;
8943 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
8944 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
8948 if(player[i].howactive<typesleeping)
8949 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
8950 for(j=0;j<numenvsounds;j++){
8951 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
8952 player[i].aitype=attacktypecutoff;
8956 if(player[i].howactive==typesleeping)
8957 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
8958 for(j=0;j<numenvsounds;j++){
8959 if(envsoundvol[j]>14)
8960 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
8961 player[i].aitype=attacktypecutoff;
8965 if(player[i].aitype!=passivetype){
8966 if(player[i].howactive==typesleeping){
8967 player[i].targetanimation=getupfromfrontanim;
8968 player[i].targetframe=0;
8972 player[i].howactive=typeactive;
8976 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
8977 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
8978 player[i].aitype=attacktypecutoff;
8979 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
8980 player[i].aitype=attacktypecutoff;
8982 if(player[i].creature==wolftype){
8984 float smelldistance;
8986 for(j=0;j<numplayers;j++){
8987 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
8988 if(j==0&&player[j].num_weapons>0){
8989 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
8990 if(player[j].num_weapons==2)
8991 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
8996 windsmell=windvector;
8997 Normalise(&windsmell);
8998 windsmell=windsmell*2+player[j].coords;
8999 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9000 player[i].aitype=attacktypecutoff;
9005 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9006 player[i].losupdatedelay=.2;
9007 for(j=0;j<numplayers;j++){
9008 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9009 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9010 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9011 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9012 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)){
9013 player[i].lastseentime-=.2;
9014 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9015 else player[i].lastseentime-=.6;
9017 if(player[i].lastseentime<=0){
9018 player[i].aitype=searchtype;
9019 player[i].lastchecktime=12;
9020 player[i].lastseen=player[j].coords;
9021 player[i].lastseentime=12;
9027 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9028 if(player[i].creature!=wolftype){
9029 player[i].stunned=.6;
9030 player[i].surprised=.6;
9032 if(player[i].creature==wolftype){
9033 player[i].stunned=.47;
9034 player[i].surprised=.47;
9040 if(player[i].aitype==searchtype){
9041 player[i].aiupdatedelay-=multiplier;
9042 player[i].losupdatedelay-=multiplier;
9043 if(!player[i].pause)player[i].lastseentime-=multiplier;
9044 player[i].lastchecktime-=multiplier;
9046 if(player[i].isRun()&&!player[i].onground){
9047 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9048 test2=player[i].coords+player[i].facing;
9050 test=player[i].coords+player[i].facing;
9052 j=checkcollide(test2,test,player[i].laststanding);
9053 if(j==-1)j=checkcollide(test2,test);
9055 player[i].velocity=0;
9056 player[i].targetanimation=player[i].getStop();
9057 player[i].targetframe=0;
9059 player[i].targetrotation+=180;
9060 player[i].stunned=.5;
9061 //player[i].aitype=passivetype;
9062 player[i].aitype=pathfindtype;
9063 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9064 player[i].finalpathfindpoint=-1;
9065 player[i].targetpathfindpoint=-1;
9066 player[i].lastpathfindpoint=-1;
9067 player[i].lastpathfindpoint2=-1;
9068 player[i].lastpathfindpoint3=-1;
9069 player[i].lastpathfindpoint4=-1;
9071 else player[i].laststanding=j;
9074 if(player[i].aiupdatedelay<0){
9075 rotatetarget=player[i].lastseen-player[i].coords;
9076 Normalise(&rotatetarget);
9077 player[i].targetrotation=-asin(0-rotatetarget.x);
9078 player[i].targetrotation*=360/6.28;
9079 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9080 player[i].lookrotation=player[i].targetrotation;
9081 player[i].aiupdatedelay=.05;
9082 player[i].forwardkeydown=1;
9084 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9085 player[i].forwardkeydown=0;
9086 player[i].aiupdatedelay=1;
9087 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9088 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9089 player[i].lastchecktime=3;
9092 player[i].leftkeydown=0;
9093 player[i].backkeydown=0;
9094 player[i].rightkeydown=0;
9095 player[i].crouchkeydown=0;
9096 player[i].attackkeydown=0;
9097 player[i].throwkeydown=0;
9099 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9100 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9102 XYZ leftpos,rightpos;
9103 float leftdist,rightdist;
9104 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9105 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9106 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9107 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9108 if(leftdist<rightdist)player[i].targetrotation+=90;
9109 else player[i].targetrotation-=90;
9113 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9114 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9116 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9117 for(j=0;j<numenvsounds;j++){
9118 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9119 player[i].aitype=attacktypecutoff;
9123 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9124 player[i].losupdatedelay=.2;
9125 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9126 {player[i].aitype=attacktypecutoff;
9127 player[i].lastseentime=1;}
9128 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9129 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9130 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9131 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)){
9132 player[i].aitype=attacktypecutoff;
9133 player[i].lastseentime=1;
9136 if(player[i].lastseentime<0){
9137 //player[i].aitype=passivetype;
9139 player[i].aitype=pathfindtype;
9140 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9141 player[i].finalpathfindpoint=-1;
9142 player[i].targetpathfindpoint=-1;
9143 player[i].lastpathfindpoint=-1;
9144 player[i].lastpathfindpoint2=-1;
9145 player[i].lastpathfindpoint3=-1;
9146 player[i].lastpathfindpoint4=-1;
9150 if(player[i].aitype!=gethelptype){
9151 player[i].runninghowlong=0;
9154 if(player[i].aitype==gethelptype){
9155 player[i].runninghowlong+=multiplier;
9156 player[i].aiupdatedelay-=multiplier;
9158 if(player[i].aiupdatedelay<0||player[i].ally==0){
9159 player[i].aiupdatedelay=.2;
9167 if(!player[i].ally){
9168 for(j=0;j<numplayers;j++){
9169 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9170 distance=findDistancefast(&player[i].coords,&player[j].coords);
9171 if(closestdist==-1||distance<closestdist){
9172 closestdist=distance;
9178 if(closest!=-1)player[i].ally=closest;
9179 else player[i].ally=0;
9180 player[i].lastseen=player[0].coords;
9181 player[i].lastseentime=12;
9185 player[i].lastchecktime=12;
9186 //player[i].lastseentime-=.5;
9188 facing=player[i].coords;
9189 flatfacing=player[player[i].ally].coords;
9190 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9191 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9192 if(-1!=checkcollide(facing,flatfacing))
9193 player[i].lastseentime-=.1;
9195 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9196 player[i].aitype=searchtype;
9197 player[i].lastseentime=12;
9200 if(player[i].ally>0){
9201 rotatetarget=player[player[i].ally].coords-player[i].coords;
9202 Normalise(&rotatetarget);
9203 player[i].targetrotation=-asin(0-rotatetarget.x);
9204 player[i].targetrotation*=360/6.28;
9205 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9206 player[i].lookrotation=player[i].targetrotation;
9207 player[i].aiupdatedelay=.05;
9208 player[i].forwardkeydown=1;
9210 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9211 player[i].aitype=searchtype;
9212 player[i].lastseentime=12;
9213 player[player[i].ally].aitype=searchtype;
9214 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9215 player[player[i].ally].lastseen=player[i].lastseen;
9216 player[player[i].ally].lastseentime=player[i].lastseentime;
9217 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9221 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9222 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9224 XYZ leftpos,rightpos;
9225 float leftdist,rightdist;
9226 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9227 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9228 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9229 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9230 if(leftdist<rightdist)player[i].targetrotation+=90;
9231 else player[i].targetrotation-=90;
9236 player[i].leftkeydown=0;
9237 player[i].backkeydown=0;
9238 player[i].rightkeydown=0;
9239 player[i].crouchkeydown=0;
9240 player[i].attackkeydown=0;
9242 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9243 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9246 if(player[i].aitype==getweapontype){
9247 player[i].aiupdatedelay-=multiplier;
9248 player[i].lastchecktime-=multiplier;
9250 if(player[i].aiupdatedelay<0){
9251 player[i].aiupdatedelay=.2;
9259 if(player[i].ally<0){
9260 for(j=0;j<weapons.numweapons;j++){
9261 if(weapons.owner[j]==-1){
9262 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9263 if(closestdist==-1||distance<closestdist){
9264 closestdist=distance;
9270 if(closest!=-1)player[i].ally=closest;
9271 else player[i].ally=-1;
9274 player[i].lastseentime=12;
9276 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9277 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9278 player[i].aitype=attacktypecutoff;
9279 player[i].lastseentime=1;
9282 if(player[i].ally>=0){
9283 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9284 player[i].aitype=attacktypecutoff;
9285 player[i].lastseentime=1;
9287 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9288 Normalise(&rotatetarget);
9289 player[i].targetrotation=-asin(0-rotatetarget.x);
9290 player[i].targetrotation*=360/6.28;
9291 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9292 player[i].lookrotation=player[i].targetrotation;
9293 player[i].aiupdatedelay=.05;
9294 player[i].forwardkeydown=1;
9297 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9298 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9300 XYZ leftpos,rightpos;
9301 float leftdist,rightdist;
9302 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9303 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9304 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9305 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9306 if(leftdist<rightdist)player[i].targetrotation+=90;
9307 else player[i].targetrotation-=90;
9310 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9311 if(abs(Random()%6)){
9312 player[i].crouchkeydown=1;
9313 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9314 if(player[i].isRun()){
9315 player[i].targetframe=0;
9317 player[i].targetanimation=sneakanim;
9320 else player[i].forwardkeydown=0;
9322 else player[i].crouchkeydown=0;
9324 else player[i].crouchkeydown=0;*/
9327 player[i].leftkeydown=0;
9328 player[i].backkeydown=0;
9329 player[i].rightkeydown=0;
9330 player[i].attackkeydown=0;
9331 player[i].throwkeydown=1;
9332 player[i].crouchkeydown=0;
9333 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9334 player[i].drawkeydown=0;
9336 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9337 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9340 if(player[i].aitype==attacktypecutoff){
9341 player[i].aiupdatedelay-=multiplier;
9342 if(player[i].damage<player[i].damagetolerance*2/3)
9343 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)){
9344 player[i].attackkeydown=0;
9345 if(player[i].isIdle())player[i].crouchkeydown=1;
9346 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9347 if(weapons.type[player[0].weaponids[0]]==knife){
9348 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9349 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9350 else player[i].targetanimation=rollanim;
9352 player[i].targetframe=0;
9353 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9354 player[i].wentforweapon=0;
9356 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9357 player[i].targetanimation=flipanim;
9359 player[i].targetframe=0;
9363 player[i].forwardkeydown=0;
9364 player[i].aiupdatedelay=.02;
9366 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9367 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9368 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9370 if(player[i].wentforweapon<3)
9371 for(j=0;j<weapons.numweapons;j++){
9372 if(player[i].creature!=wolftype)
9373 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){
9374 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9375 player[i].wentforweapon++;
9376 player[i].lastchecktime=6;
9377 player[i].aitype=getweapontype;
9382 if(player[i].damage<player[i].damagetolerance/2)
9383 if(animation[player[i].targetanimation].height!=highheight)
9384 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)))){
9385 player[i].crouchkeydown=1;
9387 if(player[i].isRun()&&!player[i].onground){
9388 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9389 test2=player[i].coords+player[i].facing;
9391 test=player[i].coords+player[i].facing;
9393 j=checkcollide(test2,test,player[i].laststanding);
9394 if(j==-1)j=checkcollide(test2,test);
9396 player[i].velocity=0;
9397 player[i].targetanimation=player[i].getStop();
9398 player[i].targetframe=0;
9400 player[i].targetrotation+=180;
9401 player[i].stunned=.5;
9402 //player[i].aitype=passivetype;
9403 player[i].aitype=pathfindtype;
9404 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9405 player[i].finalpathfindpoint=-1;
9406 player[i].targetpathfindpoint=-1;
9407 player[i].lastpathfindpoint=-1;
9408 player[i].lastpathfindpoint2=-1;
9409 player[i].lastpathfindpoint3=-1;
9410 player[i].lastpathfindpoint4=-1;
9412 else player[i].laststanding=j;
9415 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9416 player[i].aitype=pathfindtype;
9417 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9418 player[i].finalpathfindpoint=-1;
9419 player[i].targetpathfindpoint=-1;
9420 player[i].lastpathfindpoint=-1;
9421 player[i].lastpathfindpoint2=-1;
9422 player[i].lastpathfindpoint3=-1;
9423 player[i].lastpathfindpoint4=-1;
9425 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){
9426 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9427 else player[i].drawkeydown=0;
9428 player[i].rabbitkickenabled=Random()%2;
9429 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9430 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9431 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;
9432 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9433 Normalise(&rotatetarget);
9434 player[i].targetrotation=-asin(0-rotatetarget.x);
9435 player[i].targetrotation*=360/6.28;
9436 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9437 player[i].lookrotation=player[i].targetrotation;
9438 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9440 oldkey=player[i].forwardkeydown;
9441 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9442 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;
9443 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9444 else player[i].forwardkeydown=0;
9446 player[i].forwardkeydown=0;
9447 if(Random()%10==0)player[i].forwardkeydown=1;
9448 if(Random()%100==0){
9449 player[i].aitype=pathfindtype;
9450 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9451 player[i].finalpathfindpoint=-1;
9452 player[i].targetpathfindpoint=-1;
9453 player[i].lastpathfindpoint=-1;
9454 player[i].lastpathfindpoint2=-1;
9455 player[i].lastpathfindpoint3=-1;
9456 player[i].lastpathfindpoint4=-1;
9459 player[i].leftkeydown=0;
9460 player[i].backkeydown=0;
9461 player[i].rightkeydown=0;
9462 player[i].crouchkeydown=0;
9463 player[i].throwkeydown=0;
9465 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9466 /*for(j=0;j<numplayers;j++){
9467 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9468 player[i].crouchkeydown=1;
9471 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9472 else player[i].attackkeydown=0;
9473 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9474 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9475 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9476 player[i].attackkeydown=0;
9477 if(player[i].isIdle())player[i].crouchkeydown=1;
9478 player[i].forwardkeydown=0;
9479 player[i].aiupdatedelay=.02;
9482 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9484 for(j=0;j<numplayers;j++){
9485 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)){
9486 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))))){
9487 if(target>=0)target=-1;
9492 if(target>=0)player[target].Reverse();
9495 if(player[i].collided<1)player[i].jumpkeydown=0;
9496 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;
9497 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9498 player[0].jumpkeydown=0;
9499 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9500 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9501 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9503 if(tutoriallevel==1){
9504 if(!canattack)player[i].attackkeydown=0;
9508 facing=player[i].coords;
9509 flatfacing=player[0].coords;
9510 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9511 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9512 if(player[i].occluded>=2)
9513 if(-1!=checkcollide(facing,flatfacing)){
9514 if(!player[i].pause)player[i].lastseentime-=.2;
9515 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9516 player[i].aitype=searchtype;
9517 player[i].lastchecktime=12;
9518 player[i].lastseen=player[0].coords;
9519 player[i].lastseentime=12;
9522 else player[i].lastseentime=1;
9525 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9526 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9527 test=player[0].coords;
9529 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9532 // NOTE: Ask about logic of this call : NOTE
9533 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9534 player[i].stunned>0 ||
9535 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9537 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9538 player[i].targetrotation=player[i].rotation;
9539 player[i].forwardkeydown=0;
9540 player[i].leftkeydown=0;
9541 player[i].backkeydown=0;
9542 player[i].rightkeydown=0;
9543 player[i].jumpkeydown=0;
9544 player[i].attackkeydown=0;
9545 player[i].crouchkeydown=0;
9546 player[i].throwkeydown=0;
9553 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9556 if(player[i].aitype==attacktypecutoff){
9557 rotatetarget=player[0].coords-player[i].coords;
9558 Normalise(&rotatetarget);
9559 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9560 player[i].targetheadrotation*=360/6.28;
9561 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9563 player[i].targetheadrotation*=-1;
9564 player[i].targetheadrotation+=180;
9565 //player[i].targetheadrotation2=0;
9566 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9568 else if(player[i].howactive>=typesleeping){
9569 player[i].targetheadrotation=player[i].targetrotation;
9570 player[i].targetheadrotation2=0;
9573 if(player[i].interestdelay<=0){
9574 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9575 player[i].headtarget=player[i].coords;
9576 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9577 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9578 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9579 player[i].headtarget+=player[i].facing*1.5;
9581 rotatetarget=player[i].headtarget-player[i].coords;
9582 Normalise(&rotatetarget);
9583 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9584 player[i].targetheadrotation*=360/6.28;
9585 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9587 player[i].targetheadrotation*=-1;
9588 player[i].targetheadrotation+=180;
9589 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9591 //if(whichlevel==2)player[i].jumpkeydown=0;
9593 if(animation[player[i].targetanimation].attack==reversed){
9594 //player[i].targetrotation=player[i].rotation;
9595 player[i].forwardkeydown=0;
9596 player[i].leftkeydown=0;
9597 player[i].backkeydown=0;
9598 player[i].rightkeydown=0;
9599 player[i].jumpkeydown=0;
9600 player[i].attackkeydown=0;
9601 //player[i].crouchkeydown=0;
9602 player[i].throwkeydown=0;
9606 player[i].forwardkeydown=0;
9607 player[i].leftkeydown=0;
9608 player[i].backkeydown=0;
9609 player[i].rightkeydown=0;
9610 player[i].jumpkeydown=0;
9611 player[i].crouchkeydown=0;
9612 player[i].drawkeydown=0;
9613 player[i].throwkeydown=0;
9616 if(player[i].collided<-.3)player[i].collided=-.3;
9617 if(player[i].collided>1)player[i].collided=1;
9618 player[i].collided-=multiplier*4;
9619 player[i].whichdirectiondelay-=multiplier;
9620 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
9621 player[i].avoidcollided=-.3;
9622 player[i].whichdirection=abs(Random()%2);
9623 player[i].whichdirectiondelay=.4;
9625 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
9626 player[i].avoidcollided-=multiplier/4;
9627 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
9628 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
9629 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;
9631 if(!player[i].throwkeydown){
9632 player[i].throwtogglekeydown=0;
9634 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
9635 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)){
9636 for(j=0;j<weapons.numweapons;j++){
9637 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)
9638 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
9639 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
9640 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
9641 player[i].throwtogglekeydown=1;
9642 player[i].targetanimation=crouchremoveknifeanim;
9644 player[i].targetframe=0;
9645 rotatetarget=weapons.position[j]-player[i].coords;
9646 Normalise(&rotatetarget);
9647 player[i].targetrotation=-asin(0-rotatetarget.x);
9648 player[i].targetrotation*=360/6.28;
9649 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9650 player[i].hasvictim=0;
9652 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9653 player[i].throwtogglekeydown=1;
9654 player[i].hasvictim=0;
9656 //for(i=0;i<weapons.numweapons;i++){
9657 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))
9658 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
9659 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
9662 gLoc[0]=player[i].coords.x;
9663 gLoc[1]=player[i].coords.y;
9664 gLoc[2]=player[i].coords.z;
9665 vel[0]=player[i].velocity.x;
9666 vel[1]=player[i].velocity.y;
9667 vel[2]=player[i].velocity.z;
9668 if(weapons.type[j]!=staff){
9669 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9670 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9671 OPENAL_SetVolume(channels[knifedrawsound], 128);
9672 OPENAL_SetPaused(channels[knifedrawsound], false);
9675 player[i].weaponactive=0;
9676 weapons.owner[j]=player[i].id;
9677 if(player[i].num_weapons>0){
9678 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9680 player[i].num_weapons++;
9681 player[i].weaponids[0]=j;
9687 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){
9688 if(!player[i].isFlip()){
9689 player[i].throwtogglekeydown=1;
9690 player[i].targetanimation=removeknifeanim;
9692 player[i].targetframe=0;
9693 rotatetarget=weapons.position[j]-player[i].coords;
9694 Normalise(&rotatetarget);
9695 player[i].targetrotation=-asin(0-rotatetarget.x);
9696 player[i].targetrotation*=360/6.28;
9697 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9699 if(player[i].isFlip()){
9700 player[i].throwtogglekeydown=1;
9701 player[i].hasvictim=0;
9703 for(k=0;k<weapons.numweapons;k++){
9704 if(player[i].weaponactive==-1)
9705 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))
9706 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
9709 gLoc[0]=player[i].coords.x;
9710 gLoc[1]=player[i].coords.y;
9711 gLoc[2]=player[i].coords.z;
9712 vel[0]=player[i].velocity.x;
9713 vel[1]=player[i].velocity.y;
9714 vel[2]=player[i].velocity.z;
9715 if(weapons.type[k]!=staff){
9716 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9717 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9718 OPENAL_SetVolume(channels[knifedrawsound], 128);
9719 OPENAL_SetPaused(channels[knifedrawsound], false);
9722 player[i].weaponactive=0;
9723 weapons.owner[k]=player[i].id;
9724 if(player[i].num_weapons>0){
9725 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9727 player[i].num_weapons++;
9728 player[i].weaponids[0]=k;
9735 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9737 for(j=0;j<numplayers;j++){
9738 if(player[i].weaponactive==-1)
9740 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)){
9741 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
9742 player[i].throwtogglekeydown=1;
9743 player[i].victim=&player[j];
9744 player[i].hasvictim=1;
9745 player[i].targetanimation=crouchremoveknifeanim;
9747 player[i].targetframe=0;
9748 rotatetarget=player[j].coords-player[i].coords;
9749 Normalise(&rotatetarget);
9750 player[i].targetrotation=-asin(0-rotatetarget.x);
9751 player[i].targetrotation*=360/6.28;
9752 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9754 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9755 player[i].throwtogglekeydown=1;
9756 player[i].victim=&player[j];
9757 player[i].hasvictim=1;
9758 int k = player[j].weaponids[0];
9759 if(player[i].hasvictim){
9762 gLoc[0]=player[i].coords.x;
9763 gLoc[1]=player[i].coords.y;
9764 gLoc[2]=player[i].coords.z;
9765 vel[0]=player[i].velocity.x;
9766 vel[1]=player[i].velocity.y;
9767 vel[2]=player[i].velocity.z;
9770 if(player[i].victim->weaponstuck!=-1){
9771 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9776 if(weapons.type[k]!=staff){
9777 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9778 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9779 OPENAL_SetVolume(channels[knifedrawsound], 128);
9780 OPENAL_SetPaused(channels[knifedrawsound], false);
9784 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
9785 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
9786 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
9787 OPENAL_SetPaused(channels[fleshstabremovesound], false);
9790 player[i].weaponactive=0;
9791 if(weapons.owner[k]!=-1){
9792 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
9793 else player[i].victim->num_weapons=1;
9795 player[i].victim->skeleton.longdead=0;
9796 player[i].victim->skeleton.free=1;
9797 player[i].victim->skeleton.broken=0;
9799 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
9800 player[i].victim->skeleton.joints[l].velchange=0;
9801 player[i].victim->skeleton.joints[l].locked=0;
9807 Normalise(&relative);
9808 XYZ footvel,footpoint;
9810 footpoint=weapons.position[k];
9811 if(player[i].victim->weaponstuck!=-1){
9812 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9813 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
9814 weapons.bloody[k]=2;
9815 weapons.blooddrip[k]=5;
9816 player[i].victim->weaponstuck=-1;
9817 player[i].victim->bloodloss+=2000;
9818 player[i].victim->DoDamage(2000);
9821 if(player[i].victim->num_weapons>0){
9822 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
9823 if(player[i].victim->weaponids[0]==k)
9824 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
9827 player[i].victim->weaponactive=-1;
9829 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
9830 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
9831 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
9832 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
9835 if(player[i].num_weapons>0){
9836 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9838 player[i].num_weapons++;
9839 player[i].weaponids[0]=k;
9846 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9847 if(weapons.type[player[i].weaponids[0]]==knife){
9848 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
9850 for(j=0;j<numplayers;j++){
9852 if(tutoriallevel!=1||tutorialstage==49)
9854 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)){
9855 if(!player[i].isFlip()){
9856 player[i].throwtogglekeydown=1;
9857 player[i].victim=&player[j];
9858 player[i].targetanimation=knifethrowanim;
9860 player[i].targetframe=0;
9861 rotatetarget=player[j].coords-player[i].coords;
9862 Normalise(&rotatetarget);
9863 player[i].targetrotation=-asin(0-rotatetarget.x);
9864 player[i].targetrotation*=360/6.28;
9865 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9867 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
9869 if(player[i].isFlip()){
9870 if(player[i].weaponactive!=-1){
9871 player[i].throwtogglekeydown=1;
9872 player[i].victim=&player[j];
9874 weapons.owner[player[i].weaponids[0]]=-1;
9875 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);
9878 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
9880 weapons.velocity[player[i].weaponids[0]]=aim*50;
9881 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
9882 weapons.missed[player[i].weaponids[0]]=0;
9883 weapons.freetime[player[i].weaponids[0]]=0;
9884 weapons.firstfree[player[i].weaponids[0]]=1;
9885 weapons.physics[player[i].weaponids[0]]=0;
9886 player[i].num_weapons--;
9887 if(player[i].num_weapons){
9888 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
9890 player[i].weaponactive=-1;
9897 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9898 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
9900 player[i].throwtogglekeydown=1;
9901 weapons.owner[player[i].weaponids[0]]=-1;
9902 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
9903 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
9904 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
9905 weapons.missed[player[i].weaponids[0]]=1;
9906 weapons.freetime[player[i].weaponids[0]]=0;
9907 weapons.firstfree[player[i].weaponids[0]]=1;
9908 weapons.physics[player[i].weaponids[0]]=1;
9909 player[i].num_weapons--;
9910 if(player[i].num_weapons){
9911 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
9912 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
9915 player[i].weaponactive=-1;
9916 for(j=0;j<numplayers;j++){
9917 player[j].wentforweapon=0;
9924 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
9925 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)){
9926 //Setenvironment(1-environment);
9929 if(player[i].weaponactive!=-1){
9930 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
9932 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
9933 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
9934 player[i].targetanimation=drawrightanim;
9935 player[i].targetframe=0;
9937 player[i].drawtogglekeydown=1;
9939 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){
9940 player[i].targetanimation=drawleftanim;
9941 player[i].targetframe=0;
9943 player[i].drawtogglekeydown=1;
9945 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
9946 player[i].targetanimation=crouchdrawrightanim;
9947 player[i].targetframe=0;
9949 player[i].drawtogglekeydown=1;
9953 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){
9954 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
9955 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
9956 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
9957 player[i].targetframe=0;
9959 player[i].hasvictim=0;
9960 //player[i].attacktogglekeydown=1;
9964 if(!player[i].drawkeydown){
9965 player[i].drawtogglekeydown=0;
9972 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
9974 else absflatfacing=flatfacing;
9977 player[i].forwardkeydown=0;
9978 player[i].leftkeydown=0;
9979 player[i].backkeydown=0;
9980 player[i].rightkeydown=0;
9981 player[i].jumpkeydown=0;
9982 player[i].crouchkeydown=0;
9983 player[i].drawkeydown=0;
9984 player[i].throwkeydown=0;
9988 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
9989 if(!player[i].forwardkeydown){
9990 player[i].forwardstogglekeydown=0;
9992 if(player[i].crouchkeydown){
9996 player[i].superruntoggle=1;
9998 for(j=0;j<numplayers;j++){
9999 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10000 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10001 player[i].superruntoggle=0;
10008 for(j=0;j<numplayers;j++){
10009 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10010 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))){
10011 if(target>=0)target=-1;
10016 if(target>=0)player[target].Reverse();
10017 player[i].lowreversaldelay=.5;
10019 if(player[i].isIdle()){
10020 player[i].targetanimation=player[i].getCrouch();
10021 player[i].target=0;
10022 player[i].targetframe=0;
10023 player[i].transspeed=10;
10025 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10026 player[i].targetanimation=rollanim;
10027 player[i].target=0;
10028 player[i].targetframe=0;
10029 player[i].transspeed=20;
10032 if(!player[i].crouchkeydown){
10034 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10036 if(player[i].isCrouch()){
10038 for(j=0;j<numplayers;j++){
10039 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10040 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10041 if(target>=0)target=-1;
10046 if(target>=0)player[target].Reverse();
10047 player[i].highreversaldelay=.5;
10049 if(player[i].isCrouch()){
10050 if(!player[i].wasCrouch()){
10051 player[i].currentanimation=player[i].getCrouch();
10052 player[i].currentframe=0;
10054 player[i].target=0;
10055 player[i].targetanimation=player[i].getIdle();
10056 player[i].targetframe=0;
10057 player[i].transspeed=10;
10060 if(player[i].targetanimation==sneakanim){
10061 player[i].targetanimation=player[i].getIdle();
10062 player[i].target=0;
10063 player[i].targetframe=0;
10064 player[i].transspeed=10;
10067 if(player[i].forwardkeydown){
10068 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)){
10069 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10070 else player[i].targetanimation=player[i].getRun();
10071 player[i].target=0;
10072 player[i].targetframe=0;
10074 if(player[i].isCrouch()){
10075 player[i].targetanimation=sneakanim;
10076 if(player[i].wasCrouch())player[i].target=0;
10077 player[i].targetframe=0;
10079 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10080 player[i].targetanimation=climbanim;
10081 player[i].target=0;
10082 player[i].targetframe=1;
10083 player[i].jumpclimb=1;
10085 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10086 player[i].velocity+=absflatfacing*5*multiplier;
10088 player[i].forwardstogglekeydown=1;
10091 if (player[i].rightkeydown){
10092 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)){
10093 player[i].targetanimation=player[i].getRun();
10094 player[i].target=0;
10095 player[i].targetframe=0;
10097 if(player[i].isCrouch()){
10098 player[i].targetanimation=sneakanim;
10099 if(player[i].wasCrouch()) player[i].target=0;
10100 player[i].targetframe=0;
10102 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10103 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10105 player[i].targetrotation-=90;
10106 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10107 if(player[i].backkeydown)player[i].targetrotation-=45;
10110 if ( player[i].leftkeydown){
10111 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)){
10112 player[i].targetanimation=player[i].getRun();
10113 player[i].target=0;
10114 player[i].targetframe=0;
10116 if(player[i].isCrouch()){
10117 player[i].targetanimation=sneakanim;
10118 if(player[i].wasCrouch())player[i].target=0;
10119 player[i].targetframe=0;
10121 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10122 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10124 player[i].targetrotation+=90;
10125 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10126 if(player[i].backkeydown)player[i].targetrotation+=45;
10129 if(player[i].backkeydown){
10130 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)){
10131 player[i].targetanimation=player[i].getRun();
10132 player[i].target=0;
10133 player[i].targetframe=0;
10135 if(player[i].isCrouch()){
10136 player[i].targetanimation=sneakanim;
10137 if(player[i].wasCrouch())player[i].target=0;
10138 player[i].targetframe=0;
10140 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10141 player[i].velocity-=absflatfacing*5*multiplier;
10143 if(player[i].targetanimation==hanganim){
10144 player[i].currentanimation=jumpdownanim;
10145 player[i].targetanimation=jumpdownanim;
10146 player[i].target=0;
10147 player[i].currentframe=0;
10148 player[i].targetframe=1;
10149 player[i].velocity=0;
10150 player[i].velocity.y+=gravity;
10151 player[i].coords.y-=1.4;
10152 player[i].grabdelay=1;
10154 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10155 player[i].targetrotation+=180;
10158 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10159 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)){
10160 player[i].jumpstart=0;
10161 player[i].targetanimation=jumpupanim;
10162 player[i].target=0;
10163 player[i].targetframe=0;
10164 player[i].rotation=player[i].targetrotation;
10165 player[i].transspeed=20;
10166 player[i].FootLand(0,1);
10167 player[i].FootLand(1,1);
10171 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10173 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10174 if(!movekey)player[i].velocity=0;
10179 for(j=0;j<numplayers;j++){
10180 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10181 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10182 if(target>=0)target=-1;
10187 if(target>=0)player[i].velocity.y=1;
10188 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10189 player[i].velocity.y=7;
10190 player[i].crouchtogglekeydown=1;
10192 else player[i].velocity.y=5;
10194 if(mousejump&&i==0&&debugmode){
10195 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10196 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10199 player[i].coords.y+=.2;
10200 player[i].jumppower-=1;
10202 static float gLoc[3];
10203 static float vel[3];
10204 gLoc[0]=player[i].coords.x;
10205 gLoc[1]=player[i].coords.y;
10206 gLoc[2]=player[i].coords.z;
10207 vel[0]=player[i].velocity.x;
10208 vel[1]=player[i].velocity.y;
10209 vel[2]=player[i].velocity.z;
10212 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10213 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10214 OPENAL_SetVolume(channels[whooshsound], 128);
10215 OPENAL_SetPaused(channels[whooshsound], false);
10218 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10219 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10220 OPENAL_SetVolume(channels[jumpsound], 128);
10221 OPENAL_SetPaused(channels[jumpsound], false);
10223 if((player[i].isIdle())&&player[i].jumppower>1){
10224 player[i].targetanimation=player[i].getLanding();
10225 player[i].landhard=0;
10226 player[i].target=0;
10227 player[i].targetframe=2;
10228 player[i].jumpstart=1;
10229 player[i].tempdeltav=deltav;
10231 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10232 if(player[i].jumppower>multiplier*6){
10233 player[i].velocity.y+=multiplier*6;
10234 player[i].jumppower-=multiplier*6;
10236 if(player[i].jumppower<=multiplier*6){
10237 player[i].velocity.y+=player[i].jumppower;
10238 player[i].jumppower=0;
10241 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10245 if(player[i].isRun()||player[i].targetanimation==walkanim){
10246 player[i].targetanimation=player[i].getStop();
10247 player[i].target=0;
10248 player[i].targetframe=0;
10250 if(player[i].targetanimation==sneakanim){
10251 player[i].targetanimation=player[i].getCrouch();
10252 if(player[i].currentanimation==sneakanim)player[i].target=0;
10253 player[i].targetframe=0;
10256 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10257 player[i].targetanimation=player[i].getStop();
10258 player[i].target=0;
10259 player[i].targetframe=0;
10261 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10262 player[i].targetanimation=player[i].getStop();
10263 player[i].target=0;
10264 player[i].targetframe=0;
10268 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10272 for(k=0;k<numplayers;k++){
10273 if(abs(player[k].rotation-player[k].targetrotation)>180){
10274 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10275 else player[k].rotation+=360;
10278 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10279 player[k].targetanimation=player[k].getStop();
10280 player[k].targetframe=0;
10281 player[k].target=0;
10284 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10285 player[k].targettilt=0;
10287 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10288 player[k].targettilt=0;
10289 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10290 player[k].jumppower+=multiplier*7;
10291 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10292 //*(1-(player[k].damage/player[k].damagetolerance))
10293 if(player[k].jumppower>5)player[k].jumppower=5;
10296 if(player[k].isRun()){
10297 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10300 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10301 else if(player[k].tilt>player[k].targettilt){
10302 player[k].tilt-=multiplier*150;
10304 else if(player[k].tilt<player[k].targettilt){
10305 player[k].tilt+=multiplier*150;
10308 player[k].grabdelay-=multiplier;
10311 for(k=0;k<numplayers;k++){
10312 player[k].DoAnimations();
10313 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10314 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10319 player[0].righthandmorphstart=0;
10320 player[0].righthandmorphend=1;
10321 player[0].lefthandmorphstart=0;
10322 player[0].lefthandmorphend=1;
10323 player[0].headmorphstart=0;
10324 player[0].headmorphend=2;*/
10327 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10328 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10329 player[0].righthandmorphend=1;
10330 player[0].targetrighthandmorphness=1;
10332 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10333 player[0].lefthandmorphend=0;
10334 player[0].targetlefthandmorphness=1;
10336 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10337 player[0].headmorphend=2;
10338 player[0].targetheadmorphness=1;
10340 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10341 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10342 player[0].righthandmorphend=0;
10343 player[0].targetrighthandmorphness=1;
10345 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10346 player[0].lefthandmorphend=1;
10347 player[0].targetlefthandmorphness=1;
10349 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10350 player[0].headmorphend=0;
10351 player[0].targetheadmorphness=1;
10354 if(numenvsounds!=0)
10355 for(j=numenvsounds-1;j>=0;j--){
10356 envsoundlife[j]-=multiplier;
10357 if(envsoundlife[j]<0){
10359 envsoundlife[j]=envsoundlife[numenvsounds];
10360 envsound[j]=envsound[numenvsounds];
10363 if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
10364 if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
10366 if(tutoriallevel==1){
10383 if(tutorialstage>=51)
10384 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10385 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10386 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
10388 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10389 OPENAL_SetPaused(channels[stream_music3], false);
10390 OPENAL_SetVolume(channels[stream_music3], 256);
10395 float gLoc[3]={0,0,0};
10396 float vel[3]={0,0,0};
10397 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10398 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10399 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10400 OPENAL_SetVolume(channels[fireendsound], 256);
10401 OPENAL_SetPaused(channels[fireendsound], false);
10402 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10410 if(tutorialstage<51)
10411 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10414 gLoc[0]=player[0].coords.x;
10415 gLoc[1]=player[0].coords.y;
10416 gLoc[2]=player[0].coords.z;
10420 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10421 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10422 OPENAL_SetVolume(channels[fireendsound], 256);
10423 OPENAL_SetPaused(channels[fireendsound], false);
10425 player[0].coords=(oldtemp+oldtemp2)/2;
10433 if(tutorialstage>=14&&tutorialstage<50)
10434 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10437 gLoc[0]=player[1].coords.x;
10438 gLoc[1]=player[1].coords.y;
10439 gLoc[2]=player[1].coords.z;
10443 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10444 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10445 OPENAL_SetVolume(channels[fireendsound], 256);
10446 OPENAL_SetPaused(channels[fireendsound], false);
10448 for(int i=0;i<player[1].skeleton.num_joints;i++){
10450 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10451 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10452 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;
10453 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10454 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10458 player[1].coords=(oldtemp+oldtemp2)/2;
10459 for(int i=0;i<player[1].skeleton.num_joints;i++){
10460 player[1].skeleton.joints[i].velocity=0;
10462 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10463 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10464 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;
10465 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10466 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10474 static float gLoc[3];
10478 static float vel[3];
10479 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10480 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10481 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10483 //Set orientation with forward and up vectors
10484 static XYZ upvector;
10488 upvector=DoRotation(upvector,-rotation2+90,0,0);
10489 upvector=DoRotation(upvector,0,0-rotation,0);
10494 facing=DoRotation(facing,-rotation2,0,0);
10495 facing=DoRotation(facing,0,0-rotation,0);
10498 static float ori[6];
10499 ori[0] = -facing.x;
10501 ori[2] = -facing.z;
10502 ori[3] = -upvector.x;
10503 ori[4] = upvector.y;
10504 ori[5] = -upvector.z;
10506 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10513 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10515 freezetogglekeydown=1;
10519 void Game::TickOnce(){
10522 if(directing||indialogue==-1){
10523 rotation+=deltah*.7;
10524 if(!invertmouse)rotation2+=deltav*.7;
10525 if(invertmouse)rotation2-=deltav*.7;
10526 if(rotation2>90)rotation2=90;
10527 if(rotation2<-70)rotation2=-70;
10529 if(mainmenu)rotation+=multiplier*5;
10534 void Game::TickOnceAfter(){
10535 static XYZ colviewer;
10536 static XYZ coltarget;
10539 static float brotate;
10542 static float changedelay;
10543 static bool alldead;
10544 static float unseendelay;
10545 static float cameraspeed;
10549 if(environment==snowyenvironment)music1=stream_music1snow;
10550 if(environment==grassyenvironment)music1=stream_music1grass;
10551 if(environment==desertenvironment)music1=stream_music1desert;
10556 for(i=0;i<numplayers;i++){
10557 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)){
10558 musictype=stream_music2;
10562 if(player[0].dead)musictype=stream_music3;
10565 if(musictype==stream_music2){
10569 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10570 unseendelay-=multiplier;
10572 musictype=stream_music2;
10578 musictype=stream_music3;
10579 musicvolume[2]=512;
10586 if(musictype!=oldmusictype&&musictype==stream_music2){
10587 static float gLoc[3];
10588 static float vel[3];
10589 gLoc[0]=cameraloc.x;
10590 gLoc[1]=cameraloc.y;
10591 gLoc[2]=cameraloc.z;
10595 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
10596 OPENAL_SetVolume(channels[alarmsound], 512);
10597 OPENAL_SetPaused(channels[alarmsound], false);
10601 musicselected=musictype;
10603 if(musicselected==music1)musicvolume[0]+=multiplier*450;
10604 else musicvolume[0]-=multiplier*450;
10605 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
10606 else musicvolume[1]-=multiplier*450;
10607 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
10608 else musicvolume[2]-=multiplier*450;
10610 if(musicselected==music1)musicvolume[0]+=multiplier*100;
10611 else musicvolume[0]-=multiplier*450;
10612 if(musicselected==music2)musicvolume[1]+=multiplier*150;
10613 else if(player[0].dead)musicvolume[1]-=multiplier*450;
10614 else musicvolume[1]-=multiplier*100;
10615 if(musicselected==music3)musicvolume[2]+=multiplier*450;
10616 else musicvolume[2]-=multiplier*450;*/
10619 if(musicvolume[i]<0)musicvolume[i]=0;
10620 if(musicvolume[i]>512)musicvolume[i]=512;
10623 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
10626 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
10627 PlayStreamEx( music1, strm[music1], NULL, true);
10628 OPENAL_SetPaused(channels[music1], false);
10630 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
10631 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
10632 OPENAL_SetPaused(channels[stream_music2], false);
10634 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
10635 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10636 OPENAL_SetPaused(channels[stream_music3], false);
10641 OPENAL_SetPaused(channels[music1], true);
10642 OPENAL_SetPaused(channels[stream_music2], true);
10643 OPENAL_SetPaused(channels[stream_music3], true);
10646 oldmusicvolume[i]=0;
10652 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
10653 OPENAL_SetPaused(channels[music1], true);
10655 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
10656 OPENAL_SetPaused(channels[stream_music2], true);
10658 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
10659 OPENAL_SetPaused(channels[stream_music3], true);
10662 if(musicvolume[0]!=oldmusicvolume[0]){
10663 OPENAL_SetVolume(channels[music1], musicvolume[0]);
10665 if(musicvolume[1]!=oldmusicvolume[1]){
10666 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
10668 if(musicvolume[2]!=oldmusicvolume[2]){
10669 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
10673 oldmusicvolume[i]=musicvolume[i];
10679 for(i=0;i<numhotspots;i++){
10680 if(hotspottype[i]>10&&hotspottype[i]<20){
10681 if(player[hotspottype[i]-10].dead==0){
10684 else if(killhotspot==2)
10688 if(killhotspot==2)killhotspot=0;
10693 for(i=0;i<numhotspots;i++){
10694 if(hotspottype[i]==-1){
10695 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
10702 for(i=1;i<numplayers;i++){
10703 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
10705 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
10707 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
10708 if(player[0].dead&&changedelay<=0){
10710 targetlevel=whichlevel;
10714 for(i=1;i<numplayers;i++){
10715 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
10719 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
10721 targetlevel=whichlevel+1;
10722 if(targetlevel>numchallengelevels-1)targetlevel=0;
10724 if(winhotspot||windialogue){
10726 targetlevel=whichlevel+1;
10727 if(targetlevel>numchallengelevels-1)targetlevel=0;
10733 targetlevel=whichlevel+1;
10734 if(targetlevel>numchallengelevels-1)targetlevel=0;
10737 if(changedelay>0&&!player[0].dead&&!won){
10738 //high scores, awards, win
10741 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10742 accountcampaignchoicesmade[accountactive]++;
10743 accountcampaignscore[accountactive]+=bonustotal;
10745 accountcampaigntime[accountactive]+=leveltime;
10746 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
10748 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10754 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
10755 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
10757 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10773 if(!editorenabled&&gameon&&!mainmenu){
10774 if(changedelay!=-999)changedelay-=multiplier/7;
10775 if(player[0].dead)targetlevel=whichlevel;
10776 if(loading==2&&!campaign){
10784 float gLoc[3]={0,0,0};
10785 float vel[3]={0,0,0};
10786 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10787 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10788 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10789 OPENAL_SetVolume(channels[firestartsound], 256);
10790 OPENAL_SetPaused(channels[firestartsound], false);
10791 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10793 if(!player[0].dead&&targetlevel!=whichlevel){
10794 startbonustotal=bonustotal;
10796 if(!player[0].dead)Loadlevel(targetlevel);
10797 if(player[0].dead)Loadlevel(whichlevel);
10799 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10800 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10801 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10802 OPENAL_SetVolume(channels[fireendsound], 256);
10803 OPENAL_SetPaused(channels[fireendsound], false);
10804 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10808 if(loading==2&&targetlevel==whichlevel){
10816 float gLoc[3]={0,0,0};
10817 float vel[3]={0,0,0};
10818 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10819 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10820 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10821 OPENAL_SetVolume(channels[firestartsound], 256);
10822 OPENAL_SetPaused(channels[firestartsound], false);
10823 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10825 for(i=0;i<255;i++){
10839 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
10840 Loadlevel(mapname);
10842 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10843 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10844 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10845 OPENAL_SetVolume(channels[fireendsound], 256);
10846 OPENAL_SetPaused(channels[fireendsound], false);
10847 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10851 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
10852 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
10854 if(whichlevel!=-2&&!loading&&!player[0].dead){
10858 if(player[0].dead)loading=1;
10864 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
10865 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
10869 else if(mainmenu==0&&winfreeze){
10870 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
10872 else stealthloading=0;
10874 if(!stealthloading){
10875 float gLoc[3]={0,0,0};
10876 float vel[3]={0,0,0};
10877 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10878 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10879 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10880 OPENAL_SetVolume(channels[firestartsound], 256);
10881 OPENAL_SetPaused(channels[firestartsound], false);
10882 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10893 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
10894 //campaignnumlevels=0;
10895 //accountcampaignchoicesmade[accountactive]=0;
10896 ipstream.ignore(256,':');
10897 ipstream >> campaignnumlevels;
10898 for(i=0;i<campaignnumlevels;i++){
10899 ipstream.ignore(256,':');
10900 ipstream.ignore(256,':');
10901 ipstream.ignore(256,' ');
10902 ipstream >> campaignmapname[i];
10903 ipstream.ignore(256,':');
10904 ipstream >> campaigndescription[i];
10905 for(j=0;j<256;j++){
10906 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
10908 ipstream.ignore(256,':');
10909 ipstream >> campaignchoosenext[i];
10910 ipstream.ignore(256,':');
10911 ipstream >> campaignnumnext[i];
10912 if(campaignnumnext[i])
10913 for(j=0;j<campaignnumnext[i];j++){
10914 ipstream.ignore(256,':');
10915 ipstream >> campaignnextlevel[i][j];
10916 campaignnextlevel[i][j]-=1;
10918 ipstream.ignore(256,':');
10919 ipstream >> campaignlocationx[i];
10920 ipstream.ignore(256,':');
10921 ipstream >> campaignlocationy[i];
10925 for(i=0;i<campaignnumlevels;i++){
10927 levelhighlight[i]=0;
10931 for(i=0;i<campaignnumlevels;i++){
10933 levelhighlight[i]=0;
10938 if(accountcampaignchoicesmade[accountactive])
10939 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
10940 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
10941 levelvisible[levelorder[i+1]]=1;
10943 int whichlevelstart;
10944 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
10945 if(whichlevelstart<0){
10946 campaignchoicenum=1;
10947 campaignchoicewhich[0]=0;
10951 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
10952 if(campaignchoicenum)
10953 for(i=0;i<campaignchoicenum;i++){
10954 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
10955 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
10956 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
10963 //if(firstload)TickOnceAfter();
10964 if(!firstload)LoadStuff();
10966 for(i=0;i<255;i++){
10981 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10982 //accountcampaignchoicesmade[accountactive]++;
10985 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
10989 Loadlevel(mapname);
10993 OPENAL_SetPaused(channels[stream_music3], true);
10998 if(loading==3)loading=0;
11002 oldmusictype=musictype;
11008 facing=DoRotation(facing,-rotation2,0,0);
11009 facing=DoRotation(facing,0,0-rotation,0);
11010 viewerfacing=facing;
11014 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;
11015 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;
11017 if(player[0].skeleton.free){
11018 for(i=0;i<player[0].skeleton.num_joints;i++){
11019 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11020 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11024 if(player[0].skeleton.free!=2&&!autocam){
11026 if(findLengthfast(&player[0].velocity)>400){
11027 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11029 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11030 coltarget=target-cameraloc;
11031 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11033 Normalise(&coltarget);
11034 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11035 else cameraloc=cameraloc+coltarget*multiplier*8;
11037 if(editorenabled)cameraloc=target;
11038 cameradist+=multiplier*5;
11039 if(cameradist>2.3)cameradist=2.3;
11040 viewer=cameraloc-facing*cameradist;
11042 coltarget=cameraloc;
11043 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11044 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11045 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11046 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11048 coltarget=cameraloc;
11049 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11051 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11052 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11053 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11055 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11059 cameradist=findDistance(&viewer,&target);
11060 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11061 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11063 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11064 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11067 if(player[0].skeleton.free!=2&&autocam){
11069 if(findLengthfast(&player[0].velocity)>400){
11070 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11072 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11073 cameradist+=multiplier*5;
11074 if(cameradist>3.3)cameradist=3.3;
11075 coltarget=target-cameraloc;
11076 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11077 else if(findLengthfast(&coltarget)>1)
11079 Normalise(&coltarget);
11080 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11081 else cameraloc=cameraloc+coltarget*multiplier*8;
11083 if(editorenabled)cameraloc=target;
11086 coltarget=cameraloc;
11087 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11088 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11089 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11090 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11092 coltarget=cameraloc;
11093 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11095 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11096 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11097 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11099 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11103 cameradist=findDistance(&viewer,&target);
11104 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11105 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11107 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11108 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11111 if(camerashake>.8)camerashake=.8;
11112 //if(woozy>10)woozy=10;
11113 //woozy+=multiplier;
11115 if(player[0].dead)camerashake=0;
11116 if(player[0].dead)woozy=0;
11117 camerashake-=multiplier*2;
11118 blackout-=multiplier*2;
11119 //if(player[0].isCrouch())woozy-=multiplier*8;
11120 if(camerashake<0)camerashake=0;
11121 if(blackout<0)blackout=0;
11122 //if(woozy<0)woozy=0;
11124 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11125 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11126 viewer.z+=(float)(Random()%100)*.0005*camerashake;