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 showdamagebar; // (des)activate the damage bar
104 extern bool texttoggle;
105 extern bool alwaysblur;
106 extern float gamespeed;
109 extern bool immediate;
110 extern bool velocityblur;
113 extern float bonusvalue;
114 extern float bonustotal;
115 extern float bonustime;
116 extern float startbonustotal;
117 extern float tintr,tintg,tintb;
118 extern float bonusnum[100];
119 extern bool skyboxtexture;
120 extern float skyboxr;
121 extern float skyboxg;
122 extern float skyboxb;
123 extern float skyboxlightr;
124 extern float skyboxlightg;
125 extern float skyboxlightb;
126 extern float fadestart;
127 extern float slomospeed;
128 extern float slomofreq;
129 extern int tutoriallevel;
130 extern float smoketex;
131 extern float tutorialstagetime;
132 extern int tutorialstage;
133 extern float tutorialmaxtime;
134 extern float tutorialsuccess;
135 extern bool againbonus;
136 extern bool reversaltrain;
137 extern bool canattack;
138 extern bool cananger;
139 extern float damagedealt;
140 extern float damagetaken;
142 extern int editoractive;
143 extern int editorpathtype;
144 extern bool oldbuttons[3];
146 extern float hostiletime;
148 extern bool gamestarted;
150 extern int numhotspots;
151 extern int winhotspot;
152 extern int windialogue;
153 extern int killhotspot;
154 extern XYZ hotspot[40];
155 extern int hotspottype[40];
156 extern float hotspotsize[40];
157 extern char hotspottext[40][256];
158 extern int currenthotspot;
160 extern int kBitsPerPixel;
163 extern int numaccounts;
164 extern int accountactive;
165 extern int accountdifficulty[10];
166 extern int accountprogress[10];
167 extern float accountpoints[10];
168 extern float accounthighscore[10][50];
169 extern float accountfasttime[10][50];
170 extern bool accountunlocked[10][60];
171 extern char accountname[10][256];
173 extern bool stillloading;
174 extern bool winfreeze;
177 extern int numflipfail;
179 extern int numstaffattack;
180 extern int numswordattack;
181 extern int numknifeattack;
182 extern int numunarmedattack;
183 extern int numescaped;
184 extern int numflipped;
185 extern int numwallflipped;
186 extern int numthrowkill;
187 extern int numafterkill;
188 extern int numreversals;
189 extern int numattacks;
190 extern int maxalarmed;
191 extern int numresponded;
193 extern int numdialogues;
194 extern int numdialogueboxes[max_dialogues];
195 extern int dialoguetype[max_dialogues];
196 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
197 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
198 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
199 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
200 extern char dialoguename[max_dialogues][max_dialoguelength][64];
201 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
202 extern XYZ participantlocation[max_dialogues][10];
203 extern int participantfocus[max_dialogues][max_dialoguelength];
204 extern int participantaction[max_dialogues][max_dialoguelength];
205 extern float participantrotation[max_dialogues][10];
206 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
207 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
208 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
209 extern int indialogue;
210 extern int whichdialogue;
211 extern int directing;
212 extern float dialoguetime;
213 extern int dialoguegonethrough[20];
215 extern bool campaign;
217 extern float oldgamespeed;
219 extern float accountcampaignhighscore[10];
220 extern float accountcampaignfasttime[10];
221 extern float accountcampaignscore[10];
222 extern float accountcampaigntime[10];
224 extern int accountcampaignchoicesmade[10];
225 extern int accountcampaignchoices[10][5000];
227 static const char *rabbitskin[] = {
228 ":Data:Textures:Fur3.jpg",
229 ":Data:Textures:Fur.jpg",
230 ":Data:Textures:Fur2.jpg",
231 ":Data:Textures:Lynx.jpg",
232 ":Data:Textures:Otter.jpg",
233 ":Data:Textures:Opal.jpg",
234 ":Data:Textures:Sable.jpg",
235 ":Data:Textures:Chocolate.jpg",
236 ":Data:Textures:BW2.jpg",
237 ":Data:Textures:WB2.jpg"
240 static const char *wolfskin[] = {
241 ":Data:Textures:Wolf.jpg",
242 ":Data:Textures:Darkwolf.jpg",
243 ":Data:Textures:Snowwolf.jpg"
246 #define STATIC_ASSERT(x) extern int s_a_dummy[2 * (!!(x)) - 1];
247 STATIC_ASSERT (rabbittype == 0 && wolftype == 1)
249 static const char **creatureskin[] = {rabbitskin, wolfskin};
251 /********************> Tick() <*****/
252 extern OPENAL_STREAM * strm[20];
253 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
254 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
256 extern void ScreenShot(const char * fname);
257 void Screenshot (void)
260 time_t t = time(NULL);
261 struct tm *tme = localtime(&t);
262 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);
265 mkdir("Screenshots");
267 mkdir("Screenshots", S_IRWXU);
270 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
273 GraphicsExportComponent QT_exporter;
274 OSErr MAC_error_code;
275 CGrafPtr MAC_currentPort;
276 GDHandle MAC_currentDevice;
277 unsigned char* MAC_pixels;
278 Rect MAC_picture_rectangle;
279 GWorldPtr MAC_offscreen_graphics_port;
281 static int numscreenshots=0;
284 static char buf[256];
285 if(numscreenshots==0){
316 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
317 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
318 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
319 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
340 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
341 //assert(MAC_gWorld != NULL);
343 // Allocate memory for loading image
344 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
345 if (MAC_pixels == NULL) {
346 //UTIL_Error("Could not create Texture data.");
351 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
353 // Make a picture Rectangle
354 MAC_picture_rectangle.left = 0;
355 MAC_picture_rectangle.right = screenwidth;
356 MAC_picture_rectangle.top = 0;
357 MAC_picture_rectangle.bottom = screenheight;
359 // Create new offscreen GWorld
360 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
361 if (MAC_error_code) {
362 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
364 //UTIL_Error("Could not create offscreen GWorld. ");
369 // Copy OpenGL Context to new GWorld
370 glReadBuffer(GL_FRONT);
371 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
374 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
375 unsigned char temp = MAC_pixels[byte+0];
376 MAC_pixels[byte+0] = MAC_pixels[byte+3];
377 MAC_pixels[byte+3] = MAC_pixels[byte+2];
378 MAC_pixels[byte+2] = MAC_pixels[byte+1];
379 MAC_pixels[byte+1] = temp;
382 // Flip the image :( This could probably be optimized
387 for (int horz = 0; horz < screenwidth; ++horz)
388 for (vert = 0; vert < screenheight / 2; ++vert) {
389 src_index = (screenwidth * vert + horz) * 4;
390 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
392 temp=MAC_pixels[src_index+0];
393 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
394 MAC_pixels[dst_index+0]=temp;
396 temp=MAC_pixels[src_index+1];
397 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
398 MAC_pixels[dst_index+1]=temp;
400 temp=MAC_pixels[src_index+2];
401 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
402 MAC_pixels[dst_index+2]=temp;
404 temp=MAC_pixels[src_index+3];
405 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
406 MAC_pixels[dst_index+3]=temp;
412 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
413 if (MAC_error_code) {
414 //UTIL_Warning("Unable to export screenshot.");
415 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
416 ::DisposeGWorld(MAC_offscreen_graphics_port);
421 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
422 if (MAC_error_code) {
423 ::CloseComponent(QT_exporter);
424 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
425 ::DisposeGWorld(MAC_offscreen_graphics_port);
427 //UTIL_Warning("Unable to export screenshot.");
431 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
432 if (MAC_error_code) {
433 ::CloseComponent(QT_exporter);
434 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
435 ::DisposeGWorld(MAC_offscreen_graphics_port);
437 //UTIL_Warning("Unable to export screenshot.");
441 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
442 if (MAC_error_code) {
443 ::CloseComponent(QT_exporter);
444 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
445 ::DisposeGWorld(MAC_offscreen_graphics_port);
447 //UTIL_Warning("Unable to export screenshot.");
451 ::CloseComponent(QT_exporter);
452 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
453 ::DisposeGWorld(MAC_offscreen_graphics_port);
460 void Game::SetUpLighting(){
461 if(environment==snowyenvironment){
467 light.ambient[2]=.44;
469 if(environment==desertenvironment){
474 light.ambient[1]=.35;
478 if(environment==grassyenvironment){
484 light.ambient[2]=.44;
495 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
496 light.color[0]*=(skyboxlightr+average)/2;
497 light.color[1]*=(skyboxlightg+average)/2;
498 light.color[2]*=(skyboxlightb+average)/2;
499 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
500 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
501 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
505 light.ambient[2]=0; */
508 int Game::findPathDist(int start,int end){
509 int i,j,k,smallestcount,count,connected;
510 int last,last2,last3,last4;
520 while(last!=end&&count<30){
522 for(j=0;j<numpathpoints;j++){
523 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
526 if(numpathpointconnect[j])
527 for(k=0;k<numpathpointconnect[j];k++){
528 if(pathpointconnect[j][k]==last)connected=1;
531 if(numpathpointconnect[last])
532 for(k=0;k<numpathpointconnect[last];k++){
533 if(pathpointconnect[last][k]==j)connected=1;
536 if(closest==-1||Random()%2==0){
547 if(count<smallestcount)smallestcount=count;
549 return smallestcount;
552 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
553 static XYZ colpoint,colviewer,coltarget;
554 static float minx,minz,maxx,maxz,miny,maxy;
563 if(minx>endpoint.x)minx=endpoint.x;
565 if(miny>endpoint.y)miny=endpoint.y;
567 if(minz>endpoint.z)minz=endpoint.z;
570 if(maxx<endpoint.x)maxx=endpoint.x;
572 if(maxy<endpoint.y)maxy=endpoint.y;
574 if(maxz<endpoint.z)maxz=endpoint.z;
583 for(i=0;i<objects.numobjects;i++){
584 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){
585 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
586 colviewer=startpoint;
588 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
593 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
598 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
599 static XYZ colpoint,colviewer,coltarget;
600 static float minx,minz,maxx,maxz,miny,maxy;
609 if(minx>endpoint.x)minx=endpoint.x;
611 if(miny>endpoint.y)miny=endpoint.y;
613 if(minz>endpoint.z)minz=endpoint.z;
616 if(maxx<endpoint.x)maxx=endpoint.x;
618 if(maxy<endpoint.y)maxy=endpoint.y;
620 if(maxz<endpoint.z)maxz=endpoint.z;
630 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){
631 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
632 colviewer=startpoint;
634 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
639 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
644 void Game::Setenvironment(int which)
648 LOG(" Setting environment...");
653 OPENAL_SetPaused(channels[music1snow], true);
654 OPENAL_SetPaused(channels[music1grass], true);
655 OPENAL_SetPaused(channels[music1desert], true);
656 OPENAL_SetPaused(channels[wind], true);
657 OPENAL_SetPaused(channels[desertambient], true);
659 OPENAL_SetPaused(channels[stream_music1snow], true);
660 OPENAL_SetPaused(channels[stream_music1grass], true);
661 OPENAL_SetPaused(channels[stream_music1desert], true);
662 OPENAL_SetPaused(channels[stream_wind], true);
663 OPENAL_SetPaused(channels[stream_desertambient], true);
666 if(environment==snowyenvironment){
670 //PlaySoundEx( wind, samp[wind], NULL, true);
671 PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
672 OPENAL_SetPaused(channels[stream_wind], false);
673 OPENAL_SetVolume(channels[stream_wind], 256);
676 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
677 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
678 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
679 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
681 OPENAL_Sample_Free(samp[footstepsound]);
682 OPENAL_Sample_Free(samp[footstepsound2]);
683 OPENAL_Sample_Free(samp[footstepsound3]);
684 OPENAL_Sample_Free(samp[footstepsound4]);
685 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
686 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
687 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
688 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
689 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
690 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
691 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
692 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
694 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
696 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
698 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
703 temptexdetail=texdetail;
704 if(texdetail>1)texdetail=4;
705 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
706 ":Data:Textures:Skybox(snow):Left.jpg",
707 ":Data:Textures:Skybox(snow):Back.jpg",
708 ":Data:Textures:Skybox(snow):Right.jpg",
709 ":Data:Textures:Skybox(snow):Up.jpg",
710 ":Data:Textures:Skybox(snow):Down.jpg",
711 ":Data:Textures:Skybox(snow):Cloud.jpg",
712 ":Data:Textures:Skybox(snow):Reflect.jpg");
717 texdetail=temptexdetail;
719 if(environment==desertenvironment){
722 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
723 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
724 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
725 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
729 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
730 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
731 OPENAL_SetPaused(channels[stream_desertambient], false);
732 OPENAL_SetVolume(channels[stream_desertambient], 256);
735 OPENAL_Sample_Free(samp[footstepsound]);
736 OPENAL_Sample_Free(samp[footstepsound2]);
737 OPENAL_Sample_Free(samp[footstepsound3]);
738 OPENAL_Sample_Free(samp[footstepsound4]);
739 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
740 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
741 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
742 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
743 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
744 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
745 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
746 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
748 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
750 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
752 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
756 temptexdetail=texdetail;
757 if(texdetail>1)texdetail=4;
758 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
759 ":Data:Textures:Skybox(sand):Left.jpg",
760 ":Data:Textures:Skybox(sand):Back.jpg",
761 ":Data:Textures:Skybox(sand):Right.jpg",
762 ":Data:Textures:Skybox(sand):Up.jpg",
763 ":Data:Textures:Skybox(sand):Down.jpg",
764 ":Data:Textures:Skybox(sand):Cloud.jpg",
765 ":Data:Textures:Skybox(sand):Reflect.jpg");
770 texdetail=temptexdetail;
772 if(environment==grassyenvironment){
775 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
776 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
777 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
778 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
781 PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
782 OPENAL_SetPaused(channels[stream_wind], false);
783 OPENAL_SetVolume(channels[stream_wind], 100);
786 OPENAL_Sample_Free(samp[footstepsound]);
787 OPENAL_Sample_Free(samp[footstepsound2]);
788 OPENAL_Sample_Free(samp[footstepsound3]);
789 OPENAL_Sample_Free(samp[footstepsound4]);
790 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass1.ogg"), OPENAL_HW3D, 0, 0);
791 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass2.ogg"), OPENAL_HW3D, 0, 0);
792 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
793 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
794 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
795 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
796 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
797 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
799 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
801 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
803 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
807 temptexdetail=texdetail;
808 if(texdetail>1)texdetail=4;
809 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
810 ":Data:Textures:Skybox(grass):Left.jpg",
811 ":Data:Textures:Skybox(grass):Back.jpg",
812 ":Data:Textures:Skybox(grass):Right.jpg",
813 ":Data:Textures:Skybox(grass):Up.jpg",
814 ":Data:Textures:Skybox(grass):Down.jpg",
815 ":Data:Textures:Skybox(grass):Cloud.jpg",
816 ":Data:Textures:Skybox(grass):Reflect.jpg");
820 texdetail=temptexdetail;
822 temptexdetail=texdetail;
824 terrain.load(":Data:Textures:heightmap.png");
826 texdetail=temptexdetail;
830 void Game::Loadlevel(int which){
833 if(which==0)Loadlevel((char *)":Data:Maps:map1");
834 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
835 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
836 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
837 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
838 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
839 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
840 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
841 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
842 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
843 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
844 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
845 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
846 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
847 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
848 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
849 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
850 else Loadlevel((char *)":Data:Maps:mapsave");
855 /*char * Game::MD5_string (unsigned char *string){
859 strcpy(temp2,(const char *)string);
860 strcat((char *)temp2,(const char *)"Lugaru");
861 sprintf (temp, "%d",strlen((char *)temp2));
862 strcat((char *)temp2,temp);
865 unsigned int len = strlen ( (char *)temp2);
867 context.update ((unsigned char *)temp2, len);
870 return context.hex_digest();
875 void Game::Loadlevel(char *name){
882 float headprop,legprop,armprop,bodyprop;
886 LOG(std::string("Loading level...") + name);
888 if(!gameon)visibleloading=1;
890 if(stealthloading)visibleloading=0;
892 if(!stillloading)loadtime=0;
897 if(tutoriallevel!=-1)tutoriallevel=0;
898 else tutoriallevel=1;
900 if(tutoriallevel==1)tutorialstage=0;
901 if(tutorialstage==0){
909 OPENAL_SetPaused(channels[whooshsound], true);
910 OPENAL_SetPaused(channels[stream_firesound], true);
912 // Change the map filename into something that is os specific
913 char *FixedFN = ConvertFileName(name);
917 tfile=fopen( FixedFN, "rb" );
920 OPENAL_SetPaused(channels[stream_firesound], true);
931 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
937 dialoguegonethrough[i]=0;
946 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
948 if(difficulty!=2)minimap=1;
985 bonustotal=startbonustotal;
991 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
992 OPENAL_SetVolume(channels[consolesuccesssound], 256);
993 OPENAL_SetPaused(channels[consolesuccesssound], false);
1000 terrain.numdecals=0;
1001 sprites.numsprites=0;
1002 for(i=0;i<objects.numobjects;i++)
1004 objects.model[i].numdecals=0;
1007 j=objects.numobjects;
1010 objects.DeleteObject(0);
1011 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1014 for(i=0;i<subdivision;i++)
1016 for(j=0;j<subdivision;j++)
1018 terrain.patchobjectnum[i][j]=0;
1021 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1024 weapons.numweapons=0;
1026 funpackf(tfile, "Bi", &mapvers);
1027 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1029 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1030 else maptype=mapkilleveryone;
1031 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1033 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1039 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1047 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1050 skyboxlightr=skyboxr;
1051 skyboxlightg=skyboxg;
1052 skyboxlightb=skyboxb;
1054 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);
1055 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1056 player[0].originalcoords=player[0].coords;
1057 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1059 for(j=0;j<player[0].num_weapons;j++)
1061 player[0].weaponids[j]=weapons.numweapons;
1062 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1063 weapons.owner[weapons.numweapons]=0;
1064 weapons.numweapons++;
1068 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1070 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1071 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1072 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1073 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1075 funpackf(tfile, "Bi", &player[0].numclothes);
1079 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1083 player[0].whichskin=0;
1084 player[0].creature=rabbittype;
1087 for(i=0;i<max_dialogues;i++)
1089 for(j=0;j<max_dialoguelength;j++)
1093 dialoguetext[i][j][k]='\0';
1097 dialoguename[i][j][k]='\0';
1102 player[0].lastattack=-1;
1103 player[0].lastattack2=-1;
1104 player[0].lastattack3=-1;
1108 funpackf(tfile, "Bi", &numdialogues);
1111 for(k=0;k<numdialogues;k++)
1113 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1114 funpackf(tfile, "Bi", &dialoguetype[k]);
1117 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1118 funpackf(tfile, "Bf", &participantrotation[k][l]);
1120 if(numdialogueboxes)
1122 for(l=0;l<numdialogueboxes[k];l++)
1124 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1125 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1126 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1127 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1128 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1132 funpackf(tfile, "Bi",&templength);
1133 if(templength>128||templength<=0)templength=128;
1134 for(m=0;m<templength;m++){
1135 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1136 if(dialoguetext[k][l][m]=='\0')break;
1139 funpackf(tfile, "Bi",&templength);
1140 if(templength>64||templength<=0)templength=64;
1141 for(m=0;m<templength;m++){
1142 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1143 if(dialoguename[k][l][m]=='\0'){
1147 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1148 funpackf(tfile, "Bi", &participantfocus[k][l]);
1149 funpackf(tfile, "Bi", &participantaction[k][l]);
1152 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1154 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1160 else numdialogues=0;
1162 if(player[0].numclothes)
1164 for(k=0;k<player[0].numclothes;k++)
1166 funpackf(tfile, "Bi", &templength);
1167 for(l=0;l<templength;l++)
1168 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1169 player[0].clothes[k][templength]='\0';
1170 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1174 funpackf(tfile, "Bi", &environment);
1176 funpackf(tfile, "Bi", &objects.numobjects);
1177 if(objects.numobjects)
1179 for(i=0;i<objects.numobjects;i++)
1181 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]);
1182 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1188 funpackf(tfile, "Bi", &numhotspots);
1191 for(i=0;i<numhotspots;i++)
1193 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1194 funpackf(tfile, "Bi", &templength);
1196 for(l=0;l<templength;l++)
1197 funpackf(tfile, "Bb", &hotspottext[i][l]);
1198 hotspottext[i][templength]='\0';
1199 if(hotspottype[i]==-111)indemo=1;
1205 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1210 for(i=0;i<objects.numobjects;i++)
1212 objects.center+=objects.position[i];
1214 objects.center/=objects.numobjects;
1217 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1219 float maxdistance=0;
1222 for(i=0;i<objects.numobjects;i++)
1224 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1225 if(tempdist>maxdistance)
1228 maxdistance=tempdist;
1231 objects.radius=fast_sqrt(maxdistance);
1234 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1235 //mapcenter=objects.center;
1236 //mapradius=objects.radius;
1238 funpackf(tfile, "Bi", &numplayers);
1239 int howmanyremoved=0;
1240 bool removeanother=0;
1241 if(numplayers>1&&numplayers<maxplayers)
1243 for(i=1;i<numplayers;i++)
1245 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1248 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);
1249 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1250 else player[i-howmanyremoved].howactive=typeactive;
1251 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1252 else player[i-howmanyremoved].scale=-1;
1253 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1254 else player[i-howmanyremoved].immobile=0;
1255 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1256 else player[i-howmanyremoved].rotation=0;
1257 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1258 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1264 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1266 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1268 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1269 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1270 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1271 weapons.numweapons++;
1274 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1275 //player[i-howmanyremoved].numwaypoints=10;
1276 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1278 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1279 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1280 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1281 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1282 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1285 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1286 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1288 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1289 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1290 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1291 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1293 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1301 if(player[i-howmanyremoved].creature==wolftype)
1303 player[i-howmanyremoved].proportionhead=1.1*headprop;
1304 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1305 player[i-howmanyremoved].proportionarms=1.1*armprop;
1306 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1309 if(player[i-howmanyremoved].creature==rabbittype)
1311 player[i-howmanyremoved].proportionhead=1.2*headprop;
1312 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1313 player[i-howmanyremoved].proportionarms=1.00*armprop;
1314 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1315 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1318 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1319 if(player[i-howmanyremoved].numclothes)
1321 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1324 funpackf(tfile, "Bi", &templength);
1325 for(l=0;l<templength;l++)
1326 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1327 player[i-howmanyremoved].clothes[k][templength]='\0';
1328 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1334 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1336 numplayers-=howmanyremoved;
1337 funpackf(tfile, "Bi", &numpathpoints);
1338 if(numpathpoints>30||numpathpoints<0)
1342 for(j=0;j<numpathpoints;j++)
1344 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1345 for(k=0;k<numpathpointconnect[j];k++){
1346 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1350 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1352 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1355 if(environment!=oldenvironment)Setenvironment(environment);
1356 oldenvironment=environment;
1360 j=objects.numobjects;
1361 objects.numobjects=0;
1364 //if(objects.type[i]!=spiketype)
1365 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1366 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1369 //if(skyboxtexture){
1370 terrain.DoShadows();
1371 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1372 objects.DoShadows();
1373 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1375 else terrain.DoLighting();
1381 oldlevel=whichlevel;
1384 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1385 for(i=0;i<numplayers;i++)
1387 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1391 if(i==0||player[i].scale<0)player[i].scale=.2;
1392 player[i].skeleton.free=0;
1393 player[i].skeleton.id=i;
1394 //if(Random()%2==0)player[i].creature=wolftype;
1395 //else player[i].creature=rabbittype;
1396 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1397 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);
1400 if(player[i].creature!=wolftype){
1401 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);
1402 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1404 if(player[i].creature==wolftype){
1405 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);
1411 texsize=512*512*3/texdetail/texdetail;
1412 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1413 //player[i].skeleton.skinText.resize(texsize);
1415 LoadTextureSave(creatureskin[player[i].creature][player[i].whichskin],&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1417 if(player[i].numclothes)
1419 for(j=0;j<player[i].numclothes;j++)
1421 tintr=player[i].clothestintr[j];
1422 tintg=player[i].clothestintg[j];
1423 tintb=player[i].clothestintb[j];
1424 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1426 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1429 player[i].currentanimation=bounceidleanim;
1430 player[i].targetanimation=bounceidleanim;
1431 player[i].currentframe=0;
1432 player[i].targetframe=1;
1434 player[i].speed=1+(float)(Random()%100)/1000;
1435 if(difficulty==0)player[i].speed-=.2;
1436 if(difficulty==1)player[i].speed-=.1;
1438 player[i].velocity=0;
1439 player[i].oldcoords=player[i].coords;
1440 player[i].realoldcoords=player[i].coords;
1443 player[i].skeleton.id=i;
1444 player[i].updatedelay=0;
1445 player[i].normalsupdatedelay=0;
1447 player[i].aitype=passivetype;
1448 player[i].aitarget=0;
1449 player[i].madskills=0;
1453 player[i].proportionhead=1.2;
1454 player[i].proportionbody=1.05;
1455 player[i].proportionarms=1.00;
1456 player[i].proportionlegs=1.1;
1457 player[i].proportionlegs.y=1.05;
1459 player[i].headless=0;
1460 player[i].currentoffset=0;
1461 player[i].targetoffset=0;
1462 /*player[i].armorhead=1;
1463 player[i].armorhigh=1;
1464 player[i].armorlow=1;
1465 player[i].protectionhead=1;
1466 player[i].protectionhigh=1;
1467 player[i].protectionlow=1;
1468 player[i].metalhead=1;
1469 player[i].metalhigh=1;
1470 player[i].metallow=1;
1472 player[i].speedmult=1;*/
1474 player[i].damagetolerance=200;
1476 if(player[i].creature==wolftype)
1478 /*player[i].proportionhead=1.1;
1479 player[i].proportionbody=1.1;
1480 player[i].proportionarms=1.1;
1481 player[i].proportionlegs=1.1;
1482 player[i].proportionlegs.y=1.1;*/
1483 if(i==0||player[i].scale<0)player[i].scale=.23;
1485 player[i].damagetolerance=300;
1488 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1491 player[i].proportionhead.z=0;
1492 player[i].proportionbody.z=0;
1493 player[i].proportionarms.z=0;
1494 player[i].proportionlegs.z=0;
1497 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1499 player[i].headmorphness=0;
1500 player[i].targetheadmorphness=1;
1501 player[i].headmorphstart=0;
1502 player[i].headmorphend=0;
1504 player[i].pausetime=0;
1507 player[i].jumppower=5;
1509 player[i].permanentdamage=0;
1510 player[i].superpermanentdamage=0;
1512 player[i].forwardkeydown=0;
1513 player[i].leftkeydown=0;
1514 player[i].backkeydown=0;
1515 player[i].rightkeydown=0;
1516 player[i].jumpkeydown=0;
1517 player[i].crouchkeydown=0;
1518 player[i].throwkeydown=0;
1520 player[i].collided=-10;
1522 player[i].bloodloss=0;
1523 player[i].weaponactive=-1;
1524 player[i].weaponstuck=-1;
1525 player[i].bleeding=0;
1526 player[i].deathbleeding=0;
1527 player[i].stunned=0;
1528 player[i].hasvictim=0;
1529 player[i].wentforweapon=0;
1532 player[0].aitype=playercontrolled;
1533 player[0].weaponactive=-1;
1537 //player[0].speedmult=1/.9;
1538 player[0].power=1/.9;
1543 //player[0].speedmult=1/.8;
1544 player[0].power=1/.8;
1547 //player[0].weaponstuck=1;
1549 if(difficulty==1)player[0].damagetolerance=250;
1550 if(difficulty==0)player[0].damagetolerance=300;
1551 if(difficulty==0)player[0].armorhead*=1.5;
1552 if(difficulty==0)player[0].armorhigh*=1.5;
1553 if(difficulty==0)player[0].armorlow*=1.5;
1554 cameraloc=player[0].coords;
1556 rotation=player[0].rotation;
1558 hawkcoords=player[0].coords;
1561 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1562 //weapons.numweapons=numplayers;
1563 for(i=0;i<weapons.numweapons;i++)
1565 weapons.bloody[i]=0;
1566 weapons.blooddrip[i]=0;
1567 weapons.blooddripdelay[i]=0;
1568 weapons.onfire[i]=0;
1569 weapons.flamedelay[i]=0;
1570 weapons.damage[i]=0;
1571 //weapons.type[i]=sword;
1572 if(weapons.type[i]==sword){
1573 weapons.mass[i]=1.5;
1574 weapons.tipmass[i]=1;
1575 weapons.length[i]=.8;
1577 if(weapons.type[i]==staff){
1579 weapons.tipmass[i]=1;
1580 weapons.length[i]=1.5;
1582 if(weapons.type[i]==knife){
1584 weapons.tipmass[i]=1.2;
1585 weapons.length[i]=.25;
1587 weapons.position[i]=-1000;
1588 weapons.tippoint[i]=-1000;
1591 /* for(i=0;i<32;i++){
1593 OPENAL_StopSound(i);
1596 LOG("Starting background music...");
1598 OPENAL_StopSound(OPENAL_ALL);
1599 if(environment==snowyenvironment)
1603 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1604 OPENAL_SetPaused(channels[stream_wind], false);
1605 OPENAL_SetVolume(channels[stream_wind], 256);
1608 else if(environment==desertenvironment)
1612 //PlaySoundEx(desertambient,
1613 // samp[desertambient], NULL, true);
1614 PlayStreamEx(stream_desertambient,
1615 strm[stream_desertambient], NULL, true);
1616 OPENAL_SetPaused(channels[stream_desertambient], false);
1617 OPENAL_SetVolume(channels[stream_desertambient], 256);
1620 else if(environment==grassyenvironment)
1624 //PlaySoundEx(wind, samp[wind], NULL, true);
1625 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1626 OPENAL_SetPaused(channels[stream_wind], false);
1627 OPENAL_SetVolume(channels[stream_wind], 100);
1630 oldmusicvolume[0]=0;
1631 oldmusicvolume[1]=0;
1632 oldmusicvolume[2]=0;
1633 oldmusicvolume[3]=0;
1636 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1637 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1638 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1639 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1640 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1641 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1642 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1643 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1658 static int i,k,j,l,m;
1659 static XYZ facing,flatfacing,absflatfacing;
1660 static XYZ rotatetarget;
1662 static float oldtargetrotation;
1663 static int target, numgood;
1664 static XYZ tempcoords1,tempcoords2;
1667 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1668 static int whichhit;
1669 static bool donesomething;
1670 static bool oldjumpkeydown;
1674 float headprop,bodyprop,armprop,legprop;
1677 displaytime[i]+=multiplier;
1680 static unsigned char theKeyMap[16];
1681 GetKeys( theKeyMap );
1686 static bool mainmenutogglekeydown;
1688 if(mainmenu&&endgame==1)mainmenu=10;
1689 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1691 displaytext[0][j]=' ';
1696 mainmenutogglekeydown=1;
1698 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)){
1700 if(mainmenu==1||mainmenu==2||mainmenu==0){
1701 if(mainmenu==0&&!winfreeze)mainmenu=2;
1702 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1703 else if(mainmenu==0&&winfreeze){
1704 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1706 else stealthloading=0;
1708 if(!stealthloading){
1709 float gLoc[3]={0,0,0};
1710 float vel[3]={0,0,0};
1711 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1712 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1713 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1714 OPENAL_SetVolume(channels[firestartsound], 256);
1715 OPENAL_SetPaused(channels[firestartsound], false);
1716 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1727 for(i=0;i<campaignnumlevels;i++){
1729 levelhighlight[i]=0;
1734 if(accountcampaignchoicesmade[accountactive])
1735 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1736 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1737 levelvisible[levelorder[i+1]]=1;
1739 int whichlevelstart;
1740 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1741 if(whichlevelstart<0){
1742 campaignchoicenum=1;
1743 campaignchoicewhich[0]=0;
1747 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1748 if(campaignchoicenum)
1749 for(i=0;i<campaignchoicenum;i++){
1750 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1751 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1752 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1759 if(firstload)TickOnceAfter();
1760 if(!firstload)LoadStuff();
1777 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1778 //accountcampaignchoicesmade[accountactive]++;
1781 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1789 OPENAL_SetPaused(channels[music3], true);
1793 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1794 if(mainmenu&&musictoggle){
1795 if(mainmenu==1||mainmenu==2||mainmenu==100){
1796 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
1797 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1798 OPENAL_SetPaused(channels[stream_music3], false);
1799 OPENAL_SetVolume(channels[stream_music3], 256);
1800 OPENAL_SetPaused(channels[music1], true);
1804 OPENAL_SetPaused(channels[stream_music3], true);
1805 OPENAL_SetPaused(channels[music1], false);
1809 float gLoc[3]={0,0,0};
1810 float vel[3]={0,0,0};
1811 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1812 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1813 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1814 OPENAL_SetVolume(channels[fireendsound], 256);
1815 OPENAL_SetPaused(channels[fireendsound], false);
1816 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1824 if(newdetail>2)newdetail=detail;
1825 if(newdetail<0)newdetail=detail;
1826 if(newscreenwidth<0)newscreenwidth=screenwidth;
1827 if(newscreenheight<0)newscreenheight=screenheight;
1829 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1830 opstream << "Screenwidth:\n";
1831 opstream << newscreenwidth;
1832 opstream << "\nScreenheight:\n";
1833 opstream << newscreenheight;
1834 opstream << "\nMouse sensitivity:\n";
1835 opstream << usermousesensitivity;
1836 opstream << "\nBlur(0,1):\n";
1837 opstream << ismotionblur;
1838 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1839 opstream << newdetail;
1840 opstream << "\nFloating jump:\n";
1841 opstream << floatjump;
1842 opstream << "\nMouse jump:\n";
1843 opstream << mousejump;
1844 opstream << "\nAmbient sound:\n";
1845 opstream << ambientsound;
1846 opstream << "\nBlood (0,1,2):\n";
1847 opstream << bloodtoggle;
1848 opstream << "\nAuto slomo:\n";
1849 opstream << autoslomo;
1850 opstream << "\nFoliage:\n";
1851 opstream << foliage;
1852 opstream << "\nMusic:\n";
1853 opstream << musictoggle;
1854 opstream << "\nTrilinear:\n";
1855 opstream << trilinear;
1856 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1858 opstream << "\nInvert mouse:\n";
1859 opstream << invertmouse;
1860 opstream << "\nGamespeed:\n";
1861 if(oldgamespeed==0)oldgamespeed=1;
1862 opstream << oldgamespeed;
1863 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1864 opstream << difficulty;
1865 opstream << "\nDamage effects(blackout, doublevision):\n";
1866 opstream << damageeffects;
1867 opstream << "\nText:\n";
1868 opstream << texttoggle;
1869 opstream << "\nDebug:\n";
1870 opstream << debugmode;
1871 opstream << "\nVBL Sync:\n";
1872 opstream << vblsync;
1873 opstream << "\nShow Points:\n";
1874 opstream << showpoints;
1875 opstream << "\nAlways Blur:\n";
1876 opstream << alwaysblur;
1877 opstream << "\nImmediate mode (turn on on G5):\n";
1878 opstream << immediate;
1879 opstream << "\nVelocity blur:\n";
1880 opstream << velocityblur;
1881 opstream << "\nVolume:\n";
1883 opstream << "\nForward key:\n";
1884 opstream << KeyToChar(forwardkey);
1885 opstream << "\nBack key:\n";
1886 opstream << KeyToChar(backkey);
1887 opstream << "\nLeft key:\n";
1888 opstream << KeyToChar(leftkey);
1889 opstream << "\nRight key:\n";
1890 opstream << KeyToChar(rightkey);
1891 opstream << "\nJump key:\n";
1892 opstream << KeyToChar(jumpkey);
1893 opstream << "\nCrouch key:\n";
1894 opstream << KeyToChar(crouchkey);
1895 opstream << "\nDraw key:\n";
1896 opstream << KeyToChar(drawkey);
1897 opstream << "\nThrow key:\n";
1898 opstream << KeyToChar(throwkey);
1899 opstream << "\nAttack key:\n";
1900 opstream << KeyToChar(attackkey);
1901 opstream << "\nChat key:\n";
1902 opstream << KeyToChar(chatkey);
1903 opstream << "\nDamage bar:\n";
1904 opstream << showdamagebar;
1907 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
1908 float gLoc[3]={0,0,0};
1909 float vel[3]={0,0,0};
1910 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1911 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1912 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1913 OPENAL_SetVolume(channels[fireendsound], 256);
1914 OPENAL_SetPaused(channels[fireendsound], false);
1915 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1923 if(mainmenu==3&&gameon)mainmenu=2;
1924 if(mainmenu==3&&!gameon)mainmenu=1;
1925 if(mainmenu==5&&gameon)mainmenu=2;
1926 if(mainmenu==5&&!gameon)mainmenu=1;
1927 if(mainmenu==4)mainmenu=3;
1928 if(mainmenu==6)mainmenu=5;
1929 if(mainmenu==7)mainmenu=1;
1930 if(mainmenu==9)mainmenu=5;
1931 if(mainmenu==11)mainmenu=5;
1932 if(mainmenu==13)mainmenu=12;
1933 if(mainmenu==10)mainmenu=5;
1939 mainmenutogglekeydown=1;
1941 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1942 mainmenutogglekeydown=0;
1946 /*static bool minimaptogglekeydown;
1947 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1949 minimaptogglekeydown=1;
1951 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1952 minimaptogglekeydown=0;
1956 static bool minimaptogglekeydown;
1957 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1958 if(tutorialstage!=51)
1959 tutorialstagetime=tutorialmaxtime;
1960 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
1961 OPENAL_SetVolume(channels[consolefailsound], 128);
1962 OPENAL_SetPaused(channels[consolefailsound], false);
1963 minimaptogglekeydown=1;
1965 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1966 minimaptogglekeydown=0;
1971 if(mainmenu==1||mainmenu==2){
1972 if(Button()&&!oldbutton&&selected==1){
1974 float gLoc[3]={0,0,0};
1975 float vel[3]={0,0,0};
1976 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1977 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1978 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1979 OPENAL_SetVolume(channels[firestartsound], 256);
1980 OPENAL_SetPaused(channels[firestartsound], false);
1981 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1990 if(accountactive!=-1)mainmenu=5;
1997 if(firstload)TickOnceAfter();
1998 if(!firstload)LoadStuff();
2004 OPENAL_SetPaused(channels[music3], true); */
2010 OPENAL_SetPaused(channels[stream_music3], true);
2011 OPENAL_SetPaused(channels[music1], false);
2015 if(Button()&&!oldbutton&&selected==2){
2016 float gLoc[3]={0,0,0};
2017 float vel[3]={0,0,0};
2018 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2019 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2020 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2021 OPENAL_SetVolume(channels[firestartsound], 256);
2022 OPENAL_SetPaused(channels[firestartsound], false);
2023 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2035 if(newdetail>2)newdetail=detail;
2036 if(newdetail<0)newdetail=detail;
2037 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2038 if(newscreenwidth<0)newscreenwidth=screenwidth;
2039 if(newscreenheight>3000)newscreenheight=screenheight;
2040 if(newscreenheight<0)newscreenheight=screenheight;
2043 if(Button()&&!oldbutton&&selected==3){
2044 float gLoc[3]={0,0,0};
2045 float vel[3]={0,0,0};
2046 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2047 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2048 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2049 OPENAL_SetVolume(channels[fireendsound], 256);
2050 OPENAL_SetPaused(channels[fireendsound], false);
2051 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2062 OPENAL_SetPaused(channels[stream_music3], true);
2070 if(Button())oldbutton=1;
2075 if(Button()&&!oldbutton&&selected!=-1){
2076 float gLoc[3]={0,0,0};
2077 float vel[3]={0,0,0};
2078 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2079 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2080 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2081 OPENAL_SetVolume(channels[firestartsound], 256);
2082 OPENAL_SetPaused(channels[firestartsound], false);
2083 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2085 if(Button()&&!oldbutton&&selected==0){
2087 extern SDL_Rect **resolutions;
2088 bool isCustomResolution = true;
2090 for (int i = 0; (!found) && (resolutions[i]); i++)
2092 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2093 isCustomResolution = false;
2095 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2098 if (resolutions[i] != NULL)
2100 newscreenwidth = (int) resolutions[i]->w;
2101 newscreenheight = (int) resolutions[i]->h;
2103 else if (isCustomResolution)
2105 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2107 newscreenwidth = (int) resolutions[0]->w;
2108 newscreenheight = (int) resolutions[0]->h;
2112 newscreenwidth = screenwidth;
2113 newscreenheight = screenheight;
2118 newscreenwidth = (int) resolutions[0]->w;
2119 newscreenheight = (int) resolutions[0]->h;
2127 newscreenwidth = (int) resolutions[0]->w;
2128 newscreenheight = (int) resolutions[0]->h;
2133 if(Button()&&!oldbutton&&selected==1){
2135 if(newdetail>2)newdetail=0;
2137 if(Button()&&!oldbutton&&selected==2){
2139 if(bloodtoggle>2)bloodtoggle=0;
2141 if(Button()&&!oldbutton&&selected==3){
2143 if(difficulty>2)difficulty=0;
2145 if(Button()&&!oldbutton&&selected==4){
2146 ismotionblur=1-ismotionblur;
2148 if(Button()&&!oldbutton&&selected==5){
2151 if(Button()&&!oldbutton&&selected==6){
2152 musictoggle=1-musictoggle;
2155 OPENAL_SetPaused(channels[music1], true);
2156 OPENAL_SetPaused(channels[stream_music2], true);
2157 OPENAL_SetPaused(channels[stream_music3], true);
2160 oldmusicvolume[i]=0;
2166 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2167 OPENAL_SetPaused(channels[stream_music3], false);
2168 OPENAL_SetVolume(channels[stream_music3], 256);
2171 if(Button()&&!oldbutton&&selected==9){
2172 invertmouse=1-invertmouse;
2174 if(Button()&&!oldbutton&&selected==10){
2175 usermousesensitivity+=.2;
2176 if(usermousesensitivity>2)usermousesensitivity=.2;
2178 if(Button()&&!oldbutton&&selected==11){
2180 if(volume>1.0001f)volume=0;
2181 OPENAL_SetSFXMasterVolume((int)(volume*255));
2183 if(Button()&&!oldbutton&&selected==7){
2184 /*float gLoc[3]={0,0,0};
2185 float vel[3]={0,0,0};
2186 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2187 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2188 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2189 OPENAL_SetVolume(channels[firestartsound], 256);
2190 OPENAL_SetPaused(channels[firestartsound], false);
2191 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2204 if(Button()&&!oldbutton&&selected==8){
2205 float gLoc[3]={0,0,0};
2206 float vel[3]={0,0,0};
2207 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2208 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2209 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2210 OPENAL_SetVolume(channels[fireendsound], 256);
2211 OPENAL_SetPaused(channels[fireendsound], false);
2212 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2220 if(newdetail>2)newdetail=detail;
2221 if(newdetail<0)newdetail=detail;
2222 if(newscreenwidth<0)newscreenwidth=screenwidth;
2223 if(newscreenheight<0)newscreenheight=screenheight;
2226 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2227 opstream << "Screenwidth:\n";
2228 opstream << newscreenwidth;
2229 opstream << "\nScreenheight:\n";
2230 opstream << newscreenheight;
2231 opstream << "\nMouse sensitivity:\n";
2232 opstream << usermousesensitivity;
2233 opstream << "\nBlur(0,1):\n";
2234 opstream << ismotionblur;
2235 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2236 opstream << newdetail;
2237 opstream << "\nFloating jump:\n";
2238 opstream << floatjump;
2239 opstream << "\nMouse jump:\n";
2240 opstream << mousejump;
2241 opstream << "\nAmbient sound:\n";
2242 opstream << ambientsound;
2243 opstream << "\nBlood (0,1,2):\n";
2244 opstream << bloodtoggle;
2245 opstream << "\nAuto slomo:\n";
2246 opstream << autoslomo;
2247 opstream << "\nFoliage:\n";
2248 opstream << foliage;
2249 opstream << "\nMusic:\n";
2250 opstream << musictoggle;
2251 opstream << "\nTrilinear:\n";
2252 opstream << trilinear;
2253 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2255 opstream << "\nInvert mouse:\n";
2256 opstream << invertmouse;
2257 opstream << "\nGamespeed:\n";
2258 if(oldgamespeed==0)oldgamespeed=1;
2259 opstream << oldgamespeed;
2260 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2261 opstream << difficulty;
2262 opstream << "\nDamage effects(blackout, doublevision):\n";
2263 opstream << damageeffects;
2264 opstream << "\nText:\n";
2265 opstream << texttoggle;
2266 opstream << "\nDebug:\n";
2267 opstream << debugmode;
2268 opstream << "\nVBL Sync:\n";
2269 opstream << vblsync;
2270 opstream << "\nShow Points:\n";
2271 opstream << showpoints;
2272 opstream << "\nAlways Blur:\n";
2273 opstream << alwaysblur;
2274 opstream << "\nImmediate mode (turn on on G5):\n";
2275 opstream << immediate;
2276 opstream << "\nVelocity blur:\n";
2277 opstream << velocityblur;
2278 opstream << "\nVolume:\n";
2280 opstream << "\nForward key:\n";
2281 opstream << KeyToChar(forwardkey);
2282 opstream << "\nBack key:\n";
2283 opstream << KeyToChar(backkey);
2284 opstream << "\nLeft key:\n";
2285 opstream << KeyToChar(leftkey);
2286 opstream << "\nRight key:\n";
2287 opstream << KeyToChar(rightkey);
2288 opstream << "\nJump key:\n";
2289 opstream << KeyToChar(jumpkey);
2290 opstream << "\nCrouch key:\n";
2291 opstream << KeyToChar(crouchkey);
2292 opstream << "\nDraw key:\n";
2293 opstream << KeyToChar(drawkey);
2294 opstream << "\nThrow key:\n";
2295 opstream << KeyToChar(throwkey);
2296 opstream << "\nAttack key:\n";
2297 opstream << KeyToChar(attackkey);
2298 opstream << "\nChat key:\n";
2299 opstream << KeyToChar(chatkey);
2300 opstream << "\nDamage bar:\n";
2301 opstream << showdamagebar;
2304 if(mainmenu==3&&gameon)mainmenu=2;
2305 if(mainmenu==3&&!gameon)mainmenu=1;
2307 if(Button())oldbutton=1;
2311 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2312 float gLoc[3]={0,0,0};
2313 float vel[3]={0,0,0};
2314 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2315 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2316 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2317 OPENAL_SetVolume(channels[firestartsound], 256);
2318 OPENAL_SetPaused(channels[firestartsound], false);
2319 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2321 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2329 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2331 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2332 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2333 float gLoc[3]={0,0,0};
2334 float vel[3]={0,0,0};
2335 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2336 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2337 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2338 OPENAL_SetVolume(channels[fireendsound], 256);
2339 OPENAL_SetPaused(channels[fireendsound], false);
2340 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2344 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2345 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2349 if(keyselect==0)forwardkey=keynum;
2350 if(keyselect==1)backkey=keynum;
2351 if(keyselect==2)leftkey=keynum;
2352 if(keyselect==3)rightkey=keynum;
2353 if(keyselect==4)crouchkey=keynum;
2354 if(keyselect==5)jumpkey=keynum;
2355 if(keyselect==6)drawkey=keynum;
2356 if(keyselect==7)throwkey=keynum;
2357 if(keyselect==8)attackkey=keynum;
2362 if(Button()&&!oldbutton&&selected==9){
2363 float gLoc[3]={0,0,0};
2364 float vel[3]={0,0,0};
2365 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2366 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2367 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2368 OPENAL_SetVolume(channels[fireendsound], 256);
2369 OPENAL_SetPaused(channels[fireendsound], false);
2370 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2380 if(newdetail>2)newdetail=detail;
2381 if(newdetail<0)newdetail=detail;
2382 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2383 if(newscreenwidth<0)newscreenwidth=screenwidth;
2384 if(newscreenheight>3000)newscreenheight=screenheight;
2385 if(newscreenheight<0)newscreenheight=screenheight;
2392 accountcampaignchoicesmade[accountactive]=0;
2393 accountcampaignscore[accountactive]=0;
2394 accountcampaigntime[accountactive]=0;
2398 if(Button()&&!oldbutton&&selected==1){
2399 float gLoc[3]={0,0,0};
2400 float vel[3]={0,0,0};
2401 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2402 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2403 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2404 OPENAL_SetVolume(channels[firestartsound], 256);
2405 OPENAL_SetPaused(channels[firestartsound], false);
2406 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2419 if(firstload)TickOnceAfter();
2420 if(!firstload)LoadStuff();
2427 OPENAL_SetPaused(channels[stream_music3], true);
2429 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2430 float gLoc[3]={0,0,0};
2431 float vel[3]={0,0,0};
2432 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2433 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2434 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2435 OPENAL_SetVolume(channels[firestartsound], 256);
2436 OPENAL_SetPaused(channels[firestartsound], false);
2437 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2450 if(firstload)TickOnceAfter();
2451 if(!firstload)LoadStuff();
2467 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2468 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2472 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2477 OPENAL_SetPaused(channels[stream_music3], true);
2479 if(Button()&&!oldbutton&&selected==4){
2480 float gLoc[3]={0,0,0};
2481 float vel[3]={0,0,0};
2482 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2483 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2484 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2485 OPENAL_SetVolume(channels[fireendsound], 256);
2486 OPENAL_SetPaused(channels[fireendsound], false);
2487 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2495 if(mainmenu==5&&gameon)mainmenu=2;
2496 if(mainmenu==5&&!gameon)mainmenu=1;
2498 if(Button()&&!oldbutton&&selected==5){
2499 float gLoc[3]={0,0,0};
2500 float vel[3]={0,0,0};
2501 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2502 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2503 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2504 OPENAL_SetVolume(channels[fireendsound], 256);
2505 OPENAL_SetPaused(channels[fireendsound], false);
2506 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2516 if(Button()&&!oldbutton&&selected==3){
2517 float gLoc[3]={0,0,0};
2518 float vel[3]={0,0,0};
2519 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2520 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2521 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2522 OPENAL_SetVolume(channels[firestartsound], 256);
2523 OPENAL_SetPaused(channels[firestartsound], false);
2524 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2534 if(Button()&&!oldbutton&&selected==2){
2535 float gLoc[3]={0,0,0};
2536 float vel[3]={0,0,0};
2537 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2538 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2539 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2540 OPENAL_SetVolume(channels[firestartsound], 256);
2541 OPENAL_SetPaused(channels[firestartsound], false);
2542 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2552 if(Button())oldbutton=1;
2556 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2557 float gLoc[3]={0,0,0};
2558 float vel[3]={0,0,0};
2559 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2560 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2561 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2562 OPENAL_SetVolume(channels[firestartsound], 256);
2563 OPENAL_SetPaused(channels[firestartsound], false);
2564 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2576 targetlevel=selected;
2577 if(firstload)TickOnceAfter();
2578 if(!firstload)LoadStuff();
2580 Loadlevel(selected);
2586 OPENAL_SetPaused(channels[stream_music3], true);
2588 if(Button()&&!oldbutton&&selected==numchallengelevels){
2589 float gLoc[3]={0,0,0};
2590 float vel[3]={0,0,0};
2591 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2592 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2593 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2594 OPENAL_SetVolume(channels[fireendsound], 256);
2595 OPENAL_SetPaused(channels[fireendsound], false);
2596 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2606 if(Button())oldbutton=1;
2610 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2611 float gLoc[3]={0,0,0};
2612 float vel[3]={0,0,0};
2613 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2614 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2615 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2616 OPENAL_SetVolume(channels[firestartsound], 256);
2617 OPENAL_SetPaused(channels[firestartsound], false);
2618 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2630 targetlevel=selected;
2631 if(firstload)TickOnceAfter();
2632 if(!firstload)LoadStuff();
2634 Loadlevel(selected);
2640 OPENAL_SetPaused(channels[stream_music3], true);
2642 if(Button()&&!oldbutton&&selected==numchallengelevels){
2643 float gLoc[3]={0,0,0};
2644 float vel[3]={0,0,0};
2645 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2646 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2647 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2648 OPENAL_SetVolume(channels[fireendsound], 256);
2649 OPENAL_SetPaused(channels[fireendsound], false);
2650 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2660 if(Button())oldbutton=1;
2665 if(Button()&&!oldbutton&&selected==3){
2666 float gLoc[3]={0,0,0};
2667 float vel[3]={0,0,0};
2668 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2669 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2670 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2671 OPENAL_SetVolume(channels[fireendsound], 256);
2672 OPENAL_SetPaused(channels[fireendsound], false);
2673 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2683 if(Button())oldbutton=1;
2688 if(Button()&&!oldbutton&&selected!=-1){
2689 float gLoc[3]={0,0,0};
2690 float vel[3]={0,0,0};
2691 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2692 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2693 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2694 OPENAL_SetVolume(channels[firestartsound], 256);
2695 OPENAL_SetPaused(channels[firestartsound], false);
2696 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2698 if(Button()&&!oldbutton&&selected==1){
2699 float gLoc[3]={0,0,0};
2700 float vel[3]={0,0,0};
2701 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2702 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2703 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2704 OPENAL_SetVolume(channels[fireendsound], 256);
2705 OPENAL_SetPaused(channels[fireendsound], false);
2706 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2714 for(i=accountactive;i<numaccounts-1;i++){
2715 accountdifficulty[i]=accountdifficulty[i+1];
2716 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2717 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2718 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2720 accountpoints[i]=accountpoints[i+1];
2722 accounthighscore[i][j]=accounthighscore[i+1][j];
2723 accountfasttime[i][j]=accountfasttime[i+1][j];
2726 accountunlocked[i][j]=accountunlocked[i+1][j];
2729 accountname[i][j]=accountname[i+1][j];
2731 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2732 accountprogress[i]=accountprogress[i+1];
2733 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2734 accountcampaignscore[i]=accountcampaignscore[i+1];
2735 accountcampaigntime[i]=accountcampaigntime[i+1];
2744 if(Button()&&!oldbutton&&selected==2){
2745 float gLoc[3]={0,0,0};
2746 float vel[3]={0,0,0};
2747 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2748 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2749 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2750 OPENAL_SetVolume(channels[fireendsound], 256);
2751 OPENAL_SetPaused(channels[fireendsound], false);
2752 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2762 if(Button())oldbutton=1;
2766 if(Button()&&!oldbutton&&selected!=-1){
2767 float gLoc[3]={0,0,0};
2768 float vel[3]={0,0,0};
2769 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2770 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2771 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2772 OPENAL_SetVolume(channels[firestartsound], 256);
2773 OPENAL_SetPaused(channels[firestartsound], false);
2774 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2776 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2779 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2780 accountactive=selected-1;
2788 if(Button()&&!oldbutton&&selected==numaccounts+1){
2789 float gLoc[3]={0,0,0};
2790 float vel[3]={0,0,0};
2791 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2792 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2793 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2794 OPENAL_SetVolume(channels[fireendsound], 256);
2795 OPENAL_SetPaused(channels[fireendsound], false);
2796 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2807 displaytext[0][j]=' ';
2813 if(Button())oldbutton=1;
2817 if(Button()&&!oldbutton&&selected!=-1){
2818 float gLoc[3]={0,0,0};
2819 float vel[3]={0,0,0};
2820 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2821 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2822 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2823 OPENAL_SetVolume(channels[firestartsound], 256);
2824 OPENAL_SetPaused(channels[firestartsound], false);
2825 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2827 if(selected==0)accountdifficulty[accountactive]=0;
2828 if(selected==1)accountdifficulty[accountactive]=1;
2829 if(selected==2)accountdifficulty[accountactive]=2;
2840 if(Button())oldbutton=1;
2845 if(Button())oldbutton=1;
2848 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2851 if(newdetail>2)newdetail=detail;
2852 if(newdetail<0)newdetail=detail;
2853 if(newscreenwidth<0)newscreenwidth=screenwidth;
2854 if(newscreenheight<0)newscreenheight=screenheight;
2856 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2857 opstream << "Screenwidth:\n";
2858 opstream << newscreenwidth;
2859 opstream << "\nScreenheight:\n";
2860 opstream << newscreenheight;
2861 opstream << "\nMouse sensitivity:\n";
2862 opstream << usermousesensitivity;
2863 opstream << "\nBlur(0,1):\n";
2864 opstream << ismotionblur;
2865 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2866 opstream << newdetail;
2867 opstream << "\nFloating jump:\n";
2868 opstream << floatjump;
2869 opstream << "\nMouse jump:\n";
2870 opstream << mousejump;
2871 opstream << "\nAmbient sound:\n";
2872 opstream << ambientsound;
2873 opstream << "\nBlood (0,1,2):\n";
2874 opstream << bloodtoggle;
2875 opstream << "\nAuto slomo:\n";
2876 opstream << autoslomo;
2877 opstream << "\nFoliage:\n";
2878 opstream << foliage;
2879 opstream << "\nMusic:\n";
2880 opstream << musictoggle;
2881 opstream << "\nTrilinear:\n";
2882 opstream << trilinear;
2883 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2885 opstream << "\nInvert mouse:\n";
2886 opstream << invertmouse;
2887 opstream << "\nGamespeed:\n";
2888 if(oldgamespeed==0)oldgamespeed=1;
2889 opstream << oldgamespeed;
2890 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2891 opstream << difficulty;
2892 opstream << "\nDamage effects(blackout, doublevision):\n";
2893 opstream << damageeffects;
2894 opstream << "\nText:\n";
2895 opstream << texttoggle;
2896 opstream << "\nDebug:\n";
2897 opstream << debugmode;
2898 opstream << "\nVBL Sync:\n";
2899 opstream << vblsync;
2900 opstream << "\nShow Points:\n";
2901 opstream << showpoints;
2902 opstream << "\nAlways Blur:\n";
2903 opstream << alwaysblur;
2904 opstream << "\nImmediate mode (turn on on G5):\n";
2905 opstream << immediate;
2906 opstream << "\nVelocity blur:\n";
2907 opstream << velocityblur;
2908 opstream << "\nVolume:\n";
2910 opstream << "\nForward key:\n";
2911 opstream << KeyToChar(forwardkey);
2912 opstream << "\nBack key:\n";
2913 opstream << KeyToChar(backkey);
2914 opstream << "\nLeft key:\n";
2915 opstream << KeyToChar(leftkey);
2916 opstream << "\nRight key:\n";
2917 opstream << KeyToChar(rightkey);
2918 opstream << "\nJump key:\n";
2919 opstream << KeyToChar(jumpkey);
2920 opstream << "\nCrouch key:\n";
2921 opstream << KeyToChar(crouchkey);
2922 opstream << "\nDraw key:\n";
2923 opstream << KeyToChar(drawkey);
2924 opstream << "\nThrow key:\n";
2925 opstream << KeyToChar(throwkey);
2926 opstream << "\nAttack key:\n";
2927 opstream << KeyToChar(attackkey);
2928 opstream << "\nChat key:\n";
2929 opstream << KeyToChar(chatkey);
2930 opstream << "\nDamage bar:\n";
2931 opstream << showdamagebar;
2936 if(mainmenu==1||mainmenu==2){
2937 if(loaddistrib>4)transition+=multiplier/8;
2945 OPENAL_SetFrequency(channels[stream_music3], 22050);
2949 if(IsKeyDown(theKeyMap, i)){
2950 togglekeydelay[i]+=multiplier;
2951 if(togglekeydelay[i]>.4){
2953 togglekeydelay[i]=.36;
2956 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
2957 for(j=255;j>=displayselected+1;j--){
2958 displaytext[0][j]=displaytext[0][j-1];
2960 displaytext[0][displayselected]=KeyToSingleChar(i);
2961 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
2965 if(i==MAC_DELETE_KEY&&displayselected!=0){
2966 for(j=displayselected-1;j<255;j++){
2967 displaytext[0][j]=displaytext[0][j+1];
2969 displaytext[0][255]=' ';
2973 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
2976 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
2979 if(i==MAC_RETURN_KEY&&entername){
2980 if(displaychars[0]){
2982 strcpy(accountname[numaccounts-1],displaytext[0]);
2983 accountactive=numaccounts-1;
2984 accountdifficulty[accountactive]=1;
2985 accountprogress[accountactive]=0;
2986 accountpoints[accountactive]=0;
2987 accountcampaigntime[accountactive]=0;
2988 accountcampaignscore[accountactive]=0;
2989 accountcampaignfasttime[accountactive]=0;
2990 accountcampaignhighscore[accountactive]=0;
2992 accounthighscore[accountactive][j]=0;
2993 accountfasttime[accountactive][j]=0;
2996 accountunlocked[accountactive][j]=0;
2998 accountcampaignchoicesmade[accountactive]=0;
3001 displaytext[0][j]=' ';
3015 float gLoc[3]={0,0,0};
3016 float vel[3]={0,0,0};
3017 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3018 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3019 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3020 OPENAL_SetVolume(channels[firestartsound], 256);
3021 OPENAL_SetPaused(channels[firestartsound], false);
3022 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3025 displaytext[0][j]=' ';
3033 if(i==MAC_RETURN_KEY&&mainmenu==13){
3034 if(displaychars[0]){
3035 sprintf (registrationname, "%s", displaytext[0]);
3036 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3046 float gLoc[3]={0,0,0};
3047 float vel[3]={0,0,0};
3048 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3049 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3050 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3051 OPENAL_SetVolume(channels[firestartsound], 256);
3052 OPENAL_SetPaused(channels[firestartsound], false);
3053 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3056 displaytext[0][j]=' ';
3067 togglekeydelay[i]=0;
3071 displayblinkdelay-=multiplier;
3072 if(displayblinkdelay<=0){
3073 displayblinkdelay=.3;
3074 displayblink=1-displayblink;
3080 if(hostile==1)hostiletime+=multiplier;
3082 if(!winfreeze)leveltime+=multiplier;
3083 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3090 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3092 chattogglekeydown=1;
3093 togglekey[chatkey]=1;
3094 togglekeydelay[chatkey]=-20;
3097 if(!IsKeyDown(theKeyMap, chatkey)){
3098 chattogglekeydown=0;
3103 if(IsKeyDown(theKeyMap, i)){
3104 togglekeydelay[i]+=multiplier;
3105 if(togglekeydelay[i]>.4){
3107 togglekeydelay[i]=.36;
3110 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3111 for(j=255;j>=displayselected+1;j--){
3112 displaytext[0][j]=displaytext[0][j-1];
3114 displaytext[0][displayselected]=KeyToSingleChar(i);
3115 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3119 if(i==MAC_DELETE_KEY&&displayselected!=0){
3120 for(j=displayselected-1;j<255;j++){
3121 displaytext[0][j]=displaytext[0][j+1];
3123 displaytext[0][255]=' ';
3127 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3130 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3133 if(i==MAC_RETURN_KEY){
3134 if(displaychars[0]){
3135 /*for(j=0;j<displaychars[0];j++){
3136 talkname[j]=displaytext[0][j];
3138 talkname[displaychars[0]]='\0';
3139 sprintf (chatname, "%s: %s",playerName,talkname);
3140 //NetworkSendInformation(chatname);
3143 displaytext[0][j]=' ';
3155 togglekeydelay[i]=0;
3159 displayblinkdelay-=multiplier;
3160 if(displayblinkdelay<=0){
3161 displayblinkdelay=.3;
3162 displayblink=1-displayblink;
3166 if(chatting)keyboardfrozen=1;
3168 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3171 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3173 freezetogglekeydown=1;
3176 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3177 freezetogglekeydown=0;
3180 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3182 if(!console)freeze=0;
3184 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3186 consoletogglekeydown=1;
3189 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3190 consoletogglekeydown=0;
3193 if(console)freeze=1;
3195 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3197 if(IsKeyDown(theKeyMap, i)){
3198 togglekeydelay[i]+=multiplier;
3199 if(togglekeydelay[i]>.4){
3201 togglekeydelay[i]=.36;
3204 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3205 for(j=255;j>=consoleselected+1;j--){
3206 consoletext[0][j]=consoletext[0][j-1];
3208 consoletext[0][consoleselected]=KeyToSingleChar(i);
3209 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3213 else if(i==MAC_ENTER_KEY){
3214 for(j=255;j>=consoleselected+1;j--){
3215 consoletext[0][j]=consoletext[0][j-1];
3217 consoletext[0][consoleselected]='\n';
3221 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3222 for(j=consoleselected-1;j<255;j++){
3223 consoletext[0][j]=consoletext[0][j+1];
3225 consoletext[0][255]=' ';
3229 if(i==MAC_ARROW_UP_KEY){
3230 if(archiveselected<14)archiveselected++;
3232 consolechars[0]=consolechars[archiveselected];
3233 consoletext[0][j]=consoletext[archiveselected][j];
3234 consoleselected=consolechars[0];
3237 if(i==MAC_ARROW_DOWN_KEY){
3238 if(archiveselected>0)archiveselected--;
3240 consolechars[0]=consolechars[archiveselected];
3241 consoletext[0][j]=consoletext[archiveselected][j];
3242 consoleselected=consolechars[0];
3245 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3248 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3251 if(i==MAC_RETURN_KEY){
3254 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3255 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3256 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3257 OPENAL_SetPaused(channels[consolesuccesssound], false);
3261 /*if(Compare(consoletext[0],"send ",0,4)){
3262 for(j=5;j<consolechars[0];j++){
3263 talkname[j-5]=consoletext[0][j];
3265 talkname[consolechars[0]-5]='\0';
3266 sprintf (chatname, "%s: %s",playerName,talkname);
3267 //NetworkSendInformation(chatname);
3270 if(Compare(consoletext[0],"name ",0,4)){
3272 numchars=consolechars[0]-5;
3273 if(numchars>32)numchars=32;
3274 for(j=5;j<numchars+5;j++){
3275 talkname[j-5]=consoletext[0][j];
3277 talkname[numchars]='\0';
3278 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3279 //NetworkSendInformation(chatname);
3280 sprintf (playerName, "%s",talkname);
3281 //NetworkSendName(playerName);
3284 if(Compare(consoletext[0],"map ",0,3)){
3296 for(j=4;j<consolechars[0];j++){
3297 mapname[j-4+11]=consoletext[0][j];
3299 mapname[consolechars[0]-4+11]='\0';
3305 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3307 unsigned char playerNameStr[32];
3308 char theIPAddress[256];
3310 NMUInt32 port = 25710;
3312 strcpy(playerName, "Client");
3313 GameC2PStr( playerName, playerNameStr );
3315 for(j=0;j<consolechars[0]-8;j++){
3316 theIPAddress[j]=consoletext[0][j+8];
3318 theIPAddress[consolechars[0]-8]='\0';
3320 sprintf( thePort, "%li", port );
3321 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3324 if(consolechars[0]>0){
3327 consoletext[k][j]=consoletext[k-1][j];
3329 consolechars[k]=consolechars[k-1];
3332 consoletext[0][j]=' ';
3334 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3335 else sprintf (consoletext[0], "Could not open connection");
3337 consolechars[0]=255;
3344 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3345 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3346 OPENAL_SetPaused(channels[consolesuccesssound], false);
3348 if(consolechars[0]>0){
3351 consoletext[k][j]=consoletext[k-1][j];
3353 consolechars[k]=consolechars[k-1];
3356 consoletext[0][j]=' ';
3358 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3360 consolechars[0]=255;
3366 if(Compare(consoletext[0],"host ",0,4)){
3367 unsigned char gameNameStr[32], playerNameStr[32];
3368 char gameName[32];//, playerName[32];
3376 strcpy(gameName, "Host's game");
3377 strcpy(playerName, "Host");
3378 GameC2PStr( gameName, gameNameStr );
3379 GameC2PStr( playerName, playerNameStr );
3381 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3384 if(consolechars[0]>0){
3387 consoletext[k][j]=consoletext[k-1][j];
3389 consolechars[k]=consolechars[k-1];
3392 consoletext[0][j]=' ';
3394 sprintf (consoletext[0], "Error #%d!!!",v);
3396 consolechars[0]=255;
3403 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3404 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3405 OPENAL_SetPaused(channels[consolesuccesssound], false);
3407 if(consolechars[0]>0){
3410 consoletext[k][j]=consoletext[k-1][j];
3412 consolechars[k]=consolechars[k-1];
3415 consoletext[0][j]=' ';
3417 sprintf (consoletext[0], "Game hosted");
3419 consolechars[0]=255;
3425 if(Compare(consoletext[0],"save ",0,4)){
3437 for(j=5;j<consolechars[0];j++){
3438 mapname[j-5+11]=consoletext[0][j];
3440 mapname[consolechars[0]-5+11]='\0';
3442 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3443 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3444 OPENAL_SetPaused(channels[consolesuccesssound], false);
3451 tfile=fopen( ConvertFileName(mapname), "wb" );
3452 fpackf(tfile, "Bi", mapvers);
3453 //fpackf(tfile, "Bi", indemo);
3454 fpackf(tfile, "Bi", maptype);
3455 fpackf(tfile, "Bi", hostile);
3456 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3457 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3458 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3459 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);
3460 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3461 for(j=0;j<player[0].num_weapons;j++){
3462 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3465 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3466 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3467 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3468 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3470 fpackf(tfile, "Bi", player[0].numclothes);
3472 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3474 fpackf(tfile, "Bi", numdialogues);
3476 for(k=0;k<numdialogues;k++){
3477 fpackf(tfile, "Bi", numdialogueboxes[k]);
3478 fpackf(tfile, "Bi", dialoguetype[k]);
3480 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3481 fpackf(tfile, "Bf", participantrotation[k][l]);
3483 if(numdialogueboxes)
3484 for(l=0;l<numdialogueboxes[k];l++){
3485 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3486 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3487 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3488 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3489 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3491 templength=strlen(dialoguetext[k][l]);
3492 fpackf(tfile, "Bi",(templength));
3493 for(m=0;m<templength;m++){
3494 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3495 if(dialoguetext[k][l][m]=='\0')break;
3498 templength=strlen(dialoguename[k][l]);
3499 fpackf(tfile, "Bi",templength);
3500 for(m=0;m<templength;m++){
3501 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3502 if(dialoguename[k][l][m]=='\0')break;
3505 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3506 fpackf(tfile, "Bi", participantfocus[k][l]);
3507 fpackf(tfile, "Bi", participantaction[k][l]);
3510 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3512 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3516 if(player[0].numclothes)
3517 for(k=0;k<player[0].numclothes;k++){
3518 templength=strlen(player[0].clothes[k]);
3519 fpackf(tfile, "Bi", templength);
3520 for(l=0;l<templength;l++)
3521 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3522 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3525 fpackf(tfile, "Bi", environment);
3527 fpackf(tfile, "Bi", objects.numobjects);
3529 if(objects.numobjects)
3530 for(k=0;k<objects.numobjects;k++){
3531 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]);
3534 fpackf(tfile, "Bi", numhotspots);
3536 for(i=0;i<numhotspots;i++){
3537 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3538 templength=strlen(hotspottext[i]);
3539 fpackf(tfile, "Bi",templength);
3540 for(l=0;l<templength;l++)
3541 fpackf(tfile, "Bb", hotspottext[i][l]);
3544 fpackf(tfile, "Bi", numplayers);
3545 if(numplayers>1&&numplayers<maxplayers)
3546 for(j=1;j<numplayers;j++){
3547 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);
3548 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3549 for(k=0;k<player[j].num_weapons;k++){
3550 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3552 if(player[j].numwaypoints<30){
3553 fpackf(tfile, "Bi", player[j].numwaypoints);
3554 for(k=0;k<player[j].numwaypoints;k++){
3555 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3556 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3557 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3558 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3560 fpackf(tfile, "Bi", player[j].waypoint);
3563 player[j].numwaypoints=0;
3564 player[j].waypoint=0;
3565 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3568 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3569 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3570 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3571 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3573 if(player[j].creature==wolftype){
3574 headprop=player[j].proportionhead.x/1.1;
3575 bodyprop=player[j].proportionbody.x/1.1;
3576 armprop=player[j].proportionarms.x/1.1;
3577 legprop=player[j].proportionlegs.x/1.1;
3580 if(player[j].creature==rabbittype){
3581 headprop=player[j].proportionhead.x/1.2;
3582 bodyprop=player[j].proportionbody.x/1.05;
3583 armprop=player[j].proportionarms.x/1.00;
3584 legprop=player[j].proportionlegs.x/1.1;
3587 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3591 fpackf(tfile, "Bi", player[j].numclothes);
3592 if(player[j].numclothes)
3593 for(k=0;k<player[j].numclothes;k++){
3595 templength=strlen(player[j].clothes[k]);
3596 fpackf(tfile, "Bi", templength);
3597 for(l=0;l<templength;l++)
3598 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3599 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3603 fpackf(tfile, "Bi", numpathpoints);
3605 for(j=0;j<numpathpoints;j++){
3606 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3607 for(k=0;k<numpathpointconnect[j];k++){
3608 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3612 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3620 tfile=fopen( mapname, "wb" );
3621 fwrite( &mapvers, 1, sizeof(int), tfile );
3622 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3623 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3624 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3625 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3626 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3627 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3628 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3629 for(j=0;j<player[0].num_weapons;j++){
3630 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3633 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3634 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3635 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3636 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3637 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3638 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3639 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3640 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3641 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3642 fwrite( &player[0].power, 1, sizeof(int), tfile );
3643 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3645 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3646 if(player[0].numclothes)
3647 for(k=0;k<player[0].numclothes;k++){
3649 templength=strlen(player[0].clothes[k]);
3650 fwrite( &templength,1,sizeof(int),tfile);
3651 for(l=0;l<templength;l++)
3652 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3653 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3654 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3655 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3658 fwrite( &environment, 1, sizeof(int), tfile );
3660 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3662 for(k=0;k<objects.numobjects;k++){
3663 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3664 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3665 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3666 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3667 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3668 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3669 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3672 fwrite( &numplayers, 1, sizeof(int), tfile );
3673 if(numplayers>1&&numplayers<maxplayers)
3674 for(j=1;j<numplayers;j++){
3675 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3676 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3677 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3678 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3679 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3680 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3681 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3682 for(k=0;k<player[j].num_weapons;k++){
3683 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3685 if(player[j].numwaypoints<30){
3686 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3687 for(k=0;k<player[j].numwaypoints;k++){
3688 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3689 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3690 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3692 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3693 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3696 player[j].numwaypoints=0;
3697 player[j].waypoint=0;
3698 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3699 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3700 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3702 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3703 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3704 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3705 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3706 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3707 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3708 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3709 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3710 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3711 fwrite( &player[j].power, 1, sizeof(int), tfile );
3712 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3714 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3715 if(player[j].numclothes)
3716 for(k=0;k<player[j].numclothes;k++){
3718 templength=strlen(player[j].clothes[k]);
3719 fwrite( &templength,1,sizeof(int),tfile);
3720 for(l=0;l<templength;l++)
3721 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3722 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3723 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3724 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3727 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3729 for(j=0;j<numpathpoints;j++){
3730 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3731 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3732 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3733 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3734 for(k=0;k<numpathpointconnect[j];k++){
3735 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3739 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3740 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3741 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3743 fwrite( &mapradius, 1, sizeof(float), tfile );
3749 if(Compare(consoletext[0],"save ",0,4)){
3761 for(j=5;j<consolechars[0];j++){
3762 mapname[j-5+11]=consoletext[0][j];
3764 mapname[consolechars[0]-5+11]='\0';
3766 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3767 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3768 OPENAL_SetPaused(channels[consolesuccesssound], false);
3771 tfile=fopen( mapname, "wb" );
3772 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
3773 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3774 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3775 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3776 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3777 for(j=0;j<player[0].num_weapons;j++){
3778 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3780 fwrite( &environment, 1, sizeof(int), tfile );
3782 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3783 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
3784 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
3785 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
3786 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
3788 fwrite( &numplayers, 1, sizeof(int), tfile );
3789 if(numplayers>1&&numplayers<maxplayers)
3790 for(j=1;j<numplayers;j++){
3791 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
3792 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3793 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3794 for(k=0;k<player[j].num_weapons;k++){
3795 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3797 if(player[j].numwaypoints<30){
3798 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3799 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
3800 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3801 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3804 player[j].numwaypoints=0;
3805 player[j].waypoint=0;
3806 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3807 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3808 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3811 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3813 for(j=0;j<numpathpoints;j++){
3814 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
3815 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3816 for(k=0;k<numpathpointconnect[j];k++){
3817 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3823 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
3824 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
3827 /*if(Compare(consoletext[0],"Pants ",0,5)){
3828 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
3829 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
3833 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
3834 for(j=6;j<consolechars[0];j++){
3835 mapname[j-6]=consoletext[0][j];
3838 tintr=atof(mapname);
3843 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
3844 for(j=6;j<consolechars[0];j++){
3845 mapname[j-6]=consoletext[0][j];
3848 player[0].speedmult=atof(mapname);
3853 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
3854 for(j=9;j<consolechars[0];j++){
3855 mapname[j-9]=consoletext[0][j];
3858 player[0].power=atof(mapname);
3863 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
3864 for(j=13;j<consolechars[0];j++){
3865 mapname[j-13]=consoletext[0][j];
3868 viewdistance=atof(mapname)*100;
3873 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
3874 for(j=10;j<consolechars[0];j++){
3875 mapname[j-10]=consoletext[0][j];
3878 fadestart=atof(mapname);
3883 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
3884 for(j=6;j<consolechars[0];j++){
3885 mapname[j-6]=consoletext[0][j];
3888 player[0].power=atof(mapname);
3893 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
3894 for(j=6;j<consolechars[0];j++){
3895 mapname[j-6]=consoletext[0][j];
3898 slomospeed=atof(mapname);
3905 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
3906 for(j=8;j<consolechars[0];j++){
3907 mapname[j-8]=consoletext[0][j];
3910 slomofreq=atoi(mapname);
3915 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
3916 for(j=5;j<consolechars[0];j++){
3917 mapname[j-5]=consoletext[0][j];
3920 player[0].scale=atof(mapname)*.2;
3925 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
3927 float closestdist=-1;
3930 for(i=1;i<numplayers;i++){
3931 distance=findDistancefast(&player[i].coords,&player[0].coords);
3932 if(closestdist==-1||distance<closestdist){
3933 closestdist=distance;
3938 for(j=9;j<consolechars[0];j++){
3939 mapname[j-9]=consoletext[0][j];
3942 player[closest].scale=atof(mapname)*.2;
3947 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
3952 float closestdist=-1;
3955 for(i=1;i<numplayers;i++){
3956 distance=findDistancefast(&player[i].coords,&player[0].coords);
3957 if(closestdist==-1||distance<closestdist){
3958 closestdist=distance;
3966 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3967 mapname[j-startpoint]=consoletext[0][j];
3969 if(consoletext[0][j]=='\0')alldone=1;
3971 mapname[j-startpoint]='\0';
3973 headprop=atof(mapname);
3977 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3978 mapname[j-startpoint]=consoletext[0][j];
3980 if(consoletext[0][j]=='\0')alldone=1;
3982 mapname[j-startpoint]='\0';
3984 bodyprop=atof(mapname);
3988 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3989 mapname[j-startpoint]=consoletext[0][j];
3991 if(consoletext[0][j]=='\0')alldone=1;
3993 mapname[j-startpoint]='\0';
3995 armprop=atof(mapname);
3999 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4000 mapname[j-startpoint]=consoletext[0][j];
4002 if(consoletext[0][j]=='\0')alldone=1;
4004 mapname[j-startpoint]='\0';
4006 legprop=atof(mapname);
4008 if(player[closest].creature==wolftype){
4009 player[closest].proportionhead=1.1*headprop;
4010 player[closest].proportionbody=1.1*bodyprop;
4011 player[closest].proportionarms=1.1*armprop;
4012 player[closest].proportionlegs=1.1*legprop;
4015 if(player[closest].creature==rabbittype){
4016 player[closest].proportionhead=1.2*headprop;
4017 player[closest].proportionbody=1.05*bodyprop;
4018 player[closest].proportionarms=1.00*armprop;
4019 player[closest].proportionlegs=1.1*legprop;
4020 player[closest].proportionlegs.y=1.05*legprop;
4027 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4028 for(i=1;i<numplayers;i++){
4029 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4035 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4036 for(j=9;j<consolechars[0];j++){
4037 mapname[j-9]=consoletext[0][j];
4040 tutoriallevel=atoi(mapname);
4046 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4047 for(j=6;j<consolechars[0];j++){
4048 mapname[j-6]=consoletext[0][j];
4051 tintg=atof(mapname);
4056 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4057 for(j=6;j<consolechars[0];j++){
4058 mapname[j-6]=consoletext[0][j];
4061 tintb=atof(mapname);
4066 if(Compare(consoletext[0],"hostile ",0,7)){
4067 for(j=8;j<consolechars[0];j++){
4068 mapname[j-8]=consoletext[0][j];
4071 hostile=atoi(mapname);
4077 if(Compare(consoletext[0],"type active ",0,11)){
4078 editoractive=typeactive;
4083 if(Compare(consoletext[0],"indemo ",0,6)){
4085 hotspot[numhotspots]=player[0].coords;
4086 hotspotsize[numhotspots]=0;
4087 hotspottype[numhotspots]=-111;
4089 strcpy(hotspottext[numhotspots],"mapname");
4095 if(Compare(consoletext[0],"notindemo ",0,9)){
4102 if(Compare(consoletext[0],"type sitting ",0,12)){
4103 editoractive=typesitting;
4108 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4109 editoractive=typesittingwall;
4114 if(Compare(consoletext[0],"type sleeping ",0,13)){
4115 editoractive=typesleeping;
4119 if(Compare(consoletext[0],"type dead1 ",0,10)){
4120 editoractive=typedead1;
4124 if(Compare(consoletext[0],"type dead2 ",0,10)){
4125 editoractive=typedead2;
4129 if(Compare(consoletext[0],"type dead3 ",0,10)){
4130 editoractive=typedead3;
4133 if(Compare(consoletext[0],"type dead4 ",0,10)){
4134 editoractive=typedead4;
4139 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4140 editorpathtype=wpkeepwalking;
4145 if(Compare(consoletext[0],"path pause ",0,10)){
4146 editorpathtype=wppause;
4151 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4152 maptype=mapkilleveryone;
4157 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4158 maptype=mapgosomewhere;
4163 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4164 maptype=mapkillsomeone;
4170 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4171 maptype=mapkillmost;
4177 if(Compare(consoletext[0],"hs ",0,2)){
4181 hotspot[numhotspots]=player[0].coords;
4186 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4187 mapname[j-startpoint]=consoletext[0][j];
4189 if(consoletext[0][j]=='\0')alldone=1;
4191 mapname[j-startpoint]='\0';
4193 hotspotsize[numhotspots]=atof(mapname);
4197 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4198 mapname[j-startpoint]=consoletext[0][j];
4200 if(consoletext[0][j]=='\0')alldone=1;
4202 mapname[j-startpoint]='\0';
4204 hotspottype[numhotspots]=atoi(mapname);
4208 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4209 mapname[j-startpoint]=consoletext[0][j];
4211 if(consoletext[0][j]=='\0')alldone=1;
4213 mapname[j-startpoint]='\n';
4214 mapname[j-startpoint+1]='\0';
4216 strcpy(hotspottext[numhotspots],mapname);
4223 if(Compare(consoletext[0],"dialogue ",0,8)){
4230 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4231 mapname[j-startpoint]=consoletext[0][j];
4233 if(consoletext[0][j]=='\0')alldone=1;
4235 mapname[j-startpoint]='\0';
4238 dialoguetype[numdialogues]=atoi(mapname);
4256 for(j=startpoint;j<consolechars[0];j++){
4257 mapname[j-startpoint+16]=consoletext[0][j];
4259 mapname[consolechars[0]-startpoint+16]='.';
4260 mapname[consolechars[0]-startpoint+17]='t';
4261 mapname[consolechars[0]-startpoint+18]='x';
4262 mapname[consolechars[0]-startpoint+19]='t';
4263 mapname[consolechars[0]-startpoint+20]='\0';
4265 for(j=0;j<max_dialoguelength;j++){
4267 dialoguetext[numdialogues][j][k]='\0';
4270 dialoguename[numdialogues][j][k]='\0';
4274 ifstream ipstream(ConvertFileName(mapname));
4275 ipstream.ignore(256,':');
4276 ipstream >> numdialogueboxes[numdialogues];
4277 for(i=0;i<numdialogueboxes[numdialogues];i++){
4278 ipstream.ignore(256,':');
4279 ipstream.ignore(256,':');
4280 ipstream.ignore(256,' ');
4281 ipstream >> dialogueboxlocation[numdialogues][i];
4282 ipstream.ignore(256,':');
4283 ipstream >> dialogueboxcolor[numdialogues][i][0];
4284 ipstream >> dialogueboxcolor[numdialogues][i][1];
4285 ipstream >> dialogueboxcolor[numdialogues][i][2];
4286 ipstream.ignore(256,':');
4287 ipstream.getline(dialoguename[numdialogues][i],64);
4288 ipstream.ignore(256,':');
4289 ipstream.ignore(256,' ');
4290 ipstream.getline(dialoguetext[numdialogues][i],128);
4292 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4294 ipstream.ignore(256,':');
4295 ipstream >> dialogueboxsound[numdialogues][i];
4298 for(i=0;i<numdialogueboxes[numdialogues];i++){
4299 for(j=0;j<numplayers;j++){
4300 participantfacing[numdialogues][i][j]=player[j].facing;
4307 whichdialogue=numdialogues;
4315 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4323 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4324 mapname[j-startpoint]=consoletext[0][j];
4326 if(consoletext[0][j]=='\0')alldone=1;
4328 mapname[j-startpoint]='\0';
4331 whichdi=atoi(mapname);
4349 for(j=startpoint;j<consolechars[0];j++){
4350 mapname[j-startpoint+16]=consoletext[0][j];
4352 mapname[consolechars[0]-startpoint+16]='.';
4353 mapname[consolechars[0]-startpoint+17]='t';
4354 mapname[consolechars[0]-startpoint+18]='x';
4355 mapname[consolechars[0]-startpoint+19]='t';
4356 mapname[consolechars[0]-startpoint+20]='\0';
4358 for(j=0;j<max_dialoguelength;j++){
4360 dialoguetext[whichdi][j][k]='\0';
4363 dialoguename[whichdi][j][k]='\0';
4367 ifstream ipstream(ConvertFileName(mapname));
4368 ipstream.ignore(256,':');
4369 ipstream >> numdialogueboxes[whichdi];
4370 for(i=0;i<numdialogueboxes[whichdi];i++){
4371 ipstream.ignore(256,':');
4372 ipstream.ignore(256,':');
4373 ipstream.ignore(256,' ');
4374 ipstream >> dialogueboxlocation[whichdi][i];
4375 ipstream.ignore(256,':');
4376 ipstream >> dialogueboxcolor[whichdi][i][0];
4377 ipstream >> dialogueboxcolor[whichdi][i][1];
4378 ipstream >> dialogueboxcolor[whichdi][i][2];
4379 ipstream.ignore(256,':');
4380 ipstream.getline(dialoguename[whichdi][i],64);
4381 ipstream.ignore(256,':');
4382 ipstream.ignore(256,' ');
4383 ipstream.getline(dialoguetext[whichdi][i],128);
4385 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4387 ipstream.ignore(256,':');
4388 ipstream >> dialogueboxsound[whichdi][i];
4396 if(Compare(consoletext[0],"fixtype ",0,7)){
4404 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4405 mapname[j-startpoint]=consoletext[0][j];
4407 if(consoletext[0][j]=='\0')alldone=1;
4409 mapname[j-startpoint]='\0';
4410 dialoguetype[0]=atoi(mapname);
4418 if(Compare(consoletext[0],"fixrotation ",0,11)){
4419 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4424 if(Compare(consoletext[0],"ddialogue ",0,9)){
4426 if(numdialogues<0)numdialogues=0;
4431 if(Compare(consoletext[0],"immobile ",0,8)){
4432 player[0].immobile=1;
4436 if(Compare(consoletext[0],"mobile ",0,6)){
4437 player[0].immobile=0;
4441 if(Compare(consoletext[0],"play ",0,4)){
4448 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4449 mapname[j-startpoint]=consoletext[0][j];
4451 if(consoletext[0][j]=='\0')alldone=1;
4453 mapname[j-startpoint]='\0';
4456 whichdialogue=atoi(mapname);
4458 if(numdialogues>whichdialogue){
4459 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4460 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4461 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4462 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4463 player[participantfocus[whichdialogue][i]].velocity=0;
4464 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4465 player[participantfocus[whichdialogue][i]].targetframe=0;
4473 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4477 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4478 temppos=temppos-viewer;
4479 Normalise(&temppos);
4489 whichsoundplay=rabbitchitter;
4490 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4491 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4492 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4493 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4494 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4495 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4496 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4497 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4498 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4499 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4500 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4501 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4502 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4503 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4504 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4505 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4506 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4507 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4508 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4509 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4510 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4511 OPENAL_SetVolume(channels[whichsoundplay], 256);
4512 OPENAL_SetPaused(channels[whichsoundplay], false);
4520 if(Compare(consoletext[0],"dhs ",0,3)){
4522 if(numhotspots<0)numhotspots=0;
4527 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4534 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4535 mapname[j-startpoint]=consoletext[0][j];
4537 if(consoletext[0][j]=='\0')alldone=1;
4539 mapname[j-startpoint]='\0';
4541 headprop=atof(mapname);
4545 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4546 mapname[j-startpoint]=consoletext[0][j];
4548 if(consoletext[0][j]=='\0')alldone=1;
4550 mapname[j-startpoint]='\0';
4552 bodyprop=atof(mapname);
4556 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4557 mapname[j-startpoint]=consoletext[0][j];
4559 if(consoletext[0][j]=='\0')alldone=1;
4561 mapname[j-startpoint]='\0';
4563 armprop=atof(mapname);
4567 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4568 mapname[j-startpoint]=consoletext[0][j];
4570 if(consoletext[0][j]=='\0')alldone=1;
4572 mapname[j-startpoint]='\0';
4574 legprop=atof(mapname);
4576 if(player[0].creature==wolftype){
4577 player[0].proportionhead=1.1*headprop;
4578 player[0].proportionbody=1.1*bodyprop;
4579 player[0].proportionarms=1.1*armprop;
4580 player[0].proportionlegs=1.1*legprop;
4583 if(player[0].creature==rabbittype){
4584 player[0].proportionhead=1.2*headprop;
4585 player[0].proportionbody=1.05*bodyprop;
4586 player[0].proportionarms=1.00*armprop;
4587 player[0].proportionlegs=1.1*legprop;
4588 player[0].proportionlegs.y=1.05*legprop;
4594 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4595 for(i=0;i<numplayers;i++){
4596 if(i>0)player[i].immobile=1;
4602 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4603 player[0].armorhead=1;
4604 player[0].armorhigh=1;
4605 player[0].armorlow=1;
4606 player[0].protectionhead=1;
4607 player[0].protectionhigh=1;
4608 player[0].protectionlow=1;
4609 player[0].metalhead=1;
4610 player[0].metalhigh=1;
4611 player[0].metallow=1;
4613 player[0].speedmult=1;
4616 if(player[0].creature==wolftype){
4617 player[0].proportionhead=1.1;
4618 player[0].proportionbody=1.1;
4619 player[0].proportionarms=1.1;
4620 player[0].proportionlegs=1.1;
4623 if(player[0].creature==rabbittype){
4624 player[0].proportionhead=1.2;
4625 player[0].proportionbody=1.05;
4626 player[0].proportionarms=1.00;
4627 player[0].proportionlegs=1.1;
4628 player[0].proportionlegs.y=1.05;
4631 player[0].numclothes=0;
4632 LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
4633 &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4635 editoractive=typeactive;
4636 player[0].immobile=0;
4643 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4649 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4650 mapname[j-startpoint]=consoletext[0][j];
4652 if(consoletext[0][j]=='\0')alldone=1;
4654 mapname[j-startpoint]='\0';
4656 tintr=atof(mapname);
4660 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4661 mapname[j-startpoint]=consoletext[0][j];
4663 if(consoletext[0][j]=='\0')alldone=1;
4665 mapname[j-startpoint]='\0';
4667 tintg=atof(mapname);
4671 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4672 mapname[j-startpoint]=consoletext[0][j];
4674 if(consoletext[0][j]=='\0')alldone=1;
4676 mapname[j-startpoint]='\0';
4678 tintb=atof(mapname);
4683 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4689 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4690 mapname[j-startpoint]=consoletext[0][j];
4692 if(consoletext[0][j]=='\0')alldone=1;
4694 mapname[j-startpoint]='\0';
4696 skyboxr=atof(mapname);
4700 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4701 mapname[j-startpoint]=consoletext[0][j];
4703 if(consoletext[0][j]=='\0')alldone=1;
4705 mapname[j-startpoint]='\0';
4707 skyboxg=atof(mapname);
4711 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4712 mapname[j-startpoint]=consoletext[0][j];
4714 if(consoletext[0][j]=='\0')alldone=1;
4716 mapname[j-startpoint]='\0';
4718 skyboxb=atof(mapname);
4720 skyboxlightr=skyboxr;
4721 skyboxlightg=skyboxg;
4722 skyboxlightb=skyboxb;
4726 //if(skyboxtexture){
4727 terrain.DoShadows();
4728 objects.DoShadows();
4730 else terrain.DoLighting();
4735 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
4741 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4742 mapname[j-startpoint]=consoletext[0][j];
4744 if(consoletext[0][j]=='\0')alldone=1;
4746 mapname[j-startpoint]='\0';
4748 skyboxlightr=atof(mapname);
4752 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4753 mapname[j-startpoint]=consoletext[0][j];
4755 if(consoletext[0][j]=='\0')alldone=1;
4757 mapname[j-startpoint]='\0';
4759 skyboxlightg=atof(mapname);
4763 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4764 mapname[j-startpoint]=consoletext[0][j];
4766 if(consoletext[0][j]=='\0')alldone=1;
4768 mapname[j-startpoint]='\0';
4770 skyboxlightb=atof(mapname);
4774 //if(skyboxtexture){
4775 terrain.DoShadows();
4776 objects.DoShadows();
4778 else terrain.DoLighting();
4783 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
4784 skyboxtexture=1-skyboxtexture;
4787 //if(skyboxtexture){
4788 terrain.DoShadows();
4789 objects.DoShadows();
4791 else terrain.DoLighting();
4796 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
4802 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4803 mapname[j-startpoint]=consoletext[0][j];
4805 if(consoletext[0][j]=='\0')alldone=1;
4807 mapname[j-startpoint]='\0';
4809 player[0].protectionhead=atof(mapname);
4813 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4814 mapname[j-startpoint]=consoletext[0][j];
4816 if(consoletext[0][j]=='\0')alldone=1;
4818 mapname[j-startpoint]='\0';
4820 player[0].protectionhigh=atof(mapname);
4824 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4825 mapname[j-startpoint]=consoletext[0][j];
4827 if(consoletext[0][j]=='\0')alldone=1;
4829 mapname[j-startpoint]='\0';
4831 player[0].protectionlow=atof(mapname);
4836 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
4842 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4843 mapname[j-startpoint]=consoletext[0][j];
4845 if(consoletext[0][j]=='\0')alldone=1;
4847 mapname[j-startpoint]='\0';
4849 player[0].armorhead=atof(mapname);
4853 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4854 mapname[j-startpoint]=consoletext[0][j];
4856 if(consoletext[0][j]=='\0')alldone=1;
4858 mapname[j-startpoint]='\0';
4860 player[0].armorhigh=atof(mapname);
4864 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4865 mapname[j-startpoint]=consoletext[0][j];
4867 if(consoletext[0][j]=='\0')alldone=1;
4869 mapname[j-startpoint]='\0';
4871 player[0].armorlow=atof(mapname);
4876 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
4877 for(i=0;i<numplayers;i++){
4878 player[i].protectionhead=1.0;
4879 player[i].protectionhigh=1.0;
4880 player[i].protectionlow=1.0;
4881 player[i].armorhead=1.0;
4882 player[i].armorhigh=1.0;
4883 player[i].armorlow=1.0;
4889 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
4891 float closestdist=-1;
4894 for(i=1;i<numplayers;i++){
4895 distance=findDistancefast(&player[i].coords,&player[0].coords);
4896 if(closestdist==-1||distance<closestdist){
4897 closestdist=distance;
4907 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4908 mapname[j-startpoint]=consoletext[0][j];
4910 if(consoletext[0][j]=='\0')alldone=1;
4912 mapname[j-startpoint]='\0';
4914 player[closest].protectionhead=atof(mapname);
4918 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4919 mapname[j-startpoint]=consoletext[0][j];
4921 if(consoletext[0][j]=='\0')alldone=1;
4923 mapname[j-startpoint]='\0';
4925 player[closest].protectionhigh=atof(mapname);
4929 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4930 mapname[j-startpoint]=consoletext[0][j];
4932 if(consoletext[0][j]=='\0')alldone=1;
4934 mapname[j-startpoint]='\0';
4936 player[closest].protectionlow=atof(mapname);
4941 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
4943 float closestdist=-1;
4946 for(i=1;i<numplayers;i++){
4947 distance=findDistancefast(&player[i].coords,&player[0].coords);
4948 if(closestdist==-1||distance<closestdist){
4949 closestdist=distance;
4958 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4959 mapname[j-startpoint]=consoletext[0][j];
4961 if(consoletext[0][j]=='\0')alldone=1;
4963 mapname[j-startpoint]='\0';
4965 player[closest].armorhead=atof(mapname);
4969 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4970 mapname[j-startpoint]=consoletext[0][j];
4972 if(consoletext[0][j]=='\0')alldone=1;
4974 mapname[j-startpoint]='\0';
4976 player[closest].armorhigh=atof(mapname);
4980 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4981 mapname[j-startpoint]=consoletext[0][j];
4983 if(consoletext[0][j]=='\0')alldone=1;
4985 mapname[j-startpoint]='\0';
4987 player[closest].armorlow=atof(mapname);
4993 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
4999 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5000 mapname[j-startpoint]=consoletext[0][j];
5002 if(consoletext[0][j]=='\0')alldone=1;
5004 mapname[j-startpoint]='\0';
5006 player[0].metalhead=atof(mapname);
5010 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5011 mapname[j-startpoint]=consoletext[0][j];
5013 if(consoletext[0][j]=='\0')alldone=1;
5015 mapname[j-startpoint]='\0';
5017 player[0].metalhigh=atof(mapname);
5021 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5022 mapname[j-startpoint]=consoletext[0][j];
5024 if(consoletext[0][j]=='\0')alldone=1;
5027 mapname[j-startpoint]='\0';
5029 player[0].metallow=atof(mapname);
5034 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5036 float closestdist=-1;
5039 for(i=1;i<numplayers;i++){
5040 distance=findDistancefast(&player[i].coords,&player[0].coords);
5041 if(closestdist==-1||distance<closestdist){
5042 closestdist=distance;
5046 player[closest].numclothes=0;
5047 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
5048 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5053 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5056 player[closest].numclothes=0;
5057 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
5058 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5062 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5078 for(j=8;j<consolechars[0];j++){
5079 mapname[j-8+15]=consoletext[0][j];
5081 mapname[consolechars[0]-8+15]='.';
5082 mapname[consolechars[0]-8+16]='p';
5083 mapname[consolechars[0]-8+17]='n';
5084 mapname[consolechars[0]-8+18]='g';
5085 mapname[consolechars[0]-8+19]='\0';
5087 //:Data:Textures:Pants.png
5089 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5090 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5091 strcpy(player[0].clothes[player[0].numclothes],mapname);
5092 player[0].clothestintr[player[0].numclothes]=tintr;
5093 player[0].clothestintg[player[0].numclothes]=tintg;
5094 player[0].clothestintb[player[0].numclothes]=tintb;
5095 player[0].numclothes++;
5101 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5102 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5107 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5108 cellophane=1-cellophane;
5111 for(i=0;i<numplayers;i++){
5112 player[i].proportionhead.z=0;
5113 player[i].proportionbody.z=0;
5114 player[i].proportionarms.z=0;
5115 player[i].proportionlegs.z=0;
5120 for(i=0;i<numplayers;i++){
5121 player[i].proportionhead.z=player[i].proportionhead.x;
5122 player[i].proportionbody.z=player[i].proportionbody.x;
5123 player[i].proportionarms.z=player[i].proportionarms.x;
5124 player[i].proportionlegs.z=player[i].proportionlegs.x;
5131 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5147 for(j=12;j<consolechars[0];j++){
5148 mapname[j-12+15]=consoletext[0][j];
5150 mapname[consolechars[0]-12+15]='.';
5151 mapname[consolechars[0]-12+16]='p';
5152 mapname[consolechars[0]-12+17]='n';
5153 mapname[consolechars[0]-12+18]='g';
5154 mapname[consolechars[0]-12+19]='\0';
5156 //:Data:Textures:Pants.png
5158 float closestdist=-1;
5161 for(i=1;i<numplayers;i++){
5162 distance=findDistancefast(&player[i].coords,&player[0].coords);
5163 if(closestdist==-1||distance<closestdist){
5164 closestdist=distance;
5169 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5170 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5171 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5172 player[closest].clothestintr[player[closest].numclothes]=tintr;
5173 player[closest].clothestintg[player[closest].numclothes]=tintg;
5174 player[closest].clothestintb[player[closest].numclothes]=tintb;
5175 player[closest].numclothes++;
5181 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5182 player[0].skeleton.id=0;
5183 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);
5184 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5185 player[0].creature=rabbittype;
5188 player[0].proportionhead=1.2;
5189 player[0].proportionbody=1.05;
5190 player[0].proportionarms=1.00;
5191 player[0].proportionlegs=1.1;
5192 player[0].proportionlegs.y=1.05;
5193 player[0].headless=0;
5195 player[0].damagetolerance=200;
5199 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5200 player[0].skeleton.id=0;
5201 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);
5202 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5203 player[0].creature=wolftype;
5205 player[0].proportionhead=1.1;
5206 player[0].proportionbody=1.1;
5207 player[0].proportionarms=1.1;
5208 player[0].proportionlegs=1.1;
5209 player[0].proportionlegs.y=1.1;
5210 player[0].scale=.23;
5212 player[0].damagetolerance=300;
5216 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5217 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5220 if(Compare(consoletext[0],"rambo ",0,5)){
5221 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5224 if(Compare(consoletext[0],"david ",0,5)){
5225 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5228 if(Compare(consoletext[0],"wolf ",0,4)){
5229 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5232 if(Compare(consoletext[0],"darkwolf ",0,8)){
5233 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5236 if(Compare(consoletext[0],"snowwolf ",0,8)){
5237 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5240 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5241 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5244 if(Compare(consoletext[0],"white ",0,5)){
5245 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5248 if(Compare(consoletext[0],"brown ",0,5)){
5249 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5252 if(Compare(consoletext[0],"black ",0,5)){
5253 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5256 if(consolechars[0]>0){
5259 consoletext[k][j]=consoletext[k-1][j];
5261 consolechars[k]=consolechars[k-1];
5264 consoletext[0][j]=' ';
5270 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5271 OPENAL_SetVolume(channels[consolefailsound], 256);
5272 OPENAL_SetPaused(channels[consolefailsound], false);
5281 togglekeydelay[i]=0;
5285 consoleblinkdelay-=multiplier;
5286 if(consoleblinkdelay<=0){
5287 consoleblinkdelay=.3;
5288 consoleblink=1-consoleblink;
5292 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5295 if(newdetail>2)newdetail=detail;
5296 if(newdetail<0)newdetail=detail;
5297 if(newscreenwidth<0)newscreenwidth=screenwidth;
5298 if(newscreenheight<0)newscreenheight=screenheight;
5300 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5301 opstream << "Screenwidth:\n";
5302 opstream << newscreenwidth;
5303 opstream << "\nScreenheight:\n";
5304 opstream << newscreenheight;
5305 opstream << "\nMouse sensitivity:\n";
5306 opstream << usermousesensitivity;
5307 opstream << "\nBlur(0,1):\n";
5308 opstream << ismotionblur;
5309 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5310 opstream << newdetail;
5311 opstream << "\nFloating jump:\n";
5312 opstream << floatjump;
5313 opstream << "\nMouse jump:\n";
5314 opstream << mousejump;
5315 opstream << "\nAmbient sound:\n";
5316 opstream << ambientsound;
5317 opstream << "\nBlood (0,1,2):\n";
5318 opstream << bloodtoggle;
5319 opstream << "\nAuto slomo:\n";
5320 opstream << autoslomo;
5321 opstream << "\nFoliage:\n";
5322 opstream << foliage;
5323 opstream << "\nMusic:\n";
5324 opstream << musictoggle;
5325 opstream << "\nTrilinear:\n";
5326 opstream << trilinear;
5327 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5329 opstream << "\nInvert mouse:\n";
5330 opstream << invertmouse;
5331 opstream << "\nGamespeed:\n";
5332 if(oldgamespeed==0)oldgamespeed=1;
5333 opstream << oldgamespeed;
5334 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5335 opstream << difficulty;
5336 opstream << "\nDamage effects(blackout, doublevision):\n";
5337 opstream << damageeffects;
5338 opstream << "\nText:\n";
5339 opstream << texttoggle;
5340 opstream << "\nDebug:\n";
5341 opstream << debugmode;
5342 opstream << "\nVBL Sync:\n";
5343 opstream << vblsync;
5344 opstream << "\nShow Points:\n";
5345 opstream << showpoints;
5346 opstream << "\nAlways Blur:\n";
5347 opstream << alwaysblur;
5348 opstream << "\nImmediate mode (turn on on G5):\n";
5349 opstream << immediate;
5350 opstream << "\nVelocity blur:\n";
5351 opstream << velocityblur;
5352 opstream << "\nVolume:\n";
5354 opstream << "\nForward key:\n";
5355 opstream << KeyToChar(forwardkey);
5356 opstream << "\nBack key:\n";
5357 opstream << KeyToChar(backkey);
5358 opstream << "\nLeft key:\n";
5359 opstream << KeyToChar(leftkey);
5360 opstream << "\nRight key:\n";
5361 opstream << KeyToChar(rightkey);
5362 opstream << "\nJump key:\n";
5363 opstream << KeyToChar(jumpkey);
5364 opstream << "\nCrouch key:\n";
5365 opstream << KeyToChar(crouchkey);
5366 opstream << "\nDraw key:\n";
5367 opstream << KeyToChar(drawkey);
5368 opstream << "\nThrow key:\n";
5369 opstream << KeyToChar(throwkey);
5370 opstream << "\nAttack key:\n";
5371 opstream << KeyToChar(attackkey);
5372 opstream << "\nChat key:\n";
5373 opstream << KeyToChar(chatkey);
5374 opstream << "\nDamage bar:\n";
5375 opstream << showdamagebar;
5380 static int oldwinfreeze;
5381 if(winfreeze&&!oldwinfreeze){
5382 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
5383 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5384 OPENAL_SetVolume(channels[consolesuccesssound], 256);
5385 OPENAL_SetPaused(channels[consolesuccesssound], false);
5387 if(winfreeze==0)oldwinfreeze=winfreeze;
5388 else oldwinfreeze++;
5390 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5391 if(winfreeze)winfreeze=0;
5394 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5400 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5403 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5405 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5407 static bool oldbuttondialogue;
5409 if(indialogue!=-1)talkdelay=1;
5410 talkdelay-=multiplier;
5413 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5414 for(i=0;i<numdialogues;i++){
5415 int realdialoguetype;
5417 if(dialoguetype[i]>49){
5418 realdialoguetype=dialoguetype[i]-50;
5421 else if(dialoguetype[i]>39){
5422 realdialoguetype=dialoguetype[i]-40;
5425 else if(dialoguetype[i]>29){
5426 realdialoguetype=dialoguetype[i]-30;
5429 else if(dialoguetype[i]>19){
5430 realdialoguetype=dialoguetype[i]-20;
5433 else if(dialoguetype[i]>9){
5434 realdialoguetype=dialoguetype[i]-10;
5438 realdialoguetype=dialoguetype[i];
5441 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5442 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5444 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5445 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5446 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5447 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5448 player[participantfocus[whichdialogue][j]].velocity=0;
5449 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5450 player[participantfocus[whichdialogue][j]].targetframe=0;
5455 dialoguegonethrough[i]++;
5456 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5457 static float gLoc[3];
5458 static float vel[3];
5460 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5461 temppos=temppos-viewer;
5462 Normalise(&temppos);
5467 gLoc[2]=temppos.z;vel[0]=0;
5471 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5472 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5473 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5474 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5475 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5476 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5477 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5478 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5479 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5480 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5481 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5482 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5483 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5484 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5485 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5486 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5487 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5488 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5489 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5490 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5491 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5492 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5493 OPENAL_SetVolume(channels[whichsoundplay], 256);
5494 OPENAL_SetPaused(channels[whichsoundplay], false);
5496 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5501 windvar+=multiplier;
5502 smoketex+=multiplier;
5503 tutorialstagetime+=multiplier;
5505 static float hotspotvisual[40];
5509 for(i=0;i<numhotspots;i++)
5510 hotspotvisual[i]-=multiplier/320;
5512 for(i=0;i<numhotspots;i++){
5513 //if(hotspottype[i]<=10)
5514 while(hotspotvisual[i]<0){
5516 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5517 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5518 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5519 hotspotsprite+=hotspot[i];
5520 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5521 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5525 for(i=0;i<numhotspots;i++){
5526 if(hotspottype[i]<=10&&hotspottype[i]>0){
5527 hotspot[i]=player[hotspottype[i]].coords;
5533 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5536 if(tutorialstage<=1){
5541 if(tutorialstage==1){
5544 if(tutorialstage==2){
5547 if(tutorialstage==3){
5548 tutorialmaxtime=600;
5550 if(tutorialstage==4){
5551 tutorialmaxtime=1000;
5553 if(tutorialstage==5){
5554 tutorialmaxtime=600;
5556 if(tutorialstage==6){
5557 tutorialmaxtime=600;
5559 if(tutorialstage==7){
5560 tutorialmaxtime=600;
5562 if(tutorialstage==8){
5563 tutorialmaxtime=600;
5565 if(tutorialstage==9){
5566 tutorialmaxtime=600;
5568 if(tutorialstage==10){
5571 if(tutorialstage==11){
5572 tutorialmaxtime=1000;
5574 if(tutorialstage==12){
5575 tutorialmaxtime=1000;
5577 if(tutorialstage==13){
5580 if(tutorialstage==14){
5592 player[1].coords=(temp+temp2)/2;
5596 gLoc[0]=player[1].coords.x;
5597 gLoc[1]=player[1].coords.y;
5598 gLoc[2]=player[1].coords.z;
5602 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5603 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5604 OPENAL_SetVolume(channels[fireendsound], 256);
5605 OPENAL_SetPaused(channels[fireendsound], false);
5607 for(i=0;i<player[1].skeleton.num_joints;i++){
5609 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5610 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5611 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;
5612 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5613 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5618 if(tutorialstage==15){
5619 tutorialmaxtime=500;
5621 if(tutorialstage==16){
5622 tutorialmaxtime=500;
5624 if(tutorialstage==17){
5625 tutorialmaxtime=500;
5627 if(tutorialstage==18){
5628 tutorialmaxtime=500;
5630 if(tutorialstage==19){
5632 //tutorialmaxtime=500;
5634 if(tutorialstage==20){
5635 tutorialmaxtime=500;
5637 if(tutorialstage==21){
5638 tutorialmaxtime=500;
5645 if(tutorialstage==22){
5646 tutorialmaxtime=500;
5648 if(tutorialstage==23){
5649 tutorialmaxtime=500;
5651 if(tutorialstage==24){
5652 tutorialmaxtime=500;
5654 if(tutorialstage==25){
5655 tutorialmaxtime=500;
5657 if(tutorialstage==26){
5660 if(tutorialstage==27){
5664 player[1].aitype=attacktypecutoff;
5666 if(tutorialstage==28){
5667 tutorialmaxtime=400;
5669 if(tutorialstage==29){
5670 tutorialmaxtime=400;
5671 player[0].escapednum=0;
5673 if(tutorialstage==30){
5677 player[1].aitype=passivetype;
5679 if(tutorialstage==31){
5682 if(tutorialstage==32){
5685 if(tutorialstage==33){
5686 tutorialmaxtime=400;
5689 player[1].aitype=attacktypecutoff;
5691 if(tutorialstage==34){
5692 tutorialmaxtime=400;
5694 if(tutorialstage==35){
5695 tutorialmaxtime=400;
5697 if(tutorialstage==36){
5701 player[1].aitype=passivetype;
5703 if(tutorialstage==37){
5709 player[1].aitype=attacktypecutoff;
5711 if(tutorialstage==38){
5715 player[1].aitype=passivetype;
5717 if(tutorialstage==39){
5728 weapons.owner[weapons.numweapons]=-1;
5729 weapons.type[weapons.numweapons]=knife;
5730 weapons.damage[weapons.numweapons]=0;
5731 weapons.mass[weapons.numweapons]=1;
5732 weapons.tipmass[weapons.numweapons]=1.2;
5733 weapons.length[weapons.numweapons]=.25;
5734 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5735 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5737 weapons.velocity[weapons.numweapons]=0.1;
5738 weapons.tipvelocity[weapons.numweapons]=0.1;
5739 weapons.missed[weapons.numweapons]=1;
5740 weapons.hitsomething[weapons.numweapons]=0;
5741 weapons.freetime[weapons.numweapons]=0;
5742 weapons.firstfree[weapons.numweapons]=1;
5743 weapons.physics[weapons.numweapons]=1;
5745 weapons.numweapons++;
5747 if(tutorialstage==40){
5748 tutorialmaxtime=300;
5750 if(tutorialstage==41){
5751 tutorialmaxtime=300;
5753 if(tutorialstage==42){
5756 if(tutorialstage==43){
5757 tutorialmaxtime=300;
5759 if(tutorialstage==44){
5761 player[0].weaponactive=-1;
5762 player[0].num_weapons=0;
5763 player[1].weaponactive=0;
5764 player[1].num_weapons=1;
5765 player[1].weaponids[0]=0;
5769 player[1].aitype=attacktypecutoff;
5771 tutorialmaxtime=300;
5773 if(tutorialstage==45){
5775 player[0].weaponactive=-1;
5776 player[0].num_weapons=0;
5777 player[1].weaponactive=0;
5778 player[1].num_weapons=1;
5779 player[1].weaponids[0]=0;
5781 tutorialmaxtime=300;
5783 if(tutorialstage==46){
5785 player[0].weaponactive=-1;
5786 player[0].num_weapons=0;
5787 player[1].weaponactive=0;
5788 player[1].num_weapons=1;
5789 player[1].weaponids[0]=0;
5791 weapons.type[0]=sword;
5793 tutorialmaxtime=300;
5796 if(tutorialstage==47){
5808 weapons.owner[weapons.numweapons]=-1;
5809 weapons.type[weapons.numweapons]=sword;
5810 weapons.damage[weapons.numweapons]=0;
5811 weapons.mass[weapons.numweapons]=1;
5812 weapons.tipmass[weapons.numweapons]=1.2;
5813 weapons.length[weapons.numweapons]=.25;
5814 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5815 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5817 weapons.velocity[weapons.numweapons]=0.1;
5818 weapons.tipvelocity[weapons.numweapons]=0.1;
5819 weapons.missed[weapons.numweapons]=1;
5820 weapons.hitsomething[weapons.numweapons]=0;
5821 weapons.freetime[weapons.numweapons]=0;
5822 weapons.firstfree[weapons.numweapons]=1;
5823 weapons.physics[weapons.numweapons]=1;
5827 player[0].weaponactive=0;
5828 player[0].num_weapons=1;
5829 player[0].weaponids[0]=1;
5830 player[1].weaponactive=0;
5831 player[1].num_weapons=1;
5832 player[1].weaponids[0]=0;
5834 weapons.numweapons++;
5836 if(tutorialstage==48){
5839 player[1].aitype=passivetype;
5845 player[0].weaponactive=0;
5846 player[0].num_weapons=1;
5847 player[0].weaponids[0]=1;
5848 player[1].weaponactive=0;
5849 player[1].num_weapons=1;
5850 player[1].weaponids[0]=0;
5852 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
5853 else weapons.type[0]=staff;
5855 weapons.numweapons++;
5857 if(tutorialstage==49){
5860 player[1].aitype=passivetype;
5862 tutorialmaxtime=200;
5864 weapons.position[1]=1000;
5865 weapons.tippoint[1]=1000;
5867 weapons.numweapons=1;
5869 player[1].weaponactive=-1;
5870 player[1].num_weapons=0;
5871 player[0].weaponactive=0;
5872 player[0].num_weapons=1;
5873 player[0].weaponids[0]=0;
5875 weapons.type[0]=knife;
5877 weapons.numweapons++;
5879 if(tutorialstage==50){
5885 gLoc[0]=player[1].coords.x;
5886 gLoc[1]=player[1].coords.y;
5887 gLoc[2]=player[1].coords.z;
5891 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5892 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5893 OPENAL_SetVolume(channels[fireendsound], 256);
5894 OPENAL_SetPaused(channels[fireendsound], false);
5896 for(i=0;i<player[1].skeleton.num_joints;i++){
5898 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5899 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5900 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;
5901 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5902 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5906 player[1].num_weapons=0;
5907 player[1].weaponstuck=-1;
5908 player[1].weaponactive=-1;
5910 weapons.numweapons=0;
5912 weapons.owner[0]=-1;
5913 weapons.velocity[0]=0.1;
5914 weapons.tipvelocity[0]=-0.1;
5915 weapons.missed[0]=1;
5916 weapons.hitsomething[0]=0;
5917 weapons.freetime[0]=0;
5918 weapons.firstfree[0]=1;
5919 weapons.physics[0]=1;
5921 if(tutorialstage==51){
5922 tutorialmaxtime=80000;
5924 if(tutorialstage<=51)tutorialstagetime=0;
5928 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
5929 if(tutorialstage==3){
5930 if(deltah||deltav)tutorialsuccess+=multiplier;
5932 if(tutorialstage==4){
5933 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
5935 if(tutorialstage==5){
5936 if(player[0].jumpkeydown)tutorialsuccess=1;
5938 if(tutorialstage==6){
5939 if(player[0].isCrouch())tutorialsuccess=1;
5941 if(tutorialstage==7){
5942 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
5944 if(tutorialstage==8){
5945 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
5947 if(tutorialstage==9){
5948 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
5950 if(tutorialstage==11){
5951 if(player[0].isWallJump())tutorialsuccess=1;
5953 if(tutorialstage==12){
5954 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
5956 if(tutorialstage==15){
5957 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
5959 if(tutorialstage==16){
5960 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
5962 if(tutorialstage==17){
5963 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
5965 if(tutorialstage==18){
5966 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
5968 if(tutorialstage==19){
5969 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
5971 if(tutorialstage==20){
5972 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
5974 if(tutorialstage==21){
5975 if(bonus==cannon)tutorialsuccess=1;
5977 if(tutorialstage==22){
5978 if(bonus==spinecrusher)tutorialsuccess=1;
5980 if(tutorialstage==23){
5981 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
5983 if(tutorialstage==24){
5984 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
5986 if(tutorialstage==25){
5987 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
5989 if(tutorialstage==28){
5990 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
5992 if(tutorialstage==29){
5993 if(player[0].escapednum==2){
5997 player[1].aitype=passivetype;
6000 if(tutorialstage==33){
6001 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6003 if(tutorialstage==34){
6004 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6006 if(tutorialstage==35){
6007 if(animation[player[0].targetanimation].attack==reversal){
6011 player[1].aitype=passivetype;
6014 if(tutorialstage==40){
6015 if(player[0].num_weapons>0)tutorialsuccess=1;
6017 if(tutorialstage==41){
6018 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6020 if(tutorialstage==43){
6021 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6023 if(tutorialstage==44){
6024 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6026 if(tutorialstage==45){
6027 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6029 if(tutorialstage==46){
6030 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6032 if(tutorialstage==49){
6033 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6035 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6038 if(tutorialstagetime==tutorialmaxtime-3){
6039 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6040 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6041 OPENAL_SetPaused(channels[consolesuccesssound], false);
6044 if(tutorialsuccess>=1){
6045 if(tutorialstage==34||tutorialstage==35)
6046 tutorialstagetime=tutorialmaxtime-1;
6051 if(tutorialstage<14||tutorialstage>=50){
6052 player[1].coords.y=300;
6053 player[1].velocity=0;
6057 if(tutoriallevel!=1){
6058 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6059 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6060 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6061 OPENAL_SetPaused(channels[consolesuccesssound], false);
6066 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6067 OPENAL_SetVolume(channels[fireendsound], 256);
6068 OPENAL_SetPaused(channels[fireendsound], false);
6071 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6072 else bonusnum[bonus]+=0.15;
6073 if(tutoriallevel)bonusvalue=0;
6074 bonusvalue/=bonusnum[bonus];
6075 bonustotal+=bonusvalue;
6077 bonustime+=multiplier;
6079 if(environment==snowyenvironment){
6080 precipdelay-=multiplier;
6081 while(precipdelay<0){
6083 if(!detail)precipdelay+=.04;
6084 XYZ footvel,footpoint;
6087 footpoint=viewer+viewerfacing*6;
6088 footpoint.y+=((float)abs(Random()%1200))/100-6;
6089 footpoint.x+=((float)abs(Random()%1200))/100-6;
6090 footpoint.z+=((float)abs(Random()%1200))/100-6;
6091 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6094 for(k=0;k<numplayers;k++){
6095 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6096 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6098 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){
6099 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6100 else if(player[k].rotation>player[k].targetrotation){
6101 player[k].rotation-=multiplier*player[k].turnspeed;
6103 else if(player[k].rotation<player[k].targetrotation){
6104 player[k].rotation+=multiplier*player[k].turnspeed;
6109 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))){
6110 player[k].turnspeed*=2;
6111 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6112 else if(player[k].rotation>player[k].targetrotation){
6113 player[k].rotation-=multiplier*player[k].turnspeed;
6115 else if(player[k].rotation<player[k].targetrotation){
6116 player[k].rotation+=multiplier*player[k].turnspeed;
6118 player[k].turnspeed/=2;
6121 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6122 player[k].turnspeed*=4;
6123 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6124 else if(player[k].rotation>player[k].targetrotation){
6125 player[k].rotation-=multiplier*player[k].turnspeed;
6127 else if(player[k].rotation<player[k].targetrotation){
6128 player[k].rotation+=multiplier*player[k].turnspeed;
6130 player[k].turnspeed/=4;
6133 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6134 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6136 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6137 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6140 if(player[k].collide<-.3)player[k].collide=-.3;
6141 if(player[k].collide>1)player[k].collide=1;
6142 player[k].collide-=multiplier*30;
6144 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6145 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6147 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6148 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6149 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6150 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6151 lowpoint=player[k].coords;
6152 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6153 else lowpoint.y+=1.3;
6154 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){
6155 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6157 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6158 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6160 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6161 flatfacing=lowpoint-player[k].coords;
6162 player[k].coords=lowpoint;
6163 player[k].coords.y-=1.3;
6164 player[k].collide=1;
6166 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6167 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6168 tempcoords1=lowpoint;
6169 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6170 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6172 player[k].targetanimation=walljumpleftanim;
6173 player[k].targetframe=0;
6176 gLoc[0]=player[k].coords.x;
6177 gLoc[1]=player[k].coords.y;
6178 gLoc[2]=player[k].coords.z;
6182 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6183 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6184 OPENAL_SetVolume(channels[movewhooshsound], 256);
6185 OPENAL_SetPaused(channels[movewhooshsound], false);
6186 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6188 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6189 player[k].rotation=-asin(0-lowpointtarget.x);
6190 player[k].rotation*=360/6.28;
6191 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6192 player[k].targetrotation=player[k].rotation;
6193 player[k].lowrotation=player[k].rotation;
6194 if(k==0)numwallflipped++;
6198 lowpoint=tempcoords1;
6199 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6200 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6201 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6203 player[k].targetanimation=walljumprightanim;
6204 player[k].targetframe=0;
6207 gLoc[0]=player[k].coords.x;
6208 gLoc[1]=player[k].coords.y;
6209 gLoc[2]=player[k].coords.z;
6213 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6214 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6215 OPENAL_SetVolume(channels[movewhooshsound], 256);
6216 OPENAL_SetPaused(channels[movewhooshsound], false);
6217 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6219 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6220 player[k].rotation=-asin(0-lowpointtarget.x);
6221 player[k].rotation*=360/6.28;
6222 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6223 player[k].targetrotation=player[k].rotation;
6224 player[k].lowrotation=player[k].rotation;
6225 if(k==0)numwallflipped++;
6229 lowpoint=tempcoords1;
6230 lowpointtarget=lowpoint+player[k].facing*2;
6231 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6232 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6234 player[k].targetanimation=walljumpbackanim;
6235 player[k].targetframe=0;
6238 gLoc[0]=player[k].coords.x;
6239 gLoc[1]=player[k].coords.y;
6240 gLoc[2]=player[k].coords.z;
6244 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6245 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6246 OPENAL_SetVolume(channels[movewhooshsound], 256);
6247 OPENAL_SetPaused(channels[movewhooshsound], false);
6248 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6250 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6251 player[k].rotation=-asin(0-lowpointtarget.x);
6252 player[k].rotation*=360/6.28;
6253 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6254 player[k].targetrotation=player[k].rotation;
6255 player[k].lowrotation=player[k].rotation;
6256 if(k==0)numwallflipped++;
6260 lowpoint=tempcoords1;
6261 lowpointtarget=lowpoint-player[k].facing*2;
6262 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6263 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6265 player[k].targetanimation=walljumpfrontanim;
6266 player[k].targetframe=0;
6269 gLoc[0]=player[k].coords.x;
6270 gLoc[1]=player[k].coords.y;
6271 gLoc[2]=player[k].coords.z;
6275 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6276 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6277 OPENAL_SetVolume(channels[movewhooshsound], 256);
6278 OPENAL_SetPaused(channels[movewhooshsound], false);
6279 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6281 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6282 player[k].rotation=-asin(0-lowpointtarget.x);
6283 player[k].rotation*=360/6.28;
6284 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6285 player[k].rotation+=180;
6286 player[k].targetrotation=player[k].rotation;
6287 player[k].lowrotation=player[k].rotation;
6288 if(k==0)numwallflipped++;
6296 else if(objects.type[i]==rocktype){
6297 lowpoint2=player[k].coords;
6298 lowpoint=player[k].coords;
6300 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6301 player[k].coords=colpoint;
6302 player[k].collide=1;
6305 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6306 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6308 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6310 player[k].targetframe=0;
6311 player[k].onterrain=1;
6313 if(player[k].id==0){
6314 OPENAL_SetPaused(channels[whooshsound], true);
6315 OPENAL_SetVolume(channels[whooshsound], 0);
6318 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6319 if(player[k].isFlip())player[k].jumppower=-4;
6320 player[k].targetanimation=player[k].getLanding();
6323 gLoc[0]=player[k].coords.x;
6324 gLoc[1]=player[k].coords.y;
6325 gLoc[2]=player[k].coords.z;
6326 vel[0]=player[k].velocity.x;
6327 vel[1]=player[k].velocity.y;
6328 vel[2]=player[k].velocity.z;
6329 PlaySoundEx( landsound, samp[landsound], NULL, true);
6330 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6331 OPENAL_SetVolume(channels[landsound], 128);
6332 OPENAL_SetPaused(channels[landsound], false);
6334 envsound[numenvsounds]=player[k].coords;
6335 envsoundvol[numenvsounds]=16;
6336 envsoundlife[numenvsounds]=.4;
6345 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6346 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6347 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6348 lowpoint=player[k].coords;
6350 if(objects.type[i]!=rocktype)
6351 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6352 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6353 player[k].coords=lowpoint;
6354 player[k].coords.y-=1.35;
6355 player[k].collide=1;
6357 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)){
6358 lowpoint=player[k].coords;
6359 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6360 lowpoint=player[k].coords;
6364 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6365 lowpointtarget=lowpoint+facing*1.4;
6366 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6368 lowpoint=player[k].coords;
6370 lowpointtarget=lowpoint+facing*1.4;
6372 lowpointtarget2=lowpointtarget;
6374 lowpointtarget3=lowpointtarget;
6376 lowpointtarget4=lowpointtarget;
6378 lowpointtarget5=lowpointtarget;
6380 lowpointtarget6=lowpointtarget;
6382 lowpointtarget7=lowpoint;
6384 lowpointtarget2.x+=.1;
6386 lowpointtarget3.z+=.1;
6388 lowpointtarget4.x-=.1;
6390 lowpointtarget5.z-=.1;
6392 lowpointtarget6.y+=45/13;
6393 lowpointtarget6+=facing*.6;
6394 lowpointtarget7.y+=90/13;
6395 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6396 if(objects.friction[i]>.5)
6399 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6400 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6401 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6402 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)
6404 lowpoint=player[k].coords;
6405 lowpoint.y+=(float)j/13;
6406 lowpointtarget=lowpoint+facing*1.4;
6407 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6411 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6414 if(j<=25&&player[k].targetanimation==jumpdownanim){
6417 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6418 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6419 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)*/){
6420 lowpoint=player[k].coords;
6421 lowpoint.y+=(float)j/13;
6422 lowpointtarget=lowpoint+facing*1.3;
6423 flatfacing=player[k].coords;
6424 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6425 player[k].coords.y=lowpointtarget.y-.07;
6426 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6428 if(j>10||!player[k].isRun()){
6429 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6430 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6434 gLoc[0]=player[k].coords.x;
6435 gLoc[1]=player[k].coords.y;
6436 gLoc[2]=player[k].coords.z;
6437 vel[0]=player[k].velocity.x;
6438 vel[1]=player[k].velocity.y;
6439 vel[2]=player[k].velocity.z;
6440 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6441 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6442 OPENAL_SetVolume(channels[jumpsound], 128);
6443 OPENAL_SetPaused(channels[jumpsound], false);
6445 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6446 player[k].rotation=-asin(0-lowpointtarget.x);
6447 player[k].rotation*=360/6.28;
6448 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6449 player[k].targetrotation=player[k].rotation;
6450 player[k].lowrotation=player[k].rotation;
6452 //player[k].velocity=lowpointtarget*.03;
6453 player[k].velocity=0;
6455 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6456 //player[k].currentanimation=climbanim;
6457 player[k].targetanimation=climbanim;
6458 player[k].jumppower=0;
6459 player[k].jumpclimb=1;
6461 player[k].transspeed=6;
6464 //player[k].currentframe=1;
6465 player[k].targetframe=1;
6467 //player[k].currentframe=0;
6468 player[k].targetframe=0;
6469 //player[k].currentanimation=hanganim;
6470 player[k].targetanimation=hanganim;
6471 player[k].jumppower=0;
6485 if(player[k].collide<=0){
6486 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()){
6487 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)){
6488 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6489 player[k].targetanimation=jumpdownanim;
6490 player[k].targetframe=0;
6495 gLoc[0]=player[k].coords.x;
6496 gLoc[1]=player[k].coords.y;
6497 gLoc[2]=player[k].coords.z;
6498 vel[0]=player[k].velocity.x;
6499 vel[1]=player[k].velocity.y;
6500 vel[2]=player[k].velocity.z;
6502 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6503 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6504 OPENAL_SetVolume(channels[whooshsound], 128);
6505 OPENAL_SetPaused(channels[whooshsound], false);
6508 player[k].velocity.y+=gravity;
6513 player[k].realoldcoords=player[k].coords;
6516 static XYZ oldviewer;
6519 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6520 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6521 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6522 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6523 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6524 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6525 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6526 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6530 player[0].forwardkeydown=0;
6531 player[0].leftkeydown=0;
6532 player[0].backkeydown=0;
6533 player[0].rightkeydown=0;
6534 player[0].jumpkeydown=0;
6535 player[0].crouchkeydown=0;
6536 player[0].drawkeydown=0;
6537 player[0].throwkeydown=0;
6540 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6543 static bool endkeydown;
6550 facing=DoRotation(facing,-rotation2,0,0);
6551 facing=DoRotation(facing,0,0-rotation,0);
6556 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6558 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6559 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6560 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6561 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6562 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6563 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6564 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)
6565 ||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)
6566 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6568 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6569 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6570 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6571 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6572 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6573 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6574 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6575 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6576 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6577 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6578 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6580 participantfocus[whichdialogue][indialogue]=whichend;
6581 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6582 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6585 participantfocus[whichdialogue][indialogue]=-1;
6587 if(player[participantfocus[whichdialogue][indialogue]].dead){
6592 dialoguecamera[whichdialogue][indialogue]=viewer;
6593 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6594 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6596 if(indialogue<numdialogueboxes[whichdialogue]){
6597 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6598 static float gLoc[3];
6599 static float vel[3];
6601 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6602 temppos=temppos-viewer;
6603 Normalise(&temppos);
6608 gLoc[2]=temppos.z;vel[0]=0;
6612 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6613 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6614 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6615 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6616 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6617 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6618 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6619 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6620 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6621 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6622 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6623 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6624 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6625 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6626 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6627 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6628 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6629 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6630 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6631 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6632 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6633 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6634 OPENAL_SetVolume(channels[whichsoundplay], 256);
6635 OPENAL_SetPaused(channels[whichsoundplay], false);
6639 for(j=0;j<numplayers;j++){
6640 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6645 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)
6646 ||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)
6649 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6650 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6651 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6652 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6653 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6654 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6655 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6656 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6657 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6658 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6659 participantfacing[whichdialogue][indialogue][whichend]=facing;
6661 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)
6662 &&!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)
6663 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6666 if(indialogue>=numdialogueboxes[whichdialogue]){
6673 OPENAL_SetPaused(channels[whooshsound], true);
6674 viewer=dialoguecamera[whichdialogue][indialogue];
6675 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
6676 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
6678 rotation=dialoguecamerarotation[whichdialogue][indialogue];
6679 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
6680 if(dialoguetime>0.5)
6681 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)
6682 ||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)
6683 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
6686 if(indialogue<numdialogueboxes[whichdialogue]){
6687 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6688 static float gLoc[3];
6689 static float vel[3];
6691 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6692 temppos=temppos-viewer;
6693 Normalise(&temppos);
6698 gLoc[2]=temppos.z;vel[0]=0;
6702 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6703 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6704 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6705 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6706 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6707 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6708 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6709 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6710 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6711 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6712 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6713 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6714 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6715 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6716 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6717 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6718 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6719 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6720 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6721 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6722 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
6723 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
6724 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6725 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6726 OPENAL_SetVolume(channels[whichsoundplay], 256);
6727 OPENAL_SetPaused(channels[whichsoundplay], false);
6729 if(dialogueboxsound[whichdialogue][indialogue]==-5){
6730 hotspot[numhotspots]=player[0].coords;
6731 hotspotsize[numhotspots]=10;
6732 hotspottype[numhotspots]=-1;
6736 if(dialogueboxsound[whichdialogue][indialogue]==-6){
6740 if(player[participantfocus[whichdialogue][indialogue]].dead){
6748 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)
6749 &&!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)
6750 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6753 if(indialogue>=numdialogueboxes[whichdialogue]){
6757 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
6760 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
6763 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
6765 for(i=1;i<numplayers;i++){
6766 player[i].aitype = attacktypecutoff;
6773 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
6774 else oldbuttondialogue=1;
6776 static float keyrefreshdelay=0,bigrefreshdelay=0;
6780 /*keyrefreshdelay-=multiplier;
6781 bigrefreshdelay-=multiplier;
6783 if(keyrefreshdelay<=0){
6784 static int concat[4];
6786 concat[0]=player[0].forwardkeydown;
6787 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
6788 concat[0]=concat[0]*2+player[0].rightkeydown;
6789 concat[0]=concat[0]*2+player[0].leftkeydown;
6790 concat[0]=concat[0]*2+player[0].backkeydown;
6791 concat[0]=concat[0]*2+player[0].jumpkeydown;
6792 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
6793 concat[0]=concat[0]*2+player[0].crouchkeydown;
6795 concat[1]=player[0].crouchtogglekeydown;
6796 concat[1]=concat[1]*2+player[0].drawkeydown;
6797 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
6798 concat[1]=concat[1]*2+player[0].throwkeydown;
6799 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
6800 concat[1]=concat[1]*2+player[0].attackkeydown;
6802 //concat[2]=(char)((int)(rotation/2)%180);
6804 //concat[3]=(char)((int)(rotation2/2)%180);
6806 chatname[0]=concat[0]-128;
6807 chatname[1]=concat[1]-128;
6808 //chatname[2]=concat[2]-128;
6809 //chatname[3]=concat[3]-128;
6811 memcpy(chatname+temppoint,&rotation,sizeof(float));
6812 temppoint+=sizeof(float);
6813 memcpy(chatname+temppoint,&rotation2,sizeof(float));
6814 temppoint+=sizeof(float);
6816 chatname[temppoint]='\0';
6818 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
6819 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
6820 //keyrefreshdelay=.01;
6821 keyrefreshdelay=.03;
6824 if(bigrefreshdelay<=0){
6827 memcpy(chatname+temppoint,&i,sizeof(int));
6828 temppoint+=sizeof(int);
6829 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
6830 temppoint+=sizeof(float);
6831 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
6832 temppoint+=sizeof(float);
6833 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
6834 temppoint+=sizeof(float);
6835 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
6836 temppoint+=sizeof(float);
6837 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
6838 temppoint+=sizeof(float);
6839 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
6840 temppoint+=sizeof(int);
6841 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
6842 temppoint+=sizeof(int);
6843 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
6844 temppoint+=sizeof(float);
6845 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
6846 temppoint+=sizeof(float);
6847 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
6848 temppoint+=sizeof(float);
6849 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
6850 temppoint+=sizeof(int);
6851 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
6852 temppoint+=sizeof(int);
6853 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
6854 temppoint+=sizeof(float);
6855 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
6856 temppoint+=sizeof(float);
6857 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
6858 temppoint+=sizeof(float);
6859 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
6860 temppoint+=sizeof(int);
6861 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
6862 temppoint+=sizeof(int);
6863 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
6864 temppoint+=sizeof(int);
6865 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
6866 temppoint+=sizeof(int);
6867 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
6868 temppoint+=sizeof(int);
6869 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
6870 temppoint+=sizeof(int);
6871 chatname[temppoint]='\0';
6873 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);
6874 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
6875 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
6877 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);
6879 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
6880 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
6882 //bigrefreshdelay=.02;
6887 if(!player[0].jumpkeydown){
6888 player[0].jumptogglekeydown=0;
6890 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
6893 dialoguetime+=multiplier;
6894 skybox.cloudmove+=multiplier;
6895 hawkrotation+=multiplier*25;
6897 realhawkcoords.x=25;
6898 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
6899 hawkcalldelay-=multiplier/2;
6901 if(hawkcalldelay<=0)
6903 static float gLoc[3];
6904 static float vel[3];
6905 gLoc[0]=realhawkcoords.x;
6906 gLoc[1]=realhawkcoords.y;
6907 gLoc[2]=realhawkcoords.z;
6911 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
6912 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
6913 OPENAL_SetVolume(channels[hawksound], 128);
6914 OPENAL_SetPaused(channels[hawksound], false);
6916 hawkcalldelay=16+abs(Random()%8);
6918 static float temptexdetail;
6921 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
6922 player[0].damagetolerance=200000;
6925 player[0].permanentdamage=0;
6926 player[0].superpermanentdamage=0;
6929 whichchar = abs(Random()%7);
6930 registrationname[whichchar]+=1;
6934 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
6936 if(environment>2)environment=0;
6937 Setenvironment(environment);
6943 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
6947 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
6948 cameramode=1-cameramode;
6949 cameratogglekeydown=1;
6952 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
6953 cameratogglekeydown=0;
6956 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
6957 if(player[0].num_weapons>0){
6958 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
6959 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
6960 else weapons.type[player[0].weaponids[0]]=sword;
6961 if(weapons.type[player[0].weaponids[0]]==sword){
6962 weapons.mass[player[0].weaponids[0]]=1.5;
6963 weapons.tipmass[player[0].weaponids[0]]=1;
6964 weapons.length[player[0].weaponids[0]]=.8;
6966 if(weapons.type[player[0].weaponids[0]]==staff){
6967 weapons.mass[player[0].weaponids[0]]=2;
6968 weapons.tipmass[player[0].weaponids[0]]=1;
6969 weapons.length[player[0].weaponids[0]]=1.5;
6972 if(weapons.type[player[0].weaponids[0]]==knife){
6973 weapons.mass[player[0].weaponids[0]]=1;
6974 weapons.tipmass[player[0].weaponids[0]]=1.2;
6975 weapons.length[player[0].weaponids[0]]=.25;
6979 /*for(i=0;i<objects.numobjects;i++){
6980 if(objects.type[i]==treeleavestype){
6981 for(j=0;j<objects.numobjects;j++){
6982 if(objects.type[j]==treetrunktype)
6983 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
6984 objects.scale[i]=objects.scale[j];
6988 detailtogglekeydown=1;
6991 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
6993 float closestdist=-1;
6996 for(i=1;i<numplayers;i++){
6997 distance=findDistancefast(&player[i].coords,&player[0].coords);
6998 if(closestdist==-1||distance<closestdist){
6999 closestdist=distance;
7004 if(player[closest].num_weapons)
7006 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7007 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7008 else weapons.type[player[closest].weaponids[0]]=sword;
7009 if(weapons.type[player[closest].weaponids[0]]==sword){
7010 weapons.mass[player[closest].weaponids[0]]=1.5;
7011 weapons.tipmass[player[closest].weaponids[0]]=1;
7012 weapons.length[player[closest].weaponids[0]]=.8;
7014 if(weapons.type[player[0].weaponids[0]]==staff){
7015 weapons.mass[player[0].weaponids[0]]=2;
7016 weapons.tipmass[player[0].weaponids[0]]=1;
7017 weapons.length[player[0].weaponids[0]]=1.5;
7019 if(weapons.type[player[closest].weaponids[0]]==knife){
7020 weapons.mass[player[closest].weaponids[0]]=1;
7021 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7022 weapons.length[player[closest].weaponids[0]]=.25;
7025 if(!player[closest].num_weapons)
7027 player[closest].weaponids[0]=weapons.numweapons;
7028 weapons.owner[weapons.numweapons]=closest;
7029 weapons.type[weapons.numweapons]=knife;
7030 weapons.damage[weapons.numweapons]=0;
7031 weapons.numweapons++;
7032 player[closest].num_weapons=1;
7033 if(weapons.type[player[closest].weaponids[0]]==sword){
7034 weapons.mass[player[closest].weaponids[0]]=1.5;
7035 weapons.tipmass[player[closest].weaponids[0]]=1;
7036 weapons.length[player[closest].weaponids[0]]=.8;
7038 if(weapons.type[player[closest].weaponids[0]]==knife){
7039 weapons.mass[player[closest].weaponids[0]]=1;
7040 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7041 weapons.length[player[closest].weaponids[0]]=.25;
7045 detailtogglekeydown=1;
7048 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7050 float closestdist=-1;
7053 for(i=1;i<numplayers;i++){
7054 distance=findDistancefast(&player[i].coords,&player[0].coords);
7055 if(closestdist==-1||distance<closestdist){
7056 closestdist=distance;
7061 player[closest].rotation+=multiplier*50;
7062 player[closest].targetrotation=player[closest].rotation;
7066 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7068 float closestdist=-1;
7071 for(i=1;i<numplayers;i++){
7072 distance=findDistancefast(&player[i].coords,&player[0].coords);
7073 if(closestdist==-1||distance<closestdist){
7074 closestdist=distance;
7078 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7081 player[closest].whichskin++;
7082 if(player[closest].whichskin>9)player[closest].whichskin=0;
7083 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7085 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
7086 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7089 if(player[closest].numclothes){
7090 for(i=0;i<player[closest].numclothes;i++){
7091 tintr=player[closest].clothestintr[i];
7092 tintg=player[closest].clothestintg[i];
7093 tintb=player[closest].clothestintb[i];
7094 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7096 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7099 detailtogglekeydown=1;
7102 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7104 float closestdist=-1;
7107 for(i=1;i<numplayers;i++){
7108 distance=findDistancefast(&player[i].coords,&player[0].coords);
7109 if(closestdist==-1||distance<closestdist){
7110 closestdist=distance;
7115 if(player[closest].creature==wolftype){
7116 headprop=player[closest].proportionhead.x/1.1;
7117 bodyprop=player[closest].proportionbody.x/1.1;
7118 armprop=player[closest].proportionarms.x/1.1;
7119 legprop=player[closest].proportionlegs.x/1.1;
7122 if(player[closest].creature==rabbittype){
7123 headprop=player[closest].proportionhead.x/1.2;
7124 bodyprop=player[closest].proportionbody.x/1.05;
7125 armprop=player[closest].proportionarms.x/1.00;
7126 legprop=player[closest].proportionlegs.x/1.1;
7130 if(player[closest].creature==rabbittype){
7131 player[closest].skeleton.id=closest;
7132 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);
7133 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7134 player[closest].whichskin=0;
7135 player[closest].creature=wolftype;
7137 player[closest].proportionhead=1.1;
7138 player[closest].proportionbody=1.1;
7139 player[closest].proportionarms=1.1;
7140 player[closest].proportionlegs=1.1;
7141 player[closest].proportionlegs.y=1.1;
7142 player[closest].scale=.23*5*player[0].scale;
7144 player[closest].damagetolerance=300;
7148 player[closest].skeleton.id=closest;
7149 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);
7150 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7151 player[closest].whichskin=0;
7152 player[closest].creature=rabbittype;
7154 player[closest].proportionhead=1.2;
7155 player[closest].proportionbody=1.05;
7156 player[closest].proportionarms=1.00;
7157 player[closest].proportionlegs=1.1;
7158 player[closest].proportionlegs.y=1.05;
7159 player[closest].scale=.2*5*player[0].scale;
7161 player[closest].damagetolerance=200;
7164 if(player[closest].creature==wolftype){
7165 player[closest].proportionhead=1.1*headprop;
7166 player[closest].proportionbody=1.1*bodyprop;
7167 player[closest].proportionarms=1.1*armprop;
7168 player[closest].proportionlegs=1.1*legprop;
7171 if(player[closest].creature==rabbittype){
7172 player[closest].proportionhead=1.2*headprop;
7173 player[closest].proportionbody=1.05*bodyprop;
7174 player[closest].proportionarms=1.00*armprop;
7175 player[closest].proportionlegs=1.1*legprop;
7176 player[closest].proportionlegs.y=1.05*legprop;
7180 detailtogglekeydown=1;
7183 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7184 detailtogglekeydown=0;
7187 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7190 slomotogglekeydown=1;
7194 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7196 float closestdist=-1;
7198 XYZ flatfacing2,flatvelocity2;
7201 for(i=1;i<numplayers;i++){
7202 distance=findDistancefast(&player[i].coords,&player[0].coords);
7203 if(distance<144&&!player[i].headless)
7204 if(closestdist==-1||distance<closestdist){
7205 closestdist=distance;
7207 blah = player[i].coords;
7212 XYZ headspurtdirection;
7213 int i = player[closest].skeleton.jointlabels[head];
7214 for(k=0;k<player[closest].skeleton.num_joints; k++){
7215 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7216 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7217 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;
7218 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7219 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7220 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7221 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7222 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7223 Normalise(&headspurtdirection);
7224 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7225 flatvelocity2+=headspurtdirection*8;
7226 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7228 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7238 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7239 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7240 OPENAL_SetVolume(channels[splattersound], 256);
7241 OPENAL_SetPaused(channels[splattersound], false);
7243 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7244 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7245 OPENAL_SetVolume(channels[breaksound2], 100);
7246 OPENAL_SetPaused(channels[breaksound2], false);
7248 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7249 player[closest].RagDoll(0);
7250 player[closest].dead=2;
7251 player[closest].headless=1;
7252 player[closest].DoBloodBig(3,165);
7257 explodetogglekeydown=1;
7260 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7262 float closestdist=-1;
7264 XYZ flatfacing2,flatvelocity2;
7267 for(i=1;i<numplayers;i++){
7268 distance=findDistancefast(&player[i].coords,&player[0].coords);
7270 if(closestdist==-1||distance<closestdist){
7271 closestdist=distance;
7273 blah=player[i].coords;
7287 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7288 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7289 OPENAL_SetVolume(channels[splattersound], 256);
7290 OPENAL_SetPaused(channels[splattersound], false);
7292 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7293 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7294 OPENAL_SetVolume(channels[breaksound2], 600);
7295 OPENAL_SetPaused(channels[breaksound2], false);
7297 for(i=0;i<player[closest].skeleton.num_joints; i++){
7298 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7299 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7300 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;
7301 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7302 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7303 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7304 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7305 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7306 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7307 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7310 for(i=0;i<player[closest].skeleton.num_joints; i++){
7311 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7312 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7313 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;
7314 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7315 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7316 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7317 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7318 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7319 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7322 for(i=0;i<player[closest].skeleton.num_joints; i++){
7323 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7324 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7325 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;
7326 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7327 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7328 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7329 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7330 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7331 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7334 for(i=0;i<player[closest].skeleton.num_joints; i++){
7335 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7336 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7337 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;
7338 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7339 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7340 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7341 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7342 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7343 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7347 for(j=0;j<numplayers; j++){
7349 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7350 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7351 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7352 player[j].skeleton.longdead=0;
7353 player[j].RagDoll(0);
7354 for(i=0;i<player[j].skeleton.num_joints; i++){
7355 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7356 if(findDistancefast(&temppos,&player[closest].coords)<25){
7357 flatvelocity2=temppos-player[closest].coords;
7358 Normalise(&flatvelocity2);
7359 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7366 player[closest].DoDamage(10000);
7367 player[closest].RagDoll(0);
7368 player[closest].dead=2;
7369 player[closest].coords=20;
7370 player[closest].skeleton.free=2;
7376 explodetogglekeydown=1;
7379 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7380 explodetogglekeydown=0;
7384 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7386 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7387 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7388 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7389 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7390 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7391 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7392 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7394 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7395 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7396 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7397 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7398 for(j=0;j<player[0].num_weapons;j++){
7399 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7401 fwrite( &environment, 1, sizeof(int), tfile );
7403 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7404 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7405 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7406 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7407 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7409 fwrite( &numplayers, 1, sizeof(int), tfile );
7410 if(numplayers>1&&numplayers<maxplayers)
7411 for(i=1;i<numplayers;i++){
7412 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7413 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7414 for(j=0;j<player[i].num_weapons;j++){
7415 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7417 if(player[i].numwaypoints<30){
7418 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7419 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7420 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7421 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7424 player[i].numwaypoints=0;
7425 player[i].waypoint=0;
7426 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7427 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7428 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7434 slomotogglekeydown=1;
7437 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7438 slomotogglekeydown=0;
7442 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7443 player[0].onfire=1-player[0].onfire;
7444 if(player[0].onfire){
7445 player[0].CatchFire();
7447 if(!player[0].onfire){
7450 gLoc[0]=player[0].coords.x;
7451 gLoc[1]=player[0].coords.y;
7452 gLoc[2]=player[0].coords.z;
7456 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7457 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7458 OPENAL_SetVolume(channels[fireendsound], 256);
7459 OPENAL_SetPaused(channels[fireendsound], false);
7460 OPENAL_SetPaused(channels[stream_firesound], true);
7462 slomotogglekeydown=1;
7465 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7466 if(player[0].bleeding<=0)
7467 player[0].DoBlood(1,255);
7471 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7473 float closestdist=-1;
7476 for(i=1;i<numplayers;i++){
7477 distance=findDistancefast(&player[i].coords,&player[0].coords);
7478 if(closestdist==-1||distance<closestdist){
7479 closestdist=distance;
7483 if(closestdist>0&&closest>=0){
7484 //player[closest]=player[numplayers-1];
7485 //player[closest].skeleton=player[numplayers-1].skeleton;
7488 drawmodetogglekeydown=1;
7491 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7493 float closestdist=-1;
7496 for(i=1;i<max_objects;i++){
7497 distance=findDistancefast(&objects.position[i],&player[0].coords);
7498 if(closestdist==-1||distance<closestdist){
7499 closestdist=distance;
7503 if(closestdist>0&&closest>=0){
7504 objects.position[closest].y-=500;
7506 drawmodetogglekeydown=1;
7509 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7511 //if(drawmode>2)drawmode=0;
7512 if(objects.numobjects<max_objects-1){
7514 boxcoords.x=player[0].coords.x;
7515 boxcoords.z=player[0].coords.z;
7516 boxcoords.y=player[0].coords.y-3;
7517 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7518 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7519 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7520 float temprotat,temprotat2;
7521 temprotat=editorrotation;
7522 temprotat2=editorrotation2;
7523 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7524 if(temprotat2<0)temprotat2=Random()%360;
7526 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7527 if(editortype==treetrunktype)
7528 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7531 drawmodetogglekeydown=1;
7534 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7535 if(numplayers<maxplayers-1){
7536 player[numplayers].scale=.2*5*player[0].scale;
7537 player[numplayers].creature=rabbittype;
7538 player[numplayers].howactive=editoractive;
7539 player[numplayers].skeleton.id=numplayers;
7540 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);
7542 //texsize=512*512*3/texdetail/texdetail;
7543 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7544 //player[numplayers].skeleton.skinText.resize(texsize);
7546 k=abs(Random()%2)+1;
7548 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7549 player[numplayers].whichskin=0;
7552 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7553 player[numplayers].whichskin=1;
7556 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7557 player[numplayers].whichskin=2;
7560 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7561 player[numplayers].power=1;
7562 player[numplayers].speedmult=1;
7563 player[numplayers].currentanimation=bounceidleanim;
7564 player[numplayers].targetanimation=bounceidleanim;
7565 player[numplayers].currentframe=0;
7566 player[numplayers].targetframe=1;
7567 player[numplayers].target=0;
7568 player[numplayers].bled=0;
7569 player[numplayers].speed=1+(float)(Random()%100)/1000;
7571 player[numplayers].targetrotation=player[0].targetrotation;
7572 player[numplayers].rotation=player[0].rotation;
7574 player[numplayers].velocity=0;
7575 player[numplayers].coords=player[0].coords;
7576 player[numplayers].oldcoords=player[numplayers].coords;
7577 player[numplayers].realoldcoords=player[numplayers].coords;
7579 player[numplayers].id=numplayers;
7580 player[numplayers].skeleton.id=numplayers;
7581 player[numplayers].updatedelay=0;
7582 player[numplayers].normalsupdatedelay=0;
7584 player[numplayers].aitype=passivetype;
7585 player[numplayers].aitarget=0;
7587 if(player[0].creature==wolftype){
7588 headprop=player[0].proportionhead.x/1.1;
7589 bodyprop=player[0].proportionbody.x/1.1;
7590 armprop=player[0].proportionarms.x/1.1;
7591 legprop=player[0].proportionlegs.x/1.1;
7594 if(player[0].creature==rabbittype){
7595 headprop=player[0].proportionhead.x/1.2;
7596 bodyprop=player[0].proportionbody.x/1.05;
7597 armprop=player[0].proportionarms.x/1.00;
7598 legprop=player[0].proportionlegs.x/1.1;
7601 if(player[numplayers].creature==wolftype){
7602 player[numplayers].proportionhead=1.1*headprop;
7603 player[numplayers].proportionbody=1.1*bodyprop;
7604 player[numplayers].proportionarms=1.1*armprop;
7605 player[numplayers].proportionlegs=1.1*legprop;
7608 if(player[numplayers].creature==rabbittype){
7609 player[numplayers].proportionhead=1.2*headprop;
7610 player[numplayers].proportionbody=1.05*bodyprop;
7611 player[numplayers].proportionarms=1.00*armprop;
7612 player[numplayers].proportionlegs=1.1*legprop;
7613 player[numplayers].proportionlegs.y=1.05*legprop;
7616 player[numplayers].headless=0;
7617 player[numplayers].onfire=0;
7620 player[numplayers].proportionhead.z=0;
7621 player[numplayers].proportionbody.z=0;
7622 player[numplayers].proportionarms.z=0;
7623 player[numplayers].proportionlegs.z=0;
7626 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7628 player[numplayers].damagetolerance=200;
7630 player[numplayers].protectionhead=player[0].protectionhead;
7631 player[numplayers].protectionhigh=player[0].protectionhigh;
7632 player[numplayers].protectionlow=player[0].protectionlow;
7633 player[numplayers].armorhead=player[0].armorhead;
7634 player[numplayers].armorhigh=player[0].armorhigh;
7635 player[numplayers].armorlow=player[0].armorlow;
7636 player[numplayers].metalhead=player[0].metalhead;
7637 player[numplayers].metalhigh=player[0].metalhigh;
7638 player[numplayers].metallow=player[0].metallow;
7640 player[numplayers].immobile=player[0].immobile;
7642 player[numplayers].numclothes=player[0].numclothes;
7643 if(player[numplayers].numclothes)
7644 for(i=0;i<player[numplayers].numclothes;i++){
7645 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
7646 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
7647 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
7648 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
7649 tintr=player[numplayers].clothestintr[i];
7650 tintg=player[numplayers].clothestintg[i];
7651 tintb=player[numplayers].clothestintb[i];
7652 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7654 if(player[numplayers].numclothes){
7655 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
7658 player[numplayers].power=player[0].power;
7659 player[numplayers].speedmult=player[0].speedmult;
7661 player[numplayers].damage=0;
7662 player[numplayers].permanentdamage=0;
7663 player[numplayers].superpermanentdamage=0;
7664 player[numplayers].deathbleeding=0;
7665 player[numplayers].bleeding=0;
7666 player[numplayers].numwaypoints=0;
7667 player[numplayers].waypoint=0;
7668 player[numplayers].jumppath=0;
7669 player[numplayers].weaponstuck=-1;
7670 player[numplayers].weaponactive=-1;
7671 player[numplayers].num_weapons=0;
7672 player[numplayers].bloodloss=0;
7673 player[numplayers].dead=0;
7675 player[numplayers].loaded=1;
7679 drawmodetogglekeydown=1;
7682 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
7683 if(player[numplayers-1].numwaypoints<90){
7684 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
7685 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
7686 player[numplayers-1].numwaypoints++;
7688 drawmodetogglekeydown=1;
7691 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7692 if(numpathpoints<30){
7693 bool connected,alreadyconnected;
7696 for(i=0;i<numpathpoints;i++){
7697 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
7699 for(j=0;j<numpathpointconnect[pathpointselected];j++){
7700 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
7702 if(!alreadyconnected){
7703 numpathpointconnect[pathpointselected]++;
7705 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
7711 pathpoint[numpathpoints-1]=player[0].coords;
7712 numpathpointconnect[numpathpoints-1]=0;
7713 if(numpathpoints>1&&pathpointselected!=-1){
7714 numpathpointconnect[pathpointselected]++;
7715 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
7717 pathpointselected=numpathpoints-1;
7720 drawmodetogglekeydown=1;
7723 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
7724 pathpointselected++;
7725 if(pathpointselected>=numpathpoints)pathpointselected=-1;
7726 drawmodetogglekeydown=1;
7728 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7729 pathpointselected--;
7730 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
7731 drawmodetogglekeydown=1;
7733 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7734 if(pathpointselected!=-1){
7736 pathpoint[pathpointselected]=pathpoint[numpathpoints];
7737 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
7738 for(i=0;i<numpathpointconnect[pathpointselected];i++){
7739 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
7741 for(i=0;i<numpathpoints;i++){
7742 for(j=0;j<numpathpointconnect[i];j++){
7743 if(pathpointconnect[i][j]==pathpointselected){
7744 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
7745 numpathpointconnect[i]--;
7747 if(pathpointconnect[i][j]==numpathpoints){
7748 pathpointconnect[i][j]=pathpointselected;
7752 pathpointselected=numpathpoints-1;
7754 drawmodetogglekeydown=1;
7757 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7758 editorenabled=1-editorenabled;
7760 player[0].damagetolerance=100000;
7762 player[0].superpermanentdamage=0;
7763 player[0].bloodloss=0;
7764 player[0].deathbleeding=0;
7767 player[0].damagetolerance=200;
7769 player[0].permanentdamage=0;
7770 player[0].superpermanentdamage=0;
7771 player[0].bloodloss=0;
7772 player[0].deathbleeding=0;
7774 drawmodetogglekeydown=1;
7777 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7779 if(editortype==treeleavestype||editortype==10)editortype--;
7780 if(editortype<0)editortype=firetype;
7781 drawmodetogglekeydown=1;
7784 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7786 if(editortype==treeleavestype||editortype==10)editortype++;
7787 if(editortype>firetype)editortype=0;
7788 drawmodetogglekeydown=1;
7791 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7792 editorrotation-=multiplier*100;
7793 if(editorrotation<-.01)editorrotation=-.01;
7794 drawmodetogglekeydown=1;
7797 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7798 editorrotation+=multiplier*100;
7799 drawmodetogglekeydown=1;
7802 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7803 editorsize+=multiplier;
7804 drawmodetogglekeydown=1;
7807 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7808 editorsize-=multiplier;
7809 if(editorsize<.1)editorsize=.1;
7810 drawmodetogglekeydown=1;
7814 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7815 mapradius-=multiplier*10;
7818 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7819 mapradius+=multiplier*10;
7822 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7823 mapcenter.x+=multiplier*20;
7826 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7827 mapcenter.x-=multiplier*20;
7830 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7831 mapcenter.z+=multiplier*20;
7834 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7835 mapcenter.z-=multiplier*20;
7838 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7839 editorrotation2+=multiplier*100;
7842 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7843 editorrotation2-=multiplier*100;
7844 if(editorrotation2<-.01)editorrotation2=-.01;
7846 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7848 float closestdist=-1;
7850 for(i=0;i<objects.numobjects;i++){
7851 distance=findDistancefast(&objects.position[i],&player[0].coords);
7852 if(closestdist==-1||distance<closestdist){
7853 closestdist=distance;
7857 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
7858 drawmodetogglekeydown=1;
7862 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)){
7863 drawmodetogglekeydown=0;
7866 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
7867 //if(!player[0].skeleton.free)player[0].damage+=500;
7868 player[0].RagDoll(0);
7869 //player[0].spurt=1;
7870 //player[0].DoDamage(1000);
7874 gLoc[0]=player[0].coords.x;
7875 gLoc[1]=player[0].coords.y;
7876 gLoc[2]=player[0].coords.z;
7877 vel[0]=player[0].velocity.x;
7878 vel[1]=player[0].velocity.y;
7879 vel[2]=player[0].velocity.z;
7880 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
7881 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
7882 OPENAL_SetVolume(channels[whooshsound], 128);
7883 OPENAL_SetPaused(channels[whooshsound], false);
7884 //OPENAL_SetPaused(channels[whooshsound], true);
7886 texturesizetogglekeydown=1;
7889 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
7892 float closestdist=-1;
7894 for(i=0;i<objects.numobjects;i++){
7895 if(objects.type[i]==treeleavestype){
7896 objects.scale[i]*=.9;
7899 texturesizetogglekeydown=1;
7902 static XYZ relative;
7903 static int randattack;
7905 static bool playerrealattackkeydown=0;
7907 if(!buttons[0])oldbutton=0;
7908 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
7909 if(oldattackkey)player[0].attackkeydown=0;
7910 if(oldattackkey)playerrealattackkeydown=0;
7911 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
7912 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);
7913 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
7914 for(k=0;k<numplayers;k++){
7915 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
7916 player[k].Reverse();
7920 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
7922 for(k=0;k<numplayers;k++){
7923 if(indialogue!=-1)player[k].attackkeydown=0;
7924 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
7925 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
7926 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)){
7927 player[k].jumppower-=2;
7929 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)){
7930 for(i=0;i<numplayers;i++){
7932 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
7933 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
7934 player[k].targetanimation=dodgebackanim;
7936 player[k].targetframe=0;
7937 rotatetarget=player[i].coords-player[k].coords;
7938 Normalise(&rotatetarget);
7939 player[k].targetrotation=-asin(0-rotatetarget.x);
7940 player[k].targetrotation*=360/6.28;
7941 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
7943 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
7946 if(player[k].targetanimation!=dodgebackanim){
7947 if(k==0)numflipped++;
7948 player[k].targetanimation=backhandspringanim;
7950 player[k].targetframe=0;
7951 player[k].targetrotation=-rotation+180;
7952 if(player[k].leftkeydown)player[k].targetrotation-=45;
7953 if(player[k].rightkeydown)player[k].targetrotation+=45;
7954 player[k].rotation=player[k].targetrotation;
7955 player[k].jumppower-=2;
7958 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())){
7959 player[k].hasvictim=0;
7961 for(i=0;i<numplayers;i++){
7963 if(!player[k].hasvictim)
7964 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
7965 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){
7966 player[k].victim=&player[i];
7967 player[k].hasvictim=1;
7968 if(player[k].aitype==playercontrolled){
7969 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;
7970 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;
7971 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;
7972 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;
7973 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;
7974 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;
7975 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;
7976 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;
7977 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;
7978 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;
7981 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
7982 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
7983 else randattack=abs(Random()%5);
7984 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
7985 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
7986 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
7987 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
7988 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
7990 if(player[k].weaponactive!=-1){
7991 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;
7992 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;
7993 //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;
7994 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;
7995 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;
7996 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;
7997 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;
7998 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;
8002 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8004 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)){
8005 if(player[k].weaponactive==-1){
8006 player[i].targetanimation=sneakattackedanim;
8007 player[i].currentanimation=sneakattackedanim;
8008 player[k].currentanimation=sneakattackanim;
8009 player[k].targetanimation=sneakattackanim;
8010 player[k].oldcoords=player[k].coords;
8011 player[k].coords=player[i].coords;
8013 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8014 player[i].targetanimation=knifesneakattackedanim;
8015 player[i].currentanimation=knifesneakattackedanim;
8016 player[k].currentanimation=knifesneakattackanim;
8017 player[k].targetanimation=knifesneakattackanim;
8018 player[i].oldcoords=player[i].coords;
8019 player[i].coords=player[k].coords;
8021 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8022 player[i].targetanimation=swordsneakattackedanim;
8023 player[i].currentanimation=swordsneakattackedanim;
8024 player[k].currentanimation=swordsneakattackanim;
8025 player[k].targetanimation=swordsneakattackanim;
8026 player[i].oldcoords=player[i].coords;
8027 player[i].coords=player[k].coords;
8029 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8030 player[k].victim=&player[i];
8031 player[k].hasvictim=1;
8032 player[i].targettilt2=0;
8033 player[i].targetframe=1;
8034 player[i].currentframe=0;
8036 player[i].velocity=0;
8037 player[k].targettilt2=player[i].targettilt2;
8038 player[k].currentframe=player[i].currentframe;
8039 player[k].targetframe=player[i].targetframe;
8040 player[k].target=player[i].target;
8041 player[k].velocity=0;
8042 player[k].targetrotation=player[i].rotation;
8043 player[k].rotation=player[i].rotation;
8044 player[i].targetrotation=player[i].rotation;
8047 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8049 player[k].targetframe=0;
8051 //player[k].velocity=0;
8053 rotatetarget=player[i].coords-player[k].coords;
8054 Normalise(&rotatetarget);
8055 player[k].targetrotation=-asin(0-rotatetarget.x);
8056 player[k].targetrotation*=360/6.28;
8057 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8059 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8061 player[k].lastattack3=player[k].lastattack2;
8062 player[k].lastattack2=player[k].lastattack;
8063 player[k].lastattack=player[k].targetanimation;
8064 //player[k].targettilt2=0;
8068 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8069 rotatetarget=player[i].coords-player[k].coords;
8070 Normalise(&rotatetarget);
8071 player[k].targetrotation=-asin(0-rotatetarget.x);
8072 player[k].targetrotation*=360/6.28;
8073 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8074 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8076 player[k].victim=&player[i];
8077 player[k].hasvictim=1;
8078 player[i].targetanimation=knifefollowedanim;
8079 player[i].currentanimation=knifefollowedanim;
8080 player[i].targettilt2=0;
8081 player[i].targettilt2=player[k].targettilt2;
8082 player[i].targetframe=1;
8083 player[i].currentframe=0;
8085 player[i].velocity=0;
8086 player[k].currentanimation=knifefollowanim;
8087 player[k].targetanimation=knifefollowanim;
8088 player[k].targettilt2=player[i].targettilt2;
8089 player[k].currentframe=player[i].currentframe;
8090 player[k].targetframe=player[i].targetframe;
8091 player[k].target=player[i].target;
8092 player[k].velocity=0;
8093 player[k].oldcoords=player[k].coords;
8094 player[i].coords=player[k].coords;
8095 player[i].targetrotation=player[k].targetrotation;
8096 player[i].rotation=player[k].targetrotation;
8097 player[k].rotation=player[k].targetrotation;
8098 player[i].rotation=player[k].targetrotation;
8103 if(player[k].weaponactive!=-1){
8104 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8107 for(i=0;i<numplayers;i++){
8109 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8110 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8111 if(player[i].skeleton.free)
8112 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)))){
8113 player[k].victim=&player[i];
8114 player[k].hasvictim=1;
8115 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8116 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;
8117 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;
8118 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;
8120 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){
8121 player[k].targetanimation=killanim;
8122 for(j=0;j<terrain.numdecals;j++){
8123 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8124 terrain.DeleteDecal(j);
8127 for(l=0;l<objects.numobjects;l++){
8128 if(objects.model[l].type==decalstype)
8129 for(j=0;j<objects.model[l].numdecals;j++){
8130 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8131 objects.model[l].DeleteDecal(j);
8136 if(!player[i].dead||musictype!=2)
8137 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)){
8138 player[k].targetanimation=dropkickanim;
8139 for(j=0;j<terrain.numdecals;j++){
8140 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8141 terrain.DeleteDecal(j);
8144 for(l=0;l<objects.numobjects;l++){
8145 if(objects.model[l].type==decalstype)
8146 for(j=0;j<objects.model[l].numdecals;j++){
8147 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8148 objects.model[l].DeleteDecal(j);
8154 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)){
8156 player[k].targetframe=0;
8158 //player[k].velocity=0;
8160 rotatetarget=player[i].coords-player[k].coords;
8161 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8162 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;
8164 Normalise(&rotatetarget);
8165 player[k].targetrotation=-asin(0-rotatetarget.x);
8166 player[k].targetrotation*=360/6.28;
8167 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8169 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8170 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8173 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8174 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8176 player[k].lastattack3=player[k].lastattack2;
8177 player[k].lastattack2=player[k].lastattack;
8178 player[k].lastattack=player[k].targetanimation;
8180 if(player[k].targetanimation==swordgroundstabanim){
8181 player[k].targetrotation+=30;
8183 //player[k].targettilt2=0;
8189 if(!player[k].hasvictim){
8190 for(i=0;i<numplayers;i++){
8191 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8192 player[k].victim=&player[i];
8193 player[k].hasvictim=1;
8195 if(player[k].hasvictim&&!player[i].skeleton.free)
8196 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8197 player[k].victim=&player[i];
8201 if(player[k].aitype==playercontrolled)
8202 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)){
8204 player[k].targetanimation=rabbitkickanim;
8205 player[k].targetframe=0;
8208 if(animation[player[k].targetanimation].attack&&k==0){
8211 if(player[k].weaponactive!=-1){
8212 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8215 if(player[k].weaponactive!=-1){
8216 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8219 if(player[k].weaponactive!=-1){
8220 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8222 if(armedstaff)numstaffattack++;
8223 else if(armedsword)numswordattack++;
8224 else if(armedknife)numknifeattack++;
8225 else numunarmedattack++;
8232 static float collisionradius;
8234 for(k=0;k<numplayers;k++){
8235 for(i=k;i<numplayers;i++){
8238 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))
8239 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))
8240 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8241 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8242 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)
8243 if(player[i].coords.y>player[k].coords.y-3)
8244 if(player[i].coords.y<player[k].coords.y+3)
8245 if(player[i].coords.x>player[k].coords.x-3)
8246 if(player[i].coords.x<player[k].coords.x+3)
8247 if(player[i].coords.z>player[k].coords.z-3)
8248 if(player[i].coords.z<player[k].coords.z+3){
8249 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)){
8250 if(player[i].onfire||player[k].onfire){
8251 if(!player[i].onfire)player[i].CatchFire();
8252 if(!player[k].onfire)player[k].CatchFire();
8256 tempcoords1=player[i].coords;
8257 tempcoords2=player[k].coords;
8258 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8259 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8260 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8261 if(player[0].hasvictim)
8262 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8263 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8265 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)){
8266 player[k].coords.y=player[i].coords.y;
8267 player[i].velocity=player[k].velocity;
8268 player[i].skeleton.free=0;
8269 player[i].rotation=0;
8270 player[i].RagDoll(0);
8271 player[i].DoDamage(20);
8272 if(k==0)camerashake+=.3;
8273 player[i].skeleton.longdead=0;
8274 player[k].lastcollide=1;
8277 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)){
8278 player[i].coords.y=player[k].coords.y;
8279 player[k].velocity=player[i].velocity;
8280 player[k].skeleton.free=0;
8281 player[k].rotation=0;
8282 player[k].RagDoll(0);
8283 player[k].DoDamage(20);
8284 if(i==0)camerashake+=.3;
8285 player[k].skeleton.longdead=0;
8286 player[i].lastcollide=1;
8289 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)){
8290 rotatetarget=player[k].velocity-player[i].velocity;
8291 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))
8292 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))){
8294 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)){
8295 static float gLoc[3];
8296 static float vel[3];
8297 gLoc[0]=player[i].coords.x;
8298 gLoc[1]=player[i].coords.y;
8299 gLoc[2]=player[i].coords.z;
8300 vel[0]=player[i].velocity.x;
8301 vel[1]=player[i].velocity.y;
8302 vel[2]=player[i].velocity.z;
8303 if(tutoriallevel!=1){
8304 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8305 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8306 OPENAL_SetVolume(channels[heavyimpactsound], 256);
8307 OPENAL_SetPaused(channels[heavyimpactsound], false);
8309 //player[i].velocity=player[k].velocity;
8310 //player[k].velocity=player[i].velocity;
8312 player[i].RagDoll(0);
8313 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8318 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8319 player[k].RagDoll(0);
8320 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8325 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8327 //if(player[i].skeleton.oldfree){
8328 for(j=0;j<player[i].skeleton.num_joints;j++){
8329 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8332 //if(player[k].skeleton.oldfree){
8333 for(j=0;j<player[k].skeleton.num_joints;j++){
8334 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8340 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)){
8342 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8343 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)){
8344 rotatetarget=player[k].coords-player[i].coords;
8345 Normalise(&rotatetarget);
8346 player[k].coords=(player[k].coords+player[i].coords)/2;
8347 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);
8348 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8349 if(player[k].howactive==typeactive||hostile)
8350 if(player[k].isIdle()){
8351 if(player[k].howactive<typesleeping){
8352 player[k].targetanimation=player[k].getStop();
8353 player[k].targetframe=0;
8356 else if(player[k].howactive==typesleeping)
8358 player[k].targetanimation=getupfromfrontanim;
8359 player[k].targetframe=0;
8362 if(!editorenabled)player[k].howactive=typeactive;
8364 if(player[i].howactive==typeactive||hostile)
8365 if(player[i].isIdle()){
8366 if(player[i].howactive<typesleeping){
8367 player[i].targetanimation=player[i].getStop();
8368 player[i].targetframe=0;
8373 player[i].targetanimation=getupfromfrontanim;
8374 player[i].targetframe=0;
8377 if(!editorenabled)player[i].howactive=typeactive;
8381 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){
8382 player[i].velocity=player[k].velocity;
8383 player[k].velocity=player[k].velocity*-.5;
8384 //player[i].velocity.y-=10;
8385 player[k].velocity.y=player[i].velocity.y;
8386 player[i].DoDamage(20);
8387 player[i].RagDoll(0);
8388 player[k].lastcollide=1;
8395 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){
8396 player[k].velocity=player[i].velocity;
8397 player[i].velocity=player[i].velocity*-.3;
8398 //player[k].velocity.y-=10;
8399 player[i].velocity.y=player[k].velocity.y;
8400 player[k].DoDamage(20);
8401 player[k].RagDoll(0);
8402 player[i].lastcollide=1;
8413 player[i].CheckKick();
8414 player[k].CheckKick();
8420 for(k=0;k<numplayers;k++){
8421 for(i=k;i<numplayers;i++){
8423 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))){
8424 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)){
8425 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)){
8426 player[i].victim=&player[k];
8427 player[i].targetanimation=jumpreversedanim;
8428 player[i].currentanimation=jumpreversedanim;
8429 player[k].currentanimation=jumpreversalanim;
8430 player[k].targetanimation=jumpreversalanim;
8431 player[i].targettilt2=0;
8432 player[i].currentframe=0;
8433 player[i].targetframe=1;
8434 player[k].currentframe=0;
8435 player[k].targetframe=1;
8436 if(player[i].coords.y<player[k].coords.y+1){
8437 player[i].targetanimation=rabbitkickreversedanim;
8438 player[i].currentanimation=rabbitkickreversedanim;
8439 player[k].currentanimation=rabbitkickreversalanim;
8440 player[k].targetanimation=rabbitkickreversalanim;
8441 player[k].currentframe=1;
8442 player[k].targetframe=2;
8443 player[i].currentframe=1;
8444 player[i].targetframe=2;
8446 player[k].targettilt2=0;
8448 player[i].velocity=0;
8449 player[k].velocity=0;
8450 player[k].oldcoords=player[k].coords;
8451 player[i].coords=player[k].coords;
8452 player[k].targetrotation=player[i].targetrotation;
8453 player[k].rotation=player[i].targetrotation;
8454 player[k].victim=&player[i];
8455 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8457 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)){
8458 player[k].victim=&player[i];
8459 player[k].targetanimation=jumpreversedanim;
8460 player[k].currentanimation=jumpreversedanim;
8461 player[i].currentanimation=jumpreversalanim;
8462 player[i].targetanimation=jumpreversalanim;
8463 player[k].targettilt2=0;
8464 player[i].targettilt2=0;
8465 player[k].currentframe=0;
8466 player[k].targetframe=1;
8467 player[i].currentframe=0;
8468 player[i].targetframe=1;
8469 if(player[k].coords.y<player[i].coords.y+1){
8470 player[k].targetanimation=rabbitkickreversedanim;
8471 player[k].currentanimation=rabbitkickreversedanim;
8472 player[i].currentanimation=rabbitkickreversalanim;
8473 player[i].targetanimation=rabbitkickreversalanim;
8474 player[k].currentframe=1;
8475 player[k].targetframe=2;
8476 player[i].currentframe=1;
8477 player[i].targetframe=2;
8480 player[k].velocity=0;
8481 player[i].velocity=0;
8482 player[i].oldcoords=player[i].coords;
8483 player[k].coords=player[i].coords;
8484 player[i].targetrotation=player[k].targetrotation;
8485 player[i].rotation=player[k].targetrotation;
8486 player[i].victim=&player[k];
8487 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8494 for(k=0;k<numplayers;k++)
8495 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8504 static float checkdelay;
8505 checkdelay-=multiplier;
8507 static bool checkedcoll[maxplayers][maxplayers];
8508 static bool above[maxplayers];
8510 for(i=0;i<maxplayers;i++){
8511 for(j=0;j<maxplayers;j++){
8512 checkedcoll[i][j]=0;
8516 if(numplayers>1&&checkdelay<=0){
8518 for(k=0;k<numplayers;k++){
8519 if(player[k].skeleton.free!=2)above[k]=-1;
8521 for(i=k;i<numplayers;i++){
8524 if(!checkedcoll[i][k]){
8525 checkedcoll[i][k]=1;
8526 checkedcoll[k][i]=1;
8527 if(player[i].skeleton.free&&player[k].skeleton.free)
8528 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8529 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8530 if(player[i].coords.y>player[k].coords.y-3)
8531 if(player[i].coords.y<player[k].coords.y+3)
8532 if(player[i].coords.x>player[k].coords.x-3)
8533 if(player[i].coords.x<player[k].coords.x+3)
8534 if(player[i].coords.z>player[k].coords.z-3)
8535 if(player[i].coords.z<player[k].coords.z+3)
8536 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)){
8538 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8550 above[moving]=stuck;
8551 for(l=0;l<player[moving].skeleton.num_joints;l++){
8552 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8553 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8555 player[moving].skeleton.joints[l].position.y+=.003;
8556 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8570 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8571 texturesizetogglekeydown=0;
8574 for(k=0;k<numplayers;k++){
8575 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8576 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8577 player[k].DoDamage(1000);
8582 static bool respawnkeydown;
8583 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8584 targetlevel=whichlevel;
8588 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8589 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8594 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8596 if(targetlevel>numchallengelevels-1)targetlevel=0;
8599 slomotogglekeydown=1;
8603 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8605 OPENAL_SetPaused(channels[whooshsound], true);
8607 for(k=0;k<numplayers;k++){
8610 player[k].permanentdamage=0;
8611 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8612 player[k].aitype=passivetype;
8614 player[0].aitype=playercontrolled;
8618 static bool movekey;
8619 static bool connected;
8620 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8621 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8622 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8623 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8624 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8625 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8627 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
8629 for(int i=0;i<numplayers;i++){
8630 if(!player[i].skeleton.free){
8631 oldtargetrotation=player[i].targetrotation;
8632 if(i==0&&indialogue==-1){
8633 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){
8634 if(!cameramode)player[0].targetrotation=-rotation+180;
8635 if(cameramode)player[0].targetrotation=0;
8641 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8642 if(cameramode){facing=flatfacing;}
8644 facing=DoRotation(facing,-rotation2,0,0);
8645 facing=DoRotation(facing,0,0-rotation,0);
8648 player[0].lookrotation=-rotation;
8650 player[i].targetheadrotation=rotation;
8651 player[i].targetheadrotation2=rotation2;
8653 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
8654 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){
8655 player[i].targetrotation=-player[i].lookrotation+180;
8661 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8663 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
8664 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
8666 player[i].targetheadrotation=player[i].lookrotation;
8667 player[i].targetheadrotation2=player[i].lookrotation2;
8670 rotatetarget=participantfacing[whichdialogue][indialogue][i];
8671 Normalise(&rotatetarget);
8672 player[i].targetheadrotation=-asin(0-rotatetarget.x);
8673 player[i].targetheadrotation*=360/6.28;
8674 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
8676 player[i].targetheadrotation*=-1;
8677 player[i].targetheadrotation+=180;
8678 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
8686 player[i].avoidsomething=0;
8688 for(j=0;j<objects.numobjects;j++){
8689 if(objects.onfire[j]){
8690 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
8692 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
8693 player[i].collided=0;
8694 player[i].avoidcollided=1;
8695 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8696 player[i].avoidwhere=objects.position[j];
8702 //Add avoidwhere to players
8704 for(j=0;j<numplayers;j++){
8705 if(player[j].onfire){
8706 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
8708 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
8709 player[i].collided=0;
8710 player[i].avoidcollided=1;
8711 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8712 player[i].avoidwhere=objects.position[j];
8718 if(player[i].collided>.8)player[i].avoidcollided=0;
8719 if(player[i].aitype!=playercontrolled&&indialogue==-1){
8720 player[i].jumpclimb=0;
8722 if(editorenabled)player[i].stunned=1;
8725 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
8726 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;
8728 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
8729 player[i].forwardkeydown=0;
8730 player[i].leftkeydown=0;
8731 player[i].backkeydown=0;
8732 player[i].rightkeydown=0;
8733 player[i].crouchkeydown=0;
8734 player[i].attackkeydown=0;
8735 player[i].jumpkeydown=0;
8736 player[i].throwkeydown=0;
8739 if(player[i].aitype==pathfindtype){
8740 if(player[i].finalpathfindpoint==-1){
8741 float closestdistance;
8747 for(j=0;j<numpathpoints;j++){
8748 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
8749 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
8751 player[i].finaltarget=pathpoint[j];
8754 player[i].finalpathfindpoint=closest;
8755 for(j=0;j<numpathpoints;j++){
8756 if(numpathpointconnect[j])
8757 for(k=0;k<numpathpointconnect[j];k++){
8758 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8759 if(tempdist*tempdist<closestdistance){
8760 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8761 closestdistance=tempdist*tempdist;
8763 player[i].finaltarget=colpoint;
8768 player[i].finalpathfindpoint=closest;
8771 if(player[i].targetpathfindpoint==-1){
8772 float closestdistance;
8778 if(player[i].lastpathfindpoint==-1){
8779 for(j=0;j<numpathpoints;j++){
8780 if(j!=player[i].lastpathfindpoint)
8781 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
8782 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
8786 player[i].targetpathfindpoint=closest;
8787 for(j=0;j<numpathpoints;j++){
8788 if(j!=player[i].lastpathfindpoint)
8789 if(numpathpointconnect[j])
8790 for(k=0;k<numpathpointconnect[j];k++){
8791 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8792 if(tempdist*tempdist<closestdistance){
8793 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8794 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
8795 closestdistance=tempdist*tempdist;
8802 player[i].targetpathfindpoint=closest;
8806 for(j=0;j<numpathpoints;j++){
8807 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
8810 if(numpathpointconnect[j])
8811 for(k=0;k<numpathpointconnect[j];k++){
8812 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
8815 if(numpathpointconnect[player[i].lastpathfindpoint])
8816 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
8817 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
8820 tempdist=findPathDist(j,player[i].finalpathfindpoint);
8821 if(closest==-1||tempdist<closestdistance){
8822 closestdistance=tempdist;
8828 player[i].targetpathfindpoint=closest;
8831 player[i].losupdatedelay-=multiplier;
8833 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
8834 Normalise(&rotatetarget);
8835 player[i].targetrotation=-asin(0-rotatetarget.x);
8836 player[i].targetrotation*=360/6.28;
8837 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8838 player[i].lookrotation=player[i].targetrotation;
8839 //player[i].aiupdatedelay=.05;
8841 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
8842 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8843 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8844 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8845 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
8846 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8847 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8848 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8849 player[i].targetpathfindpoint=-1;
8851 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){
8852 player[i].aitype=passivetype;
8855 player[i].forwardkeydown=1;
8856 player[i].leftkeydown=0;
8857 player[i].backkeydown=0;
8858 player[i].rightkeydown=0;
8859 player[i].crouchkeydown=0;
8860 player[i].attackkeydown=0;
8861 player[i].throwkeydown=0;
8863 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
8865 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
8866 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
8868 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
8869 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))
8870 player[i].aitype=attacktypecutoff;
8871 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
8872 player[i].aitype=attacktypecutoff;
8874 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
8875 player[i].losupdatedelay=.2;
8876 for(j=0;j<numplayers;j++){
8877 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
8878 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
8879 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
8880 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
8881 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
8882 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)){
8883 player[i].aitype=searchtype;
8884 player[i].lastchecktime=12;
8885 player[i].lastseen=player[j].coords;
8886 player[i].lastseentime=12;
8892 if(player[i].aitype==attacktypecutoff&&musictype!=2){
8893 if(player[i].creature!=wolftype){
8894 player[i].stunned=.6;
8895 player[i].surprised=.6;
8900 if(player[i].aitype!=passivetype&&leveltime>.5){
8901 player[i].howactive=typeactive;
8904 if(player[i].aitype==passivetype){
8905 player[i].aiupdatedelay-=multiplier;
8906 player[i].losupdatedelay-=multiplier;
8907 player[i].lastseentime+=multiplier;
8908 player[i].pausetime-=multiplier;
8909 if(player[i].lastseentime>1)player[i].lastseentime=1;
8911 if(player[i].aiupdatedelay<0){
8912 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
8913 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
8914 Normalise(&rotatetarget);
8915 player[i].targetrotation=-asin(0-rotatetarget.x);
8916 player[i].targetrotation*=360/6.28;
8917 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8918 player[i].lookrotation=player[i].targetrotation;
8919 player[i].aiupdatedelay=.05;
8921 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
8922 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
8923 player[i].waypoint++;
8924 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
8929 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
8930 else player[i].forwardkeydown=0;
8931 player[i].leftkeydown=0;
8932 player[i].backkeydown=0;
8933 player[i].rightkeydown=0;
8934 player[i].crouchkeydown=0;
8935 player[i].attackkeydown=0;
8936 player[i].throwkeydown=0;
8938 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
8939 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
8941 XYZ leftpos,rightpos;
8942 float leftdist,rightdist;
8943 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
8944 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
8945 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
8946 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
8947 if(leftdist<rightdist)player[i].targetrotation+=90;
8948 else player[i].targetrotation-=90;
8952 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
8953 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
8957 if(player[i].howactive<typesleeping)
8958 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
8959 for(j=0;j<numenvsounds;j++){
8960 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
8961 player[i].aitype=attacktypecutoff;
8965 if(player[i].howactive==typesleeping)
8966 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
8967 for(j=0;j<numenvsounds;j++){
8968 if(envsoundvol[j]>14)
8969 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
8970 player[i].aitype=attacktypecutoff;
8974 if(player[i].aitype!=passivetype){
8975 if(player[i].howactive==typesleeping){
8976 player[i].targetanimation=getupfromfrontanim;
8977 player[i].targetframe=0;
8981 player[i].howactive=typeactive;
8985 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
8986 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
8987 player[i].aitype=attacktypecutoff;
8988 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
8989 player[i].aitype=attacktypecutoff;
8991 if(player[i].creature==wolftype){
8993 float smelldistance;
8995 for(j=0;j<numplayers;j++){
8996 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
8997 if(j==0&&player[j].num_weapons>0){
8998 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
8999 if(player[j].num_weapons==2)
9000 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9005 windsmell=windvector;
9006 Normalise(&windsmell);
9007 windsmell=windsmell*2+player[j].coords;
9008 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9009 player[i].aitype=attacktypecutoff;
9014 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9015 player[i].losupdatedelay=.2;
9016 for(j=0;j<numplayers;j++){
9017 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9018 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9019 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9020 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9021 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)){
9022 player[i].lastseentime-=.2;
9023 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9024 else player[i].lastseentime-=.6;
9026 if(player[i].lastseentime<=0){
9027 player[i].aitype=searchtype;
9028 player[i].lastchecktime=12;
9029 player[i].lastseen=player[j].coords;
9030 player[i].lastseentime=12;
9036 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9037 if(player[i].creature!=wolftype){
9038 player[i].stunned=.6;
9039 player[i].surprised=.6;
9041 if(player[i].creature==wolftype){
9042 player[i].stunned=.47;
9043 player[i].surprised=.47;
9049 if(player[i].aitype==searchtype){
9050 player[i].aiupdatedelay-=multiplier;
9051 player[i].losupdatedelay-=multiplier;
9052 if(!player[i].pause)player[i].lastseentime-=multiplier;
9053 player[i].lastchecktime-=multiplier;
9055 if(player[i].isRun()&&!player[i].onground){
9056 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9057 test2=player[i].coords+player[i].facing;
9059 test=player[i].coords+player[i].facing;
9061 j=checkcollide(test2,test,player[i].laststanding);
9062 if(j==-1)j=checkcollide(test2,test);
9064 player[i].velocity=0;
9065 player[i].targetanimation=player[i].getStop();
9066 player[i].targetframe=0;
9068 player[i].targetrotation+=180;
9069 player[i].stunned=.5;
9070 //player[i].aitype=passivetype;
9071 player[i].aitype=pathfindtype;
9072 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9073 player[i].finalpathfindpoint=-1;
9074 player[i].targetpathfindpoint=-1;
9075 player[i].lastpathfindpoint=-1;
9076 player[i].lastpathfindpoint2=-1;
9077 player[i].lastpathfindpoint3=-1;
9078 player[i].lastpathfindpoint4=-1;
9080 else player[i].laststanding=j;
9083 if(player[i].aiupdatedelay<0){
9084 rotatetarget=player[i].lastseen-player[i].coords;
9085 Normalise(&rotatetarget);
9086 player[i].targetrotation=-asin(0-rotatetarget.x);
9087 player[i].targetrotation*=360/6.28;
9088 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9089 player[i].lookrotation=player[i].targetrotation;
9090 player[i].aiupdatedelay=.05;
9091 player[i].forwardkeydown=1;
9093 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9094 player[i].forwardkeydown=0;
9095 player[i].aiupdatedelay=1;
9096 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9097 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9098 player[i].lastchecktime=3;
9101 player[i].leftkeydown=0;
9102 player[i].backkeydown=0;
9103 player[i].rightkeydown=0;
9104 player[i].crouchkeydown=0;
9105 player[i].attackkeydown=0;
9106 player[i].throwkeydown=0;
9108 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9109 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9111 XYZ leftpos,rightpos;
9112 float leftdist,rightdist;
9113 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9114 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9115 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9116 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9117 if(leftdist<rightdist)player[i].targetrotation+=90;
9118 else player[i].targetrotation-=90;
9122 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9123 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9125 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9126 for(j=0;j<numenvsounds;j++){
9127 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9128 player[i].aitype=attacktypecutoff;
9132 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9133 player[i].losupdatedelay=.2;
9134 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9135 {player[i].aitype=attacktypecutoff;
9136 player[i].lastseentime=1;}
9137 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9138 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9139 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9140 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)){
9141 player[i].aitype=attacktypecutoff;
9142 player[i].lastseentime=1;
9145 if(player[i].lastseentime<0){
9146 //player[i].aitype=passivetype;
9148 player[i].aitype=pathfindtype;
9149 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9150 player[i].finalpathfindpoint=-1;
9151 player[i].targetpathfindpoint=-1;
9152 player[i].lastpathfindpoint=-1;
9153 player[i].lastpathfindpoint2=-1;
9154 player[i].lastpathfindpoint3=-1;
9155 player[i].lastpathfindpoint4=-1;
9159 if(player[i].aitype!=gethelptype){
9160 player[i].runninghowlong=0;
9163 if(player[i].aitype==gethelptype){
9164 player[i].runninghowlong+=multiplier;
9165 player[i].aiupdatedelay-=multiplier;
9167 if(player[i].aiupdatedelay<0||player[i].ally==0){
9168 player[i].aiupdatedelay=.2;
9176 if(!player[i].ally){
9177 for(j=0;j<numplayers;j++){
9178 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9179 distance=findDistancefast(&player[i].coords,&player[j].coords);
9180 if(closestdist==-1||distance<closestdist){
9181 closestdist=distance;
9187 if(closest!=-1)player[i].ally=closest;
9188 else player[i].ally=0;
9189 player[i].lastseen=player[0].coords;
9190 player[i].lastseentime=12;
9194 player[i].lastchecktime=12;
9195 //player[i].lastseentime-=.5;
9197 facing=player[i].coords;
9198 flatfacing=player[player[i].ally].coords;
9199 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9200 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9201 if(-1!=checkcollide(facing,flatfacing))
9202 player[i].lastseentime-=.1;
9204 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9205 player[i].aitype=searchtype;
9206 player[i].lastseentime=12;
9209 if(player[i].ally>0){
9210 rotatetarget=player[player[i].ally].coords-player[i].coords;
9211 Normalise(&rotatetarget);
9212 player[i].targetrotation=-asin(0-rotatetarget.x);
9213 player[i].targetrotation*=360/6.28;
9214 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9215 player[i].lookrotation=player[i].targetrotation;
9216 player[i].aiupdatedelay=.05;
9217 player[i].forwardkeydown=1;
9219 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9220 player[i].aitype=searchtype;
9221 player[i].lastseentime=12;
9222 player[player[i].ally].aitype=searchtype;
9223 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9224 player[player[i].ally].lastseen=player[i].lastseen;
9225 player[player[i].ally].lastseentime=player[i].lastseentime;
9226 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9230 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9231 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9233 XYZ leftpos,rightpos;
9234 float leftdist,rightdist;
9235 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9236 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9237 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9238 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9239 if(leftdist<rightdist)player[i].targetrotation+=90;
9240 else player[i].targetrotation-=90;
9245 player[i].leftkeydown=0;
9246 player[i].backkeydown=0;
9247 player[i].rightkeydown=0;
9248 player[i].crouchkeydown=0;
9249 player[i].attackkeydown=0;
9251 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9252 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9255 if(player[i].aitype==getweapontype){
9256 player[i].aiupdatedelay-=multiplier;
9257 player[i].lastchecktime-=multiplier;
9259 if(player[i].aiupdatedelay<0){
9260 player[i].aiupdatedelay=.2;
9268 if(player[i].ally<0){
9269 for(j=0;j<weapons.numweapons;j++){
9270 if(weapons.owner[j]==-1){
9271 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9272 if(closestdist==-1||distance<closestdist){
9273 closestdist=distance;
9279 if(closest!=-1)player[i].ally=closest;
9280 else player[i].ally=-1;
9283 player[i].lastseentime=12;
9285 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9286 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9287 player[i].aitype=attacktypecutoff;
9288 player[i].lastseentime=1;
9291 if(player[i].ally>=0){
9292 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9293 player[i].aitype=attacktypecutoff;
9294 player[i].lastseentime=1;
9296 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9297 Normalise(&rotatetarget);
9298 player[i].targetrotation=-asin(0-rotatetarget.x);
9299 player[i].targetrotation*=360/6.28;
9300 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9301 player[i].lookrotation=player[i].targetrotation;
9302 player[i].aiupdatedelay=.05;
9303 player[i].forwardkeydown=1;
9306 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9307 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9309 XYZ leftpos,rightpos;
9310 float leftdist,rightdist;
9311 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9312 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9313 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9314 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9315 if(leftdist<rightdist)player[i].targetrotation+=90;
9316 else player[i].targetrotation-=90;
9319 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9320 if(abs(Random()%6)){
9321 player[i].crouchkeydown=1;
9322 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9323 if(player[i].isRun()){
9324 player[i].targetframe=0;
9326 player[i].targetanimation=sneakanim;
9329 else player[i].forwardkeydown=0;
9331 else player[i].crouchkeydown=0;
9333 else player[i].crouchkeydown=0;*/
9336 player[i].leftkeydown=0;
9337 player[i].backkeydown=0;
9338 player[i].rightkeydown=0;
9339 player[i].attackkeydown=0;
9340 player[i].throwkeydown=1;
9341 player[i].crouchkeydown=0;
9342 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9343 player[i].drawkeydown=0;
9345 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9346 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9349 if(player[i].aitype==attacktypecutoff){
9350 player[i].aiupdatedelay-=multiplier;
9351 if(player[i].damage<player[i].damagetolerance*2/3)
9352 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)){
9353 player[i].attackkeydown=0;
9354 if(player[i].isIdle())player[i].crouchkeydown=1;
9355 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9356 if(weapons.type[player[0].weaponids[0]]==knife){
9357 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9358 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9359 else player[i].targetanimation=rollanim;
9361 player[i].targetframe=0;
9362 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9363 player[i].wentforweapon=0;
9365 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9366 player[i].targetanimation=flipanim;
9368 player[i].targetframe=0;
9372 player[i].forwardkeydown=0;
9373 player[i].aiupdatedelay=.02;
9375 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9376 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9377 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9379 if(player[i].wentforweapon<3)
9380 for(j=0;j<weapons.numweapons;j++){
9381 if(player[i].creature!=wolftype)
9382 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){
9383 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9384 player[i].wentforweapon++;
9385 player[i].lastchecktime=6;
9386 player[i].aitype=getweapontype;
9391 if(player[i].damage<player[i].damagetolerance/2)
9392 if(animation[player[i].targetanimation].height!=highheight)
9393 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)))){
9394 player[i].crouchkeydown=1;
9396 if(player[i].isRun()&&!player[i].onground){
9397 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9398 test2=player[i].coords+player[i].facing;
9400 test=player[i].coords+player[i].facing;
9402 j=checkcollide(test2,test,player[i].laststanding);
9403 if(j==-1)j=checkcollide(test2,test);
9405 player[i].velocity=0;
9406 player[i].targetanimation=player[i].getStop();
9407 player[i].targetframe=0;
9409 player[i].targetrotation+=180;
9410 player[i].stunned=.5;
9411 //player[i].aitype=passivetype;
9412 player[i].aitype=pathfindtype;
9413 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9414 player[i].finalpathfindpoint=-1;
9415 player[i].targetpathfindpoint=-1;
9416 player[i].lastpathfindpoint=-1;
9417 player[i].lastpathfindpoint2=-1;
9418 player[i].lastpathfindpoint3=-1;
9419 player[i].lastpathfindpoint4=-1;
9421 else player[i].laststanding=j;
9424 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9425 player[i].aitype=pathfindtype;
9426 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9427 player[i].finalpathfindpoint=-1;
9428 player[i].targetpathfindpoint=-1;
9429 player[i].lastpathfindpoint=-1;
9430 player[i].lastpathfindpoint2=-1;
9431 player[i].lastpathfindpoint3=-1;
9432 player[i].lastpathfindpoint4=-1;
9434 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){
9435 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9436 else player[i].drawkeydown=0;
9437 player[i].rabbitkickenabled=Random()%2;
9438 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9439 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9440 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;
9441 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9442 Normalise(&rotatetarget);
9443 player[i].targetrotation=-asin(0-rotatetarget.x);
9444 player[i].targetrotation*=360/6.28;
9445 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9446 player[i].lookrotation=player[i].targetrotation;
9447 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9449 oldkey=player[i].forwardkeydown;
9450 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9451 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;
9452 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9453 else player[i].forwardkeydown=0;
9455 player[i].forwardkeydown=0;
9456 if(Random()%10==0)player[i].forwardkeydown=1;
9457 if(Random()%100==0){
9458 player[i].aitype=pathfindtype;
9459 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9460 player[i].finalpathfindpoint=-1;
9461 player[i].targetpathfindpoint=-1;
9462 player[i].lastpathfindpoint=-1;
9463 player[i].lastpathfindpoint2=-1;
9464 player[i].lastpathfindpoint3=-1;
9465 player[i].lastpathfindpoint4=-1;
9468 player[i].leftkeydown=0;
9469 player[i].backkeydown=0;
9470 player[i].rightkeydown=0;
9471 player[i].crouchkeydown=0;
9472 player[i].throwkeydown=0;
9474 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9475 /*for(j=0;j<numplayers;j++){
9476 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9477 player[i].crouchkeydown=1;
9480 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9481 else player[i].attackkeydown=0;
9482 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9483 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9484 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9485 player[i].attackkeydown=0;
9486 if(player[i].isIdle())player[i].crouchkeydown=1;
9487 player[i].forwardkeydown=0;
9488 player[i].aiupdatedelay=.02;
9491 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9493 for(j=0;j<numplayers;j++){
9494 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)){
9495 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))))){
9496 if(target>=0)target=-1;
9501 if(target>=0)player[target].Reverse();
9504 if(player[i].collided<1)player[i].jumpkeydown=0;
9505 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;
9506 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9507 player[0].jumpkeydown=0;
9508 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9509 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9510 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9512 if(tutoriallevel==1){
9513 if(!canattack)player[i].attackkeydown=0;
9517 facing=player[i].coords;
9518 flatfacing=player[0].coords;
9519 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9520 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9521 if(player[i].occluded>=2)
9522 if(-1!=checkcollide(facing,flatfacing)){
9523 if(!player[i].pause)player[i].lastseentime-=.2;
9524 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9525 player[i].aitype=searchtype;
9526 player[i].lastchecktime=12;
9527 player[i].lastseen=player[0].coords;
9528 player[i].lastseentime=12;
9531 else player[i].lastseentime=1;
9534 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9535 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9536 test=player[0].coords;
9538 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9541 // NOTE: Ask about logic of this call : NOTE
9542 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9543 player[i].stunned>0 ||
9544 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9546 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9547 player[i].targetrotation=player[i].rotation;
9548 player[i].forwardkeydown=0;
9549 player[i].leftkeydown=0;
9550 player[i].backkeydown=0;
9551 player[i].rightkeydown=0;
9552 player[i].jumpkeydown=0;
9553 player[i].attackkeydown=0;
9554 player[i].crouchkeydown=0;
9555 player[i].throwkeydown=0;
9562 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9565 if(player[i].aitype==attacktypecutoff){
9566 rotatetarget=player[0].coords-player[i].coords;
9567 Normalise(&rotatetarget);
9568 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9569 player[i].targetheadrotation*=360/6.28;
9570 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9572 player[i].targetheadrotation*=-1;
9573 player[i].targetheadrotation+=180;
9574 //player[i].targetheadrotation2=0;
9575 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9577 else if(player[i].howactive>=typesleeping){
9578 player[i].targetheadrotation=player[i].targetrotation;
9579 player[i].targetheadrotation2=0;
9582 if(player[i].interestdelay<=0){
9583 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9584 player[i].headtarget=player[i].coords;
9585 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9586 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9587 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9588 player[i].headtarget+=player[i].facing*1.5;
9590 rotatetarget=player[i].headtarget-player[i].coords;
9591 Normalise(&rotatetarget);
9592 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9593 player[i].targetheadrotation*=360/6.28;
9594 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9596 player[i].targetheadrotation*=-1;
9597 player[i].targetheadrotation+=180;
9598 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9600 //if(whichlevel==2)player[i].jumpkeydown=0;
9602 if(animation[player[i].targetanimation].attack==reversed){
9603 //player[i].targetrotation=player[i].rotation;
9604 player[i].forwardkeydown=0;
9605 player[i].leftkeydown=0;
9606 player[i].backkeydown=0;
9607 player[i].rightkeydown=0;
9608 player[i].jumpkeydown=0;
9609 player[i].attackkeydown=0;
9610 //player[i].crouchkeydown=0;
9611 player[i].throwkeydown=0;
9615 player[i].forwardkeydown=0;
9616 player[i].leftkeydown=0;
9617 player[i].backkeydown=0;
9618 player[i].rightkeydown=0;
9619 player[i].jumpkeydown=0;
9620 player[i].crouchkeydown=0;
9621 player[i].drawkeydown=0;
9622 player[i].throwkeydown=0;
9625 if(player[i].collided<-.3)player[i].collided=-.3;
9626 if(player[i].collided>1)player[i].collided=1;
9627 player[i].collided-=multiplier*4;
9628 player[i].whichdirectiondelay-=multiplier;
9629 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
9630 player[i].avoidcollided=-.3;
9631 player[i].whichdirection=abs(Random()%2);
9632 player[i].whichdirectiondelay=.4;
9634 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
9635 player[i].avoidcollided-=multiplier/4;
9636 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
9637 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
9638 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;
9640 if(!player[i].throwkeydown){
9641 player[i].throwtogglekeydown=0;
9643 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
9644 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)){
9645 for(j=0;j<weapons.numweapons;j++){
9646 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)
9647 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
9648 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
9649 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
9650 player[i].throwtogglekeydown=1;
9651 player[i].targetanimation=crouchremoveknifeanim;
9653 player[i].targetframe=0;
9654 rotatetarget=weapons.position[j]-player[i].coords;
9655 Normalise(&rotatetarget);
9656 player[i].targetrotation=-asin(0-rotatetarget.x);
9657 player[i].targetrotation*=360/6.28;
9658 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9659 player[i].hasvictim=0;
9661 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9662 player[i].throwtogglekeydown=1;
9663 player[i].hasvictim=0;
9665 //for(i=0;i<weapons.numweapons;i++){
9666 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))
9667 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
9668 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
9671 gLoc[0]=player[i].coords.x;
9672 gLoc[1]=player[i].coords.y;
9673 gLoc[2]=player[i].coords.z;
9674 vel[0]=player[i].velocity.x;
9675 vel[1]=player[i].velocity.y;
9676 vel[2]=player[i].velocity.z;
9677 if(weapons.type[j]!=staff){
9678 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9679 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9680 OPENAL_SetVolume(channels[knifedrawsound], 128);
9681 OPENAL_SetPaused(channels[knifedrawsound], false);
9684 player[i].weaponactive=0;
9685 weapons.owner[j]=player[i].id;
9686 if(player[i].num_weapons>0){
9687 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9689 player[i].num_weapons++;
9690 player[i].weaponids[0]=j;
9696 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){
9697 if(!player[i].isFlip()){
9698 player[i].throwtogglekeydown=1;
9699 player[i].targetanimation=removeknifeanim;
9701 player[i].targetframe=0;
9702 rotatetarget=weapons.position[j]-player[i].coords;
9703 Normalise(&rotatetarget);
9704 player[i].targetrotation=-asin(0-rotatetarget.x);
9705 player[i].targetrotation*=360/6.28;
9706 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9708 if(player[i].isFlip()){
9709 player[i].throwtogglekeydown=1;
9710 player[i].hasvictim=0;
9712 for(k=0;k<weapons.numweapons;k++){
9713 if(player[i].weaponactive==-1)
9714 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))
9715 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
9718 gLoc[0]=player[i].coords.x;
9719 gLoc[1]=player[i].coords.y;
9720 gLoc[2]=player[i].coords.z;
9721 vel[0]=player[i].velocity.x;
9722 vel[1]=player[i].velocity.y;
9723 vel[2]=player[i].velocity.z;
9724 if(weapons.type[k]!=staff){
9725 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9726 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9727 OPENAL_SetVolume(channels[knifedrawsound], 128);
9728 OPENAL_SetPaused(channels[knifedrawsound], false);
9731 player[i].weaponactive=0;
9732 weapons.owner[k]=player[i].id;
9733 if(player[i].num_weapons>0){
9734 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9736 player[i].num_weapons++;
9737 player[i].weaponids[0]=k;
9744 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9746 for(j=0;j<numplayers;j++){
9747 if(player[i].weaponactive==-1)
9749 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)){
9750 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
9751 player[i].throwtogglekeydown=1;
9752 player[i].victim=&player[j];
9753 player[i].hasvictim=1;
9754 player[i].targetanimation=crouchremoveknifeanim;
9756 player[i].targetframe=0;
9757 rotatetarget=player[j].coords-player[i].coords;
9758 Normalise(&rotatetarget);
9759 player[i].targetrotation=-asin(0-rotatetarget.x);
9760 player[i].targetrotation*=360/6.28;
9761 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9763 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9764 player[i].throwtogglekeydown=1;
9765 player[i].victim=&player[j];
9766 player[i].hasvictim=1;
9767 int k = player[j].weaponids[0];
9768 if(player[i].hasvictim){
9771 gLoc[0]=player[i].coords.x;
9772 gLoc[1]=player[i].coords.y;
9773 gLoc[2]=player[i].coords.z;
9774 vel[0]=player[i].velocity.x;
9775 vel[1]=player[i].velocity.y;
9776 vel[2]=player[i].velocity.z;
9779 if(player[i].victim->weaponstuck!=-1){
9780 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9785 if(weapons.type[k]!=staff){
9786 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9787 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9788 OPENAL_SetVolume(channels[knifedrawsound], 128);
9789 OPENAL_SetPaused(channels[knifedrawsound], false);
9793 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
9794 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
9795 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
9796 OPENAL_SetPaused(channels[fleshstabremovesound], false);
9799 player[i].weaponactive=0;
9800 if(weapons.owner[k]!=-1){
9801 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
9802 else player[i].victim->num_weapons=1;
9804 player[i].victim->skeleton.longdead=0;
9805 player[i].victim->skeleton.free=1;
9806 player[i].victim->skeleton.broken=0;
9808 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
9809 player[i].victim->skeleton.joints[l].velchange=0;
9810 player[i].victim->skeleton.joints[l].locked=0;
9816 Normalise(&relative);
9817 XYZ footvel,footpoint;
9819 footpoint=weapons.position[k];
9820 if(player[i].victim->weaponstuck!=-1){
9821 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9822 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
9823 weapons.bloody[k]=2;
9824 weapons.blooddrip[k]=5;
9825 player[i].victim->weaponstuck=-1;
9826 player[i].victim->bloodloss+=2000;
9827 player[i].victim->DoDamage(2000);
9830 if(player[i].victim->num_weapons>0){
9831 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
9832 if(player[i].victim->weaponids[0]==k)
9833 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
9836 player[i].victim->weaponactive=-1;
9838 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
9839 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
9840 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
9841 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
9844 if(player[i].num_weapons>0){
9845 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9847 player[i].num_weapons++;
9848 player[i].weaponids[0]=k;
9855 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9856 if(weapons.type[player[i].weaponids[0]]==knife){
9857 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
9859 for(j=0;j<numplayers;j++){
9861 if(tutoriallevel!=1||tutorialstage==49)
9863 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)){
9864 if(!player[i].isFlip()){
9865 player[i].throwtogglekeydown=1;
9866 player[i].victim=&player[j];
9867 player[i].targetanimation=knifethrowanim;
9869 player[i].targetframe=0;
9870 rotatetarget=player[j].coords-player[i].coords;
9871 Normalise(&rotatetarget);
9872 player[i].targetrotation=-asin(0-rotatetarget.x);
9873 player[i].targetrotation*=360/6.28;
9874 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9876 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
9878 if(player[i].isFlip()){
9879 if(player[i].weaponactive!=-1){
9880 player[i].throwtogglekeydown=1;
9881 player[i].victim=&player[j];
9883 weapons.owner[player[i].weaponids[0]]=-1;
9884 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);
9887 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
9889 weapons.velocity[player[i].weaponids[0]]=aim*50;
9890 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
9891 weapons.missed[player[i].weaponids[0]]=0;
9892 weapons.freetime[player[i].weaponids[0]]=0;
9893 weapons.firstfree[player[i].weaponids[0]]=1;
9894 weapons.physics[player[i].weaponids[0]]=0;
9895 player[i].num_weapons--;
9896 if(player[i].num_weapons){
9897 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
9899 player[i].weaponactive=-1;
9906 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9907 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
9909 player[i].throwtogglekeydown=1;
9910 weapons.owner[player[i].weaponids[0]]=-1;
9911 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
9912 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
9913 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
9914 weapons.missed[player[i].weaponids[0]]=1;
9915 weapons.freetime[player[i].weaponids[0]]=0;
9916 weapons.firstfree[player[i].weaponids[0]]=1;
9917 weapons.physics[player[i].weaponids[0]]=1;
9918 player[i].num_weapons--;
9919 if(player[i].num_weapons){
9920 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
9921 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
9924 player[i].weaponactive=-1;
9925 for(j=0;j<numplayers;j++){
9926 player[j].wentforweapon=0;
9933 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
9934 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)){
9935 //Setenvironment(1-environment);
9938 if(player[i].weaponactive!=-1){
9939 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
9941 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
9942 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
9943 player[i].targetanimation=drawrightanim;
9944 player[i].targetframe=0;
9946 player[i].drawtogglekeydown=1;
9948 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){
9949 player[i].targetanimation=drawleftanim;
9950 player[i].targetframe=0;
9952 player[i].drawtogglekeydown=1;
9954 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
9955 player[i].targetanimation=crouchdrawrightanim;
9956 player[i].targetframe=0;
9958 player[i].drawtogglekeydown=1;
9962 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){
9963 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
9964 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
9965 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
9966 player[i].targetframe=0;
9968 player[i].hasvictim=0;
9969 //player[i].attacktogglekeydown=1;
9973 if(!player[i].drawkeydown){
9974 player[i].drawtogglekeydown=0;
9981 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
9983 else absflatfacing=flatfacing;
9986 player[i].forwardkeydown=0;
9987 player[i].leftkeydown=0;
9988 player[i].backkeydown=0;
9989 player[i].rightkeydown=0;
9990 player[i].jumpkeydown=0;
9991 player[i].crouchkeydown=0;
9992 player[i].drawkeydown=0;
9993 player[i].throwkeydown=0;
9997 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
9998 if(!player[i].forwardkeydown){
9999 player[i].forwardstogglekeydown=0;
10001 if(player[i].crouchkeydown){
10005 player[i].superruntoggle=1;
10007 for(j=0;j<numplayers;j++){
10008 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10009 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10010 player[i].superruntoggle=0;
10017 for(j=0;j<numplayers;j++){
10018 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10019 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))){
10020 if(target>=0)target=-1;
10025 if(target>=0)player[target].Reverse();
10026 player[i].lowreversaldelay=.5;
10028 if(player[i].isIdle()){
10029 player[i].targetanimation=player[i].getCrouch();
10030 player[i].target=0;
10031 player[i].targetframe=0;
10032 player[i].transspeed=10;
10034 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10035 player[i].targetanimation=rollanim;
10036 player[i].target=0;
10037 player[i].targetframe=0;
10038 player[i].transspeed=20;
10041 if(!player[i].crouchkeydown){
10043 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10045 if(player[i].isCrouch()){
10047 for(j=0;j<numplayers;j++){
10048 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10049 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10050 if(target>=0)target=-1;
10055 if(target>=0)player[target].Reverse();
10056 player[i].highreversaldelay=.5;
10058 if(player[i].isCrouch()){
10059 if(!player[i].wasCrouch()){
10060 player[i].currentanimation=player[i].getCrouch();
10061 player[i].currentframe=0;
10063 player[i].target=0;
10064 player[i].targetanimation=player[i].getIdle();
10065 player[i].targetframe=0;
10066 player[i].transspeed=10;
10069 if(player[i].targetanimation==sneakanim){
10070 player[i].targetanimation=player[i].getIdle();
10071 player[i].target=0;
10072 player[i].targetframe=0;
10073 player[i].transspeed=10;
10076 if(player[i].forwardkeydown){
10077 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)){
10078 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10079 else player[i].targetanimation=player[i].getRun();
10080 player[i].target=0;
10081 player[i].targetframe=0;
10083 if(player[i].isCrouch()){
10084 player[i].targetanimation=sneakanim;
10085 if(player[i].wasCrouch())player[i].target=0;
10086 player[i].targetframe=0;
10088 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10089 player[i].targetanimation=climbanim;
10090 player[i].target=0;
10091 player[i].targetframe=1;
10092 player[i].jumpclimb=1;
10094 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10095 player[i].velocity+=absflatfacing*5*multiplier;
10097 player[i].forwardstogglekeydown=1;
10100 if (player[i].rightkeydown){
10101 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)){
10102 player[i].targetanimation=player[i].getRun();
10103 player[i].target=0;
10104 player[i].targetframe=0;
10106 if(player[i].isCrouch()){
10107 player[i].targetanimation=sneakanim;
10108 if(player[i].wasCrouch()) player[i].target=0;
10109 player[i].targetframe=0;
10111 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10112 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10114 player[i].targetrotation-=90;
10115 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10116 if(player[i].backkeydown)player[i].targetrotation-=45;
10119 if ( player[i].leftkeydown){
10120 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)){
10121 player[i].targetanimation=player[i].getRun();
10122 player[i].target=0;
10123 player[i].targetframe=0;
10125 if(player[i].isCrouch()){
10126 player[i].targetanimation=sneakanim;
10127 if(player[i].wasCrouch())player[i].target=0;
10128 player[i].targetframe=0;
10130 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10131 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10133 player[i].targetrotation+=90;
10134 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10135 if(player[i].backkeydown)player[i].targetrotation+=45;
10138 if(player[i].backkeydown){
10139 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)){
10140 player[i].targetanimation=player[i].getRun();
10141 player[i].target=0;
10142 player[i].targetframe=0;
10144 if(player[i].isCrouch()){
10145 player[i].targetanimation=sneakanim;
10146 if(player[i].wasCrouch())player[i].target=0;
10147 player[i].targetframe=0;
10149 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10150 player[i].velocity-=absflatfacing*5*multiplier;
10152 if(player[i].targetanimation==hanganim){
10153 player[i].currentanimation=jumpdownanim;
10154 player[i].targetanimation=jumpdownanim;
10155 player[i].target=0;
10156 player[i].currentframe=0;
10157 player[i].targetframe=1;
10158 player[i].velocity=0;
10159 player[i].velocity.y+=gravity;
10160 player[i].coords.y-=1.4;
10161 player[i].grabdelay=1;
10163 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10164 player[i].targetrotation+=180;
10167 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10168 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)){
10169 player[i].jumpstart=0;
10170 player[i].targetanimation=jumpupanim;
10171 player[i].target=0;
10172 player[i].targetframe=0;
10173 player[i].rotation=player[i].targetrotation;
10174 player[i].transspeed=20;
10175 player[i].FootLand(0,1);
10176 player[i].FootLand(1,1);
10180 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10182 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10183 if(!movekey)player[i].velocity=0;
10188 for(j=0;j<numplayers;j++){
10189 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10190 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10191 if(target>=0)target=-1;
10196 if(target>=0)player[i].velocity.y=1;
10197 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10198 player[i].velocity.y=7;
10199 player[i].crouchtogglekeydown=1;
10201 else player[i].velocity.y=5;
10203 if(mousejump&&i==0&&debugmode){
10204 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10205 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10208 player[i].coords.y+=.2;
10209 player[i].jumppower-=1;
10211 static float gLoc[3];
10212 static float vel[3];
10213 gLoc[0]=player[i].coords.x;
10214 gLoc[1]=player[i].coords.y;
10215 gLoc[2]=player[i].coords.z;
10216 vel[0]=player[i].velocity.x;
10217 vel[1]=player[i].velocity.y;
10218 vel[2]=player[i].velocity.z;
10221 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10222 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10223 OPENAL_SetVolume(channels[whooshsound], 128);
10224 OPENAL_SetPaused(channels[whooshsound], false);
10227 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10228 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10229 OPENAL_SetVolume(channels[jumpsound], 128);
10230 OPENAL_SetPaused(channels[jumpsound], false);
10232 if((player[i].isIdle())&&player[i].jumppower>1){
10233 player[i].targetanimation=player[i].getLanding();
10234 player[i].landhard=0;
10235 player[i].target=0;
10236 player[i].targetframe=2;
10237 player[i].jumpstart=1;
10238 player[i].tempdeltav=deltav;
10240 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10241 if(player[i].jumppower>multiplier*6){
10242 player[i].velocity.y+=multiplier*6;
10243 player[i].jumppower-=multiplier*6;
10245 if(player[i].jumppower<=multiplier*6){
10246 player[i].velocity.y+=player[i].jumppower;
10247 player[i].jumppower=0;
10250 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10254 if(player[i].isRun()||player[i].targetanimation==walkanim){
10255 player[i].targetanimation=player[i].getStop();
10256 player[i].target=0;
10257 player[i].targetframe=0;
10259 if(player[i].targetanimation==sneakanim){
10260 player[i].targetanimation=player[i].getCrouch();
10261 if(player[i].currentanimation==sneakanim)player[i].target=0;
10262 player[i].targetframe=0;
10265 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10266 player[i].targetanimation=player[i].getStop();
10267 player[i].target=0;
10268 player[i].targetframe=0;
10270 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10271 player[i].targetanimation=player[i].getStop();
10272 player[i].target=0;
10273 player[i].targetframe=0;
10277 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10281 for(k=0;k<numplayers;k++){
10282 if(abs(player[k].rotation-player[k].targetrotation)>180){
10283 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10284 else player[k].rotation+=360;
10287 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10288 player[k].targetanimation=player[k].getStop();
10289 player[k].targetframe=0;
10290 player[k].target=0;
10293 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10294 player[k].targettilt=0;
10296 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10297 player[k].targettilt=0;
10298 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10299 player[k].jumppower+=multiplier*7;
10300 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10301 //*(1-(player[k].damage/player[k].damagetolerance))
10302 if(player[k].jumppower>5)player[k].jumppower=5;
10305 if(player[k].isRun()){
10306 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10309 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10310 else if(player[k].tilt>player[k].targettilt){
10311 player[k].tilt-=multiplier*150;
10313 else if(player[k].tilt<player[k].targettilt){
10314 player[k].tilt+=multiplier*150;
10317 player[k].grabdelay-=multiplier;
10320 for(k=0;k<numplayers;k++){
10321 player[k].DoAnimations();
10322 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10323 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10328 player[0].righthandmorphstart=0;
10329 player[0].righthandmorphend=1;
10330 player[0].lefthandmorphstart=0;
10331 player[0].lefthandmorphend=1;
10332 player[0].headmorphstart=0;
10333 player[0].headmorphend=2;*/
10336 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10337 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10338 player[0].righthandmorphend=1;
10339 player[0].targetrighthandmorphness=1;
10341 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10342 player[0].lefthandmorphend=0;
10343 player[0].targetlefthandmorphness=1;
10345 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10346 player[0].headmorphend=2;
10347 player[0].targetheadmorphness=1;
10349 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10350 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10351 player[0].righthandmorphend=0;
10352 player[0].targetrighthandmorphness=1;
10354 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10355 player[0].lefthandmorphend=1;
10356 player[0].targetlefthandmorphness=1;
10358 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10359 player[0].headmorphend=0;
10360 player[0].targetheadmorphness=1;
10363 if(numenvsounds!=0)
10364 for(j=numenvsounds-1;j>=0;j--){
10365 envsoundlife[j]-=multiplier;
10366 if(envsoundlife[j]<0){
10368 envsoundlife[j]=envsoundlife[numenvsounds];
10369 envsound[j]=envsound[numenvsounds];
10372 if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
10373 if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
10375 if(tutoriallevel==1){
10392 if(tutorialstage>=51)
10393 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10394 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10395 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
10397 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10398 OPENAL_SetPaused(channels[stream_music3], false);
10399 OPENAL_SetVolume(channels[stream_music3], 256);
10404 float gLoc[3]={0,0,0};
10405 float vel[3]={0,0,0};
10406 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10407 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10408 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10409 OPENAL_SetVolume(channels[fireendsound], 256);
10410 OPENAL_SetPaused(channels[fireendsound], false);
10411 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10419 if(tutorialstage<51)
10420 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10423 gLoc[0]=player[0].coords.x;
10424 gLoc[1]=player[0].coords.y;
10425 gLoc[2]=player[0].coords.z;
10429 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10430 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10431 OPENAL_SetVolume(channels[fireendsound], 256);
10432 OPENAL_SetPaused(channels[fireendsound], false);
10434 player[0].coords=(oldtemp+oldtemp2)/2;
10442 if(tutorialstage>=14&&tutorialstage<50)
10443 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10446 gLoc[0]=player[1].coords.x;
10447 gLoc[1]=player[1].coords.y;
10448 gLoc[2]=player[1].coords.z;
10452 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10453 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10454 OPENAL_SetVolume(channels[fireendsound], 256);
10455 OPENAL_SetPaused(channels[fireendsound], false);
10457 for(int i=0;i<player[1].skeleton.num_joints;i++){
10459 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10460 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10461 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;
10462 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10463 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10467 player[1].coords=(oldtemp+oldtemp2)/2;
10468 for(int i=0;i<player[1].skeleton.num_joints;i++){
10469 player[1].skeleton.joints[i].velocity=0;
10471 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10472 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10473 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;
10474 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10475 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10483 static float gLoc[3];
10487 static float vel[3];
10488 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10489 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10490 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10492 //Set orientation with forward and up vectors
10493 static XYZ upvector;
10497 upvector=DoRotation(upvector,-rotation2+90,0,0);
10498 upvector=DoRotation(upvector,0,0-rotation,0);
10503 facing=DoRotation(facing,-rotation2,0,0);
10504 facing=DoRotation(facing,0,0-rotation,0);
10507 static float ori[6];
10508 ori[0] = -facing.x;
10510 ori[2] = -facing.z;
10511 ori[3] = -upvector.x;
10512 ori[4] = upvector.y;
10513 ori[5] = -upvector.z;
10515 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10522 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10524 freezetogglekeydown=1;
10528 void Game::TickOnce(){
10531 if(directing||indialogue==-1){
10532 rotation+=deltah*.7;
10533 if(!invertmouse)rotation2+=deltav*.7;
10534 if(invertmouse)rotation2-=deltav*.7;
10535 if(rotation2>90)rotation2=90;
10536 if(rotation2<-70)rotation2=-70;
10538 if(mainmenu)rotation+=multiplier*5;
10543 void Game::TickOnceAfter(){
10544 static XYZ colviewer;
10545 static XYZ coltarget;
10548 static float brotate;
10551 static float changedelay;
10552 static bool alldead;
10553 static float unseendelay;
10554 static float cameraspeed;
10558 if(environment==snowyenvironment)music1=stream_music1snow;
10559 if(environment==grassyenvironment)music1=stream_music1grass;
10560 if(environment==desertenvironment)music1=stream_music1desert;
10565 for(i=0;i<numplayers;i++){
10566 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)){
10567 musictype=stream_music2;
10571 if(player[0].dead)musictype=stream_music3;
10574 if(musictype==stream_music2){
10578 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10579 unseendelay-=multiplier;
10581 musictype=stream_music2;
10587 musictype=stream_music3;
10588 musicvolume[2]=512;
10595 if(musictype!=oldmusictype&&musictype==stream_music2){
10596 static float gLoc[3];
10597 static float vel[3];
10598 gLoc[0]=cameraloc.x;
10599 gLoc[1]=cameraloc.y;
10600 gLoc[2]=cameraloc.z;
10604 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
10605 OPENAL_SetVolume(channels[alarmsound], 512);
10606 OPENAL_SetPaused(channels[alarmsound], false);
10610 musicselected=musictype;
10612 if(musicselected==music1)musicvolume[0]+=multiplier*450;
10613 else musicvolume[0]-=multiplier*450;
10614 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
10615 else musicvolume[1]-=multiplier*450;
10616 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
10617 else musicvolume[2]-=multiplier*450;
10619 if(musicselected==music1)musicvolume[0]+=multiplier*100;
10620 else musicvolume[0]-=multiplier*450;
10621 if(musicselected==music2)musicvolume[1]+=multiplier*150;
10622 else if(player[0].dead)musicvolume[1]-=multiplier*450;
10623 else musicvolume[1]-=multiplier*100;
10624 if(musicselected==music3)musicvolume[2]+=multiplier*450;
10625 else musicvolume[2]-=multiplier*450;*/
10628 if(musicvolume[i]<0)musicvolume[i]=0;
10629 if(musicvolume[i]>512)musicvolume[i]=512;
10632 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
10635 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
10636 PlayStreamEx( music1, strm[music1], NULL, true);
10637 OPENAL_SetPaused(channels[music1], false);
10639 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
10640 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
10641 OPENAL_SetPaused(channels[stream_music2], false);
10643 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
10644 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10645 OPENAL_SetPaused(channels[stream_music3], false);
10650 OPENAL_SetPaused(channels[music1], true);
10651 OPENAL_SetPaused(channels[stream_music2], true);
10652 OPENAL_SetPaused(channels[stream_music3], true);
10655 oldmusicvolume[i]=0;
10661 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
10662 OPENAL_SetPaused(channels[music1], true);
10664 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
10665 OPENAL_SetPaused(channels[stream_music2], true);
10667 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
10668 OPENAL_SetPaused(channels[stream_music3], true);
10671 if(musicvolume[0]!=oldmusicvolume[0]){
10672 OPENAL_SetVolume(channels[music1], musicvolume[0]);
10674 if(musicvolume[1]!=oldmusicvolume[1]){
10675 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
10677 if(musicvolume[2]!=oldmusicvolume[2]){
10678 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
10682 oldmusicvolume[i]=musicvolume[i];
10688 for(i=0;i<numhotspots;i++){
10689 if(hotspottype[i]>10&&hotspottype[i]<20){
10690 if(player[hotspottype[i]-10].dead==0){
10693 else if(killhotspot==2)
10697 if(killhotspot==2)killhotspot=0;
10702 for(i=0;i<numhotspots;i++){
10703 if(hotspottype[i]==-1){
10704 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
10711 for(i=1;i<numplayers;i++){
10712 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
10714 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
10716 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
10717 if(player[0].dead&&changedelay<=0){
10719 targetlevel=whichlevel;
10723 for(i=1;i<numplayers;i++){
10724 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
10728 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
10730 targetlevel=whichlevel+1;
10731 if(targetlevel>numchallengelevels-1)targetlevel=0;
10733 if(winhotspot||windialogue){
10735 targetlevel=whichlevel+1;
10736 if(targetlevel>numchallengelevels-1)targetlevel=0;
10742 targetlevel=whichlevel+1;
10743 if(targetlevel>numchallengelevels-1)targetlevel=0;
10746 if(changedelay>0&&!player[0].dead&&!won){
10747 //high scores, awards, win
10750 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10751 accountcampaignchoicesmade[accountactive]++;
10752 accountcampaignscore[accountactive]+=bonustotal;
10754 accountcampaigntime[accountactive]+=leveltime;
10755 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
10757 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10763 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
10764 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
10766 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10782 if(!editorenabled&&gameon&&!mainmenu){
10783 if(changedelay!=-999)changedelay-=multiplier/7;
10784 if(player[0].dead)targetlevel=whichlevel;
10785 if(loading==2&&!campaign){
10793 float gLoc[3]={0,0,0};
10794 float vel[3]={0,0,0};
10795 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10796 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10797 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10798 OPENAL_SetVolume(channels[firestartsound], 256);
10799 OPENAL_SetPaused(channels[firestartsound], false);
10800 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10802 if(!player[0].dead&&targetlevel!=whichlevel){
10803 startbonustotal=bonustotal;
10805 if(!player[0].dead)Loadlevel(targetlevel);
10806 if(player[0].dead)Loadlevel(whichlevel);
10808 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10809 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10810 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10811 OPENAL_SetVolume(channels[fireendsound], 256);
10812 OPENAL_SetPaused(channels[fireendsound], false);
10813 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10817 if(loading==2&&targetlevel==whichlevel){
10825 float gLoc[3]={0,0,0};
10826 float vel[3]={0,0,0};
10827 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10828 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10829 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10830 OPENAL_SetVolume(channels[firestartsound], 256);
10831 OPENAL_SetPaused(channels[firestartsound], false);
10832 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10834 for(i=0;i<255;i++){
10848 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
10849 Loadlevel(mapname);
10851 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10852 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10853 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10854 OPENAL_SetVolume(channels[fireendsound], 256);
10855 OPENAL_SetPaused(channels[fireendsound], false);
10856 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10860 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
10861 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
10863 if(whichlevel!=-2&&!loading&&!player[0].dead){
10867 if(player[0].dead)loading=1;
10873 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
10874 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
10878 else if(mainmenu==0&&winfreeze){
10879 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
10881 else stealthloading=0;
10883 if(!stealthloading){
10884 float gLoc[3]={0,0,0};
10885 float vel[3]={0,0,0};
10886 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10887 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10888 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10889 OPENAL_SetVolume(channels[firestartsound], 256);
10890 OPENAL_SetPaused(channels[firestartsound], false);
10891 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10902 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
10903 //campaignnumlevels=0;
10904 //accountcampaignchoicesmade[accountactive]=0;
10905 ipstream.ignore(256,':');
10906 ipstream >> campaignnumlevels;
10907 for(i=0;i<campaignnumlevels;i++){
10908 ipstream.ignore(256,':');
10909 ipstream.ignore(256,':');
10910 ipstream.ignore(256,' ');
10911 ipstream >> campaignmapname[i];
10912 ipstream.ignore(256,':');
10913 ipstream >> campaigndescription[i];
10914 for(j=0;j<256;j++){
10915 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
10917 ipstream.ignore(256,':');
10918 ipstream >> campaignchoosenext[i];
10919 ipstream.ignore(256,':');
10920 ipstream >> campaignnumnext[i];
10921 if(campaignnumnext[i])
10922 for(j=0;j<campaignnumnext[i];j++){
10923 ipstream.ignore(256,':');
10924 ipstream >> campaignnextlevel[i][j];
10925 campaignnextlevel[i][j]-=1;
10927 ipstream.ignore(256,':');
10928 ipstream >> campaignlocationx[i];
10929 ipstream.ignore(256,':');
10930 ipstream >> campaignlocationy[i];
10934 for(i=0;i<campaignnumlevels;i++){
10936 levelhighlight[i]=0;
10940 for(i=0;i<campaignnumlevels;i++){
10942 levelhighlight[i]=0;
10947 if(accountcampaignchoicesmade[accountactive])
10948 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
10949 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
10950 levelvisible[levelorder[i+1]]=1;
10952 int whichlevelstart;
10953 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
10954 if(whichlevelstart<0){
10955 campaignchoicenum=1;
10956 campaignchoicewhich[0]=0;
10960 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
10961 if(campaignchoicenum)
10962 for(i=0;i<campaignchoicenum;i++){
10963 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
10964 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
10965 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
10972 //if(firstload)TickOnceAfter();
10973 if(!firstload)LoadStuff();
10975 for(i=0;i<255;i++){
10990 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10991 //accountcampaignchoicesmade[accountactive]++;
10994 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
10998 Loadlevel(mapname);
11002 OPENAL_SetPaused(channels[stream_music3], true);
11007 if(loading==3)loading=0;
11011 oldmusictype=musictype;
11017 facing=DoRotation(facing,-rotation2,0,0);
11018 facing=DoRotation(facing,0,0-rotation,0);
11019 viewerfacing=facing;
11023 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;
11024 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;
11026 if(player[0].skeleton.free){
11027 for(i=0;i<player[0].skeleton.num_joints;i++){
11028 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11029 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11033 if(player[0].skeleton.free!=2&&!autocam){
11035 if(findLengthfast(&player[0].velocity)>400){
11036 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11038 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11039 coltarget=target-cameraloc;
11040 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11042 Normalise(&coltarget);
11043 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11044 else cameraloc=cameraloc+coltarget*multiplier*8;
11046 if(editorenabled)cameraloc=target;
11047 cameradist+=multiplier*5;
11048 if(cameradist>2.3)cameradist=2.3;
11049 viewer=cameraloc-facing*cameradist;
11051 coltarget=cameraloc;
11052 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11053 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11054 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11055 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11057 coltarget=cameraloc;
11058 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11060 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11061 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11062 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11064 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11068 cameradist=findDistance(&viewer,&target);
11069 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11070 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11072 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11073 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11076 if(player[0].skeleton.free!=2&&autocam){
11078 if(findLengthfast(&player[0].velocity)>400){
11079 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11081 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11082 cameradist+=multiplier*5;
11083 if(cameradist>3.3)cameradist=3.3;
11084 coltarget=target-cameraloc;
11085 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11086 else if(findLengthfast(&coltarget)>1)
11088 Normalise(&coltarget);
11089 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11090 else cameraloc=cameraloc+coltarget*multiplier*8;
11092 if(editorenabled)cameraloc=target;
11095 coltarget=cameraloc;
11096 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11097 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11098 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11099 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11101 coltarget=cameraloc;
11102 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11104 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11105 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11106 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11108 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11112 cameradist=findDistance(&viewer,&target);
11113 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11114 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11116 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11117 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11120 if(camerashake>.8)camerashake=.8;
11121 //if(woozy>10)woozy=10;
11122 //woozy+=multiplier;
11124 if(player[0].dead)camerashake=0;
11125 if(player[0].dead)woozy=0;
11126 camerashake-=multiplier*2;
11127 blackout-=multiplier*2;
11128 //if(player[0].isCrouch())woozy-=multiplier*8;
11129 if(camerashake<0)camerashake=0;
11130 if(blackout<0)blackout=0;
11131 //if(woozy<0)woozy=0;
11133 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11134 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11135 viewer.z+=(float)(Random()%100)*.0005*camerashake;