2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <sys/types.h>
32 #include "openal_wrapper.h"
36 extern float multiplier;
38 extern int environment;
39 extern float texscale;
40 extern Terrain terrain;
41 extern OPENAL_SAMPLE *samp[100];
42 extern int channels[100];
43 extern Sprites sprites;
44 extern int kTextureSize;
45 extern float screenwidth,screenheight;
48 extern float texdetail;
49 extern Objects objects;
51 extern float slomodelay;
52 extern bool floatjump;
54 extern Animation animation[animation_count];
56 extern float texdetail;
57 extern GLubyte bloodText[512*512*3];
58 extern GLubyte wolfbloodText[512*512*3];
59 extern float terraindetail;
60 extern float camerashake;
62 extern float blackout;
63 extern bool cellophane;
64 extern bool musictoggle;
65 extern int difficulty;
66 extern Weapons weapons;
67 extern Person player[maxplayers];
68 extern int numplayers;
69 extern int bloodtoggle;
70 extern bool invertmouse;
72 extern float precipdelay;
73 extern XYZ viewerfacing;
74 extern bool ambientsound;
75 extern bool mousejump;
76 extern float viewdistance;
78 extern bool autoslomo;
79 extern bool keyboardfrozen;
80 extern int netdatanew;
81 extern bool loadingstuff;
82 extern char mapname[256];
83 extern XYZ windvector;
84 extern bool buttons[3];
85 extern bool debugmode;
88 extern int oldmainmenu;
89 extern bool visibleloading;
90 extern int loadscreencolor;
91 extern float flashamount,flashr,flashg,flashb;
92 extern int flashdelay;
93 extern XYZ envsound[30];
94 extern float envsoundvol[30];
95 extern int numenvsounds;
96 extern float envsoundlife[30];
97 extern float usermousesensitivity;
98 extern bool ismotionblur;
100 extern bool trilinear;
101 extern bool damageeffects;
102 extern bool showpoints;
103 extern bool texttoggle;
104 extern bool alwaysblur;
105 extern float gamespeed;
108 extern bool immediate;
109 extern bool velocityblur;
112 extern float bonusvalue;
113 extern float bonustotal;
114 extern float bonustime;
115 extern float startbonustotal;
116 extern float tintr,tintg,tintb;
117 extern float bonusnum[100];
118 extern bool skyboxtexture;
119 extern float skyboxr;
120 extern float skyboxg;
121 extern float skyboxb;
122 extern float skyboxlightr;
123 extern float skyboxlightg;
124 extern float skyboxlightb;
125 extern float fadestart;
126 extern float slomospeed;
127 extern float slomofreq;
128 extern int tutoriallevel;
129 extern float smoketex;
130 extern float tutorialstagetime;
131 extern int tutorialstage;
132 extern float tutorialmaxtime;
133 extern float tutorialsuccess;
134 extern bool againbonus;
135 extern bool reversaltrain;
136 extern bool canattack;
137 extern bool cananger;
138 extern float damagedealt;
139 extern float damagetaken;
141 extern int editoractive;
142 extern int editorpathtype;
143 extern bool oldbuttons[3];
145 extern float hostiletime;
147 extern bool gamestarted;
149 extern int numhotspots;
150 extern int winhotspot;
151 extern int windialogue;
152 extern int killhotspot;
153 extern XYZ hotspot[40];
154 extern int hotspottype[40];
155 extern float hotspotsize[40];
156 extern char hotspottext[40][256];
157 extern int currenthotspot;
159 extern int kBitsPerPixel;
162 extern int numaccounts;
163 extern int accountactive;
164 extern int accountdifficulty[10];
165 extern int accountprogress[10];
166 extern float accountpoints[10];
167 extern float accounthighscore[10][50];
168 extern float accountfasttime[10][50];
169 extern bool accountunlocked[10][60];
170 extern char accountname[10][256];
172 extern bool stillloading;
173 extern bool winfreeze;
176 extern int numflipfail;
178 extern int numstaffattack;
179 extern int numswordattack;
180 extern int numknifeattack;
181 extern int numunarmedattack;
182 extern int numescaped;
183 extern int numflipped;
184 extern int numwallflipped;
185 extern int numthrowkill;
186 extern int numafterkill;
187 extern int numreversals;
188 extern int numattacks;
189 extern int maxalarmed;
190 extern int numresponded;
192 extern int numdialogues;
193 extern int numdialogueboxes[max_dialogues];
194 extern int dialoguetype[max_dialogues];
195 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
196 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
197 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
198 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
199 extern char dialoguename[max_dialogues][max_dialoguelength][64];
200 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
201 extern XYZ participantlocation[max_dialogues][10];
202 extern int participantfocus[max_dialogues][max_dialoguelength];
203 extern int participantaction[max_dialogues][max_dialoguelength];
204 extern float participantrotation[max_dialogues][10];
205 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
206 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
207 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
208 extern int indialogue;
209 extern int whichdialogue;
210 extern int directing;
211 extern float dialoguetime;
212 extern int dialoguegonethrough[20];
214 extern bool campaign;
216 extern float oldgamespeed;
218 extern float accountcampaignhighscore[10];
219 extern float accountcampaignfasttime[10];
220 extern float accountcampaignscore[10];
221 extern float accountcampaigntime[10];
223 extern int accountcampaignchoicesmade[10];
224 extern int accountcampaignchoices[10][5000];
226 static const char *rabbitskin[] = {
227 ":Data:Textures:Fur3.jpg",
228 ":Data:Textures:Fur.jpg",
229 ":Data:Textures:Fur2.jpg",
230 ":Data:Textures:Lynx.jpg",
231 ":Data:Textures:Otter.jpg",
232 ":Data:Textures:Opal.jpg",
233 ":Data:Textures:Sable.jpg",
234 ":Data:Textures:Chocolate.jpg",
235 ":Data:Textures:BW2.jpg",
236 ":Data:Textures:WB2.jpg"
239 static const char *wolfskin[] = {
240 ":Data:Textures:Wolf.jpg",
241 ":Data:Textures:Darkwolf.jpg",
242 ":Data:Textures:Snowwolf.jpg"
245 #define STATIC_ASSERT(x) extern int s_a_dummy[2 * (!!(x)) - 1];
246 STATIC_ASSERT (rabbittype == 0 && wolftype == 1)
248 static const char **creatureskin[] = {rabbitskin, wolfskin};
250 /* Return true if PFX is a prefix of STR (case-insensitive). */
251 static bool stripfx(const char *str, const char *pfx)
253 return !strncasecmp(str, pfx, strlen(pfx));
256 /********************> Tick() <*****/
257 extern OPENAL_STREAM * strm[20];
258 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
259 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
261 extern void ScreenShot(const char * fname);
262 void Screenshot (void)
265 time_t t = time(NULL);
266 struct tm *tme = localtime(&t);
267 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);
270 mkdir("Screenshots");
272 mkdir("Screenshots", S_IRWXU);
275 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
278 GraphicsExportComponent QT_exporter;
279 OSErr MAC_error_code;
280 CGrafPtr MAC_currentPort;
281 GDHandle MAC_currentDevice;
282 unsigned char* MAC_pixels;
283 Rect MAC_picture_rectangle;
284 GWorldPtr MAC_offscreen_graphics_port;
286 static int numscreenshots=0;
289 static char buf[256];
290 if(numscreenshots==0){
321 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
322 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
323 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
324 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
345 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
346 //assert(MAC_gWorld != NULL);
348 // Allocate memory for loading image
349 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
350 if (MAC_pixels == NULL) {
351 //UTIL_Error("Could not create Texture data.");
356 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
358 // Make a picture Rectangle
359 MAC_picture_rectangle.left = 0;
360 MAC_picture_rectangle.right = screenwidth;
361 MAC_picture_rectangle.top = 0;
362 MAC_picture_rectangle.bottom = screenheight;
364 // Create new offscreen GWorld
365 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
366 if (MAC_error_code) {
367 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
369 //UTIL_Error("Could not create offscreen GWorld. ");
374 // Copy OpenGL Context to new GWorld
375 glReadBuffer(GL_FRONT);
376 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
379 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
380 unsigned char temp = MAC_pixels[byte+0];
381 MAC_pixels[byte+0] = MAC_pixels[byte+3];
382 MAC_pixels[byte+3] = MAC_pixels[byte+2];
383 MAC_pixels[byte+2] = MAC_pixels[byte+1];
384 MAC_pixels[byte+1] = temp;
387 // Flip the image :( This could probably be optimized
392 for (int horz = 0; horz < screenwidth; ++horz)
393 for (vert = 0; vert < screenheight / 2; ++vert) {
394 src_index = (screenwidth * vert + horz) * 4;
395 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
397 temp=MAC_pixels[src_index+0];
398 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
399 MAC_pixels[dst_index+0]=temp;
401 temp=MAC_pixels[src_index+1];
402 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
403 MAC_pixels[dst_index+1]=temp;
405 temp=MAC_pixels[src_index+2];
406 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
407 MAC_pixels[dst_index+2]=temp;
409 temp=MAC_pixels[src_index+3];
410 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
411 MAC_pixels[dst_index+3]=temp;
417 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
418 if (MAC_error_code) {
419 //UTIL_Warning("Unable to export screenshot.");
420 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
421 ::DisposeGWorld(MAC_offscreen_graphics_port);
426 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
427 if (MAC_error_code) {
428 ::CloseComponent(QT_exporter);
429 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
430 ::DisposeGWorld(MAC_offscreen_graphics_port);
432 //UTIL_Warning("Unable to export screenshot.");
436 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
437 if (MAC_error_code) {
438 ::CloseComponent(QT_exporter);
439 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
440 ::DisposeGWorld(MAC_offscreen_graphics_port);
442 //UTIL_Warning("Unable to export screenshot.");
446 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
447 if (MAC_error_code) {
448 ::CloseComponent(QT_exporter);
449 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
450 ::DisposeGWorld(MAC_offscreen_graphics_port);
452 //UTIL_Warning("Unable to export screenshot.");
456 ::CloseComponent(QT_exporter);
457 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
458 ::DisposeGWorld(MAC_offscreen_graphics_port);
465 void Game::SetUpLighting(){
466 if(environment==snowyenvironment){
472 light.ambient[2]=.44;
474 if(environment==desertenvironment){
479 light.ambient[1]=.35;
483 if(environment==grassyenvironment){
489 light.ambient[2]=.44;
500 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
501 light.color[0]*=(skyboxlightr+average)/2;
502 light.color[1]*=(skyboxlightg+average)/2;
503 light.color[2]*=(skyboxlightb+average)/2;
504 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
505 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
506 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
510 light.ambient[2]=0; */
513 int Game::findPathDist(int start,int end){
514 int i,j,k,smallestcount,count,connected;
515 int last,last2,last3,last4;
525 while(last!=end&&count<30){
527 for(j=0;j<numpathpoints;j++){
528 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
531 if(numpathpointconnect[j])
532 for(k=0;k<numpathpointconnect[j];k++){
533 if(pathpointconnect[j][k]==last)connected=1;
536 if(numpathpointconnect[last])
537 for(k=0;k<numpathpointconnect[last];k++){
538 if(pathpointconnect[last][k]==j)connected=1;
541 if(closest==-1||Random()%2==0){
552 if(count<smallestcount)smallestcount=count;
554 return smallestcount;
557 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
558 static XYZ colpoint,colviewer,coltarget;
559 static float minx,minz,maxx,maxz,miny,maxy;
568 if(minx>endpoint.x)minx=endpoint.x;
570 if(miny>endpoint.y)miny=endpoint.y;
572 if(minz>endpoint.z)minz=endpoint.z;
575 if(maxx<endpoint.x)maxx=endpoint.x;
577 if(maxy<endpoint.y)maxy=endpoint.y;
579 if(maxz<endpoint.z)maxz=endpoint.z;
588 for(i=0;i<objects.numobjects;i++){
589 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){
590 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
591 colviewer=startpoint;
593 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
598 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
603 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
604 static XYZ colpoint,colviewer,coltarget;
605 static float minx,minz,maxx,maxz,miny,maxy;
614 if(minx>endpoint.x)minx=endpoint.x;
616 if(miny>endpoint.y)miny=endpoint.y;
618 if(minz>endpoint.z)minz=endpoint.z;
621 if(maxx<endpoint.x)maxx=endpoint.x;
623 if(maxy<endpoint.y)maxy=endpoint.y;
625 if(maxz<endpoint.z)maxz=endpoint.z;
635 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){
636 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
637 colviewer=startpoint;
639 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
644 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
649 void Game::Setenvironment(int which)
653 LOG(" Setting environment...");
658 OPENAL_SetPaused(channels[music1snow], true);
659 OPENAL_SetPaused(channels[music1grass], true);
660 OPENAL_SetPaused(channels[music1desert], true);
661 OPENAL_SetPaused(channels[wind], true);
662 OPENAL_SetPaused(channels[desertambient], true);
664 OPENAL_SetPaused(channels[stream_music1snow], true);
665 OPENAL_SetPaused(channels[stream_music1grass], true);
666 OPENAL_SetPaused(channels[stream_music1desert], true);
667 OPENAL_SetPaused(channels[stream_wind], true);
668 OPENAL_SetPaused(channels[stream_desertambient], true);
671 if(environment==snowyenvironment){
675 //PlaySoundEx( wind, samp[wind], NULL, true);
676 PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
677 OPENAL_SetPaused(channels[stream_wind], false);
678 OPENAL_SetVolume(channels[stream_wind], 256);
681 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
682 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
683 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
684 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
686 OPENAL_Sample_Free(samp[footstepsound]);
687 OPENAL_Sample_Free(samp[footstepsound2]);
688 OPENAL_Sample_Free(samp[footstepsound3]);
689 OPENAL_Sample_Free(samp[footstepsound4]);
690 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
691 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
692 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
693 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
694 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
695 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
696 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
697 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
699 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
701 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
703 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
708 temptexdetail=texdetail;
709 if(texdetail>1)texdetail=4;
710 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
711 ":Data:Textures:Skybox(snow):Left.jpg",
712 ":Data:Textures:Skybox(snow):Back.jpg",
713 ":Data:Textures:Skybox(snow):Right.jpg",
714 ":Data:Textures:Skybox(snow):Up.jpg",
715 ":Data:Textures:Skybox(snow):Down.jpg",
716 ":Data:Textures:Skybox(snow):Cloud.jpg",
717 ":Data:Textures:Skybox(snow):Reflect.jpg");
722 texdetail=temptexdetail;
724 if(environment==desertenvironment){
727 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
728 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
729 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
730 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
734 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
735 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
736 OPENAL_SetPaused(channels[stream_desertambient], false);
737 OPENAL_SetVolume(channels[stream_desertambient], 256);
740 OPENAL_Sample_Free(samp[footstepsound]);
741 OPENAL_Sample_Free(samp[footstepsound2]);
742 OPENAL_Sample_Free(samp[footstepsound3]);
743 OPENAL_Sample_Free(samp[footstepsound4]);
744 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
745 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
746 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
747 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
748 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
749 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
750 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
751 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
753 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
755 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
757 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
761 temptexdetail=texdetail;
762 if(texdetail>1)texdetail=4;
763 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
764 ":Data:Textures:Skybox(sand):Left.jpg",
765 ":Data:Textures:Skybox(sand):Back.jpg",
766 ":Data:Textures:Skybox(sand):Right.jpg",
767 ":Data:Textures:Skybox(sand):Up.jpg",
768 ":Data:Textures:Skybox(sand):Down.jpg",
769 ":Data:Textures:Skybox(sand):Cloud.jpg",
770 ":Data:Textures:Skybox(sand):Reflect.jpg");
775 texdetail=temptexdetail;
777 if(environment==grassyenvironment){
780 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
781 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
782 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
783 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
786 PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
787 OPENAL_SetPaused(channels[stream_wind], false);
788 OPENAL_SetVolume(channels[stream_wind], 100);
791 OPENAL_Sample_Free(samp[footstepsound]);
792 OPENAL_Sample_Free(samp[footstepsound2]);
793 OPENAL_Sample_Free(samp[footstepsound3]);
794 OPENAL_Sample_Free(samp[footstepsound4]);
795 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass1.ogg"), OPENAL_HW3D, 0, 0);
796 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass2.ogg"), OPENAL_HW3D, 0, 0);
797 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
798 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
799 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
800 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
801 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
802 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
804 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
806 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
808 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
812 temptexdetail=texdetail;
813 if(texdetail>1)texdetail=4;
814 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
815 ":Data:Textures:Skybox(grass):Left.jpg",
816 ":Data:Textures:Skybox(grass):Back.jpg",
817 ":Data:Textures:Skybox(grass):Right.jpg",
818 ":Data:Textures:Skybox(grass):Up.jpg",
819 ":Data:Textures:Skybox(grass):Down.jpg",
820 ":Data:Textures:Skybox(grass):Cloud.jpg",
821 ":Data:Textures:Skybox(grass):Reflect.jpg");
825 texdetail=temptexdetail;
827 temptexdetail=texdetail;
829 terrain.load(":Data:Textures:heightmap.png");
831 texdetail=temptexdetail;
835 void Game::Loadlevel(int which){
838 if(which==0)Loadlevel((char *)":Data:Maps:map1");
839 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
840 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
841 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
842 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
843 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
844 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
845 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
846 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
847 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
848 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
849 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
850 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
851 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
852 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
853 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
854 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
855 else Loadlevel((char *)":Data:Maps:mapsave");
860 /*char * Game::MD5_string (unsigned char *string){
864 strcpy(temp2,(const char *)string);
865 strcat((char *)temp2,(const char *)"Lugaru");
866 sprintf (temp, "%d",strlen((char *)temp2));
867 strcat((char *)temp2,temp);
870 unsigned int len = strlen ( (char *)temp2);
872 context.update ((unsigned char *)temp2, len);
875 return context.hex_digest();
880 void Game::Loadlevel(char *name){
887 float headprop,legprop,armprop,bodyprop;
891 LOG(std::string("Loading level...") + name);
893 if(!gameon)visibleloading=1;
895 if(stealthloading)visibleloading=0;
897 if(!stillloading)loadtime=0;
902 if(tutoriallevel!=-1)tutoriallevel=0;
903 else tutoriallevel=1;
905 if(tutoriallevel==1)tutorialstage=0;
906 if(tutorialstage==0){
914 OPENAL_SetPaused(channels[whooshsound], true);
915 OPENAL_SetPaused(channels[stream_firesound], true);
917 // Change the map filename into something that is os specific
918 char *FixedFN = ConvertFileName(name);
922 tfile=fopen( FixedFN, "rb" );
925 OPENAL_SetPaused(channels[stream_firesound], true);
936 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
942 dialoguegonethrough[i]=0;
951 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
953 if(difficulty!=2)minimap=1;
990 bonustotal=startbonustotal;
996 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
997 OPENAL_SetVolume(channels[consolesuccesssound], 256);
998 OPENAL_SetPaused(channels[consolesuccesssound], false);
1005 terrain.numdecals=0;
1006 sprites.numsprites=0;
1007 for(i=0;i<objects.numobjects;i++)
1009 objects.model[i].numdecals=0;
1012 j=objects.numobjects;
1015 objects.DeleteObject(0);
1016 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1019 for(i=0;i<subdivision;i++)
1021 for(j=0;j<subdivision;j++)
1023 terrain.patchobjectnum[i][j]=0;
1026 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1029 weapons.numweapons=0;
1031 funpackf(tfile, "Bi", &mapvers);
1032 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1034 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1035 else maptype=mapkilleveryone;
1036 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1038 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1044 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1052 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1055 skyboxlightr=skyboxr;
1056 skyboxlightg=skyboxg;
1057 skyboxlightb=skyboxb;
1059 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);
1060 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1061 player[0].originalcoords=player[0].coords;
1062 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1064 for(j=0;j<player[0].num_weapons;j++)
1066 player[0].weaponids[j]=weapons.numweapons;
1067 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1068 weapons.owner[weapons.numweapons]=0;
1069 weapons.numweapons++;
1073 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1075 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1076 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1077 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1078 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1080 funpackf(tfile, "Bi", &player[0].numclothes);
1084 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1088 player[0].whichskin=0;
1089 player[0].creature=rabbittype;
1092 for(i=0;i<max_dialogues;i++)
1094 for(j=0;j<max_dialoguelength;j++)
1098 dialoguetext[i][j][k]='\0';
1102 dialoguename[i][j][k]='\0';
1107 player[0].lastattack=-1;
1108 player[0].lastattack2=-1;
1109 player[0].lastattack3=-1;
1113 funpackf(tfile, "Bi", &numdialogues);
1116 for(k=0;k<numdialogues;k++)
1118 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1119 funpackf(tfile, "Bi", &dialoguetype[k]);
1122 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1123 funpackf(tfile, "Bf", &participantrotation[k][l]);
1125 if(numdialogueboxes)
1127 for(l=0;l<numdialogueboxes[k];l++)
1129 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1130 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1131 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1132 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1133 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1137 funpackf(tfile, "Bi",&templength);
1138 if(templength>128||templength<=0)templength=128;
1139 for(m=0;m<templength;m++){
1140 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1141 if(dialoguetext[k][l][m]=='\0')break;
1144 funpackf(tfile, "Bi",&templength);
1145 if(templength>64||templength<=0)templength=64;
1146 for(m=0;m<templength;m++){
1147 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1148 if(dialoguename[k][l][m]=='\0'){
1152 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1153 funpackf(tfile, "Bi", &participantfocus[k][l]);
1154 funpackf(tfile, "Bi", &participantaction[k][l]);
1157 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1159 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1165 else numdialogues=0;
1167 if(player[0].numclothes)
1169 for(k=0;k<player[0].numclothes;k++)
1171 funpackf(tfile, "Bi", &templength);
1172 for(l=0;l<templength;l++)
1173 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1174 player[0].clothes[k][templength]='\0';
1175 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1179 funpackf(tfile, "Bi", &environment);
1181 funpackf(tfile, "Bi", &objects.numobjects);
1182 if(objects.numobjects)
1184 for(i=0;i<objects.numobjects;i++)
1186 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]);
1187 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1193 funpackf(tfile, "Bi", &numhotspots);
1196 for(i=0;i<numhotspots;i++)
1198 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1199 funpackf(tfile, "Bi", &templength);
1201 for(l=0;l<templength;l++)
1202 funpackf(tfile, "Bb", &hotspottext[i][l]);
1203 hotspottext[i][templength]='\0';
1204 if(hotspottype[i]==-111)indemo=1;
1210 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1215 for(i=0;i<objects.numobjects;i++)
1217 objects.center+=objects.position[i];
1219 objects.center/=objects.numobjects;
1222 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1224 float maxdistance=0;
1227 for(i=0;i<objects.numobjects;i++)
1229 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1230 if(tempdist>maxdistance)
1233 maxdistance=tempdist;
1236 objects.radius=fast_sqrt(maxdistance);
1239 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1240 //mapcenter=objects.center;
1241 //mapradius=objects.radius;
1243 funpackf(tfile, "Bi", &numplayers);
1244 int howmanyremoved=0;
1245 bool removeanother=0;
1246 if(numplayers>1&&numplayers<maxplayers)
1248 for(i=1;i<numplayers;i++)
1250 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1253 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);
1254 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1255 else player[i-howmanyremoved].howactive=typeactive;
1256 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1257 else player[i-howmanyremoved].scale=-1;
1258 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1259 else player[i-howmanyremoved].immobile=0;
1260 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1261 else player[i-howmanyremoved].rotation=0;
1262 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1263 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1269 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1271 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1273 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1274 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1275 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1276 weapons.numweapons++;
1279 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1280 //player[i-howmanyremoved].numwaypoints=10;
1281 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1283 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1284 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1285 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1286 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1287 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1290 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1291 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1293 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1294 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1295 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1296 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1298 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1306 if(player[i-howmanyremoved].creature==wolftype)
1308 player[i-howmanyremoved].proportionhead=1.1*headprop;
1309 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1310 player[i-howmanyremoved].proportionarms=1.1*armprop;
1311 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1314 if(player[i-howmanyremoved].creature==rabbittype)
1316 player[i-howmanyremoved].proportionhead=1.2*headprop;
1317 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1318 player[i-howmanyremoved].proportionarms=1.00*armprop;
1319 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1320 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1323 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1324 if(player[i-howmanyremoved].numclothes)
1326 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1329 funpackf(tfile, "Bi", &templength);
1330 for(l=0;l<templength;l++)
1331 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1332 player[i-howmanyremoved].clothes[k][templength]='\0';
1333 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1339 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1341 numplayers-=howmanyremoved;
1342 funpackf(tfile, "Bi", &numpathpoints);
1343 if(numpathpoints>30||numpathpoints<0)
1347 for(j=0;j<numpathpoints;j++)
1349 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1350 for(k=0;k<numpathpointconnect[j];k++){
1351 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1355 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1357 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1360 if(environment!=oldenvironment)Setenvironment(environment);
1361 oldenvironment=environment;
1365 j=objects.numobjects;
1366 objects.numobjects=0;
1369 //if(objects.type[i]!=spiketype)
1370 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1371 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1374 //if(skyboxtexture){
1375 terrain.DoShadows();
1376 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1377 objects.DoShadows();
1378 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1380 else terrain.DoLighting();
1386 oldlevel=whichlevel;
1389 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1390 for(i=0;i<numplayers;i++)
1392 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1396 if(i==0||player[i].scale<0)player[i].scale=.2;
1397 player[i].skeleton.free=0;
1398 player[i].skeleton.id=i;
1399 //if(Random()%2==0)player[i].creature=wolftype;
1400 //else player[i].creature=rabbittype;
1401 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1402 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);
1405 if(player[i].creature!=wolftype){
1406 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);
1407 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1409 if(player[i].creature==wolftype){
1410 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);
1416 texsize=512*512*3/texdetail/texdetail;
1417 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1418 //player[i].skeleton.skinText.resize(texsize);
1420 LoadTextureSave(creatureskin[player[i].creature][player[i].whichskin],&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1422 if(player[i].numclothes)
1424 for(j=0;j<player[i].numclothes;j++)
1426 tintr=player[i].clothestintr[j];
1427 tintg=player[i].clothestintg[j];
1428 tintb=player[i].clothestintb[j];
1429 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1431 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1434 player[i].currentanimation=bounceidleanim;
1435 player[i].targetanimation=bounceidleanim;
1436 player[i].currentframe=0;
1437 player[i].targetframe=1;
1439 player[i].speed=1+(float)(Random()%100)/1000;
1440 if(difficulty==0)player[i].speed-=.2;
1441 if(difficulty==1)player[i].speed-=.1;
1443 player[i].velocity=0;
1444 player[i].oldcoords=player[i].coords;
1445 player[i].realoldcoords=player[i].coords;
1448 player[i].skeleton.id=i;
1449 player[i].updatedelay=0;
1450 player[i].normalsupdatedelay=0;
1452 player[i].aitype=passivetype;
1453 player[i].aitarget=0;
1454 player[i].madskills=0;
1458 player[i].proportionhead=1.2;
1459 player[i].proportionbody=1.05;
1460 player[i].proportionarms=1.00;
1461 player[i].proportionlegs=1.1;
1462 player[i].proportionlegs.y=1.05;
1464 player[i].headless=0;
1465 player[i].currentoffset=0;
1466 player[i].targetoffset=0;
1467 /*player[i].armorhead=1;
1468 player[i].armorhigh=1;
1469 player[i].armorlow=1;
1470 player[i].protectionhead=1;
1471 player[i].protectionhigh=1;
1472 player[i].protectionlow=1;
1473 player[i].metalhead=1;
1474 player[i].metalhigh=1;
1475 player[i].metallow=1;
1477 player[i].speedmult=1;*/
1479 player[i].damagetolerance=200;
1481 if(player[i].creature==wolftype)
1483 /*player[i].proportionhead=1.1;
1484 player[i].proportionbody=1.1;
1485 player[i].proportionarms=1.1;
1486 player[i].proportionlegs=1.1;
1487 player[i].proportionlegs.y=1.1;*/
1488 if(i==0||player[i].scale<0)player[i].scale=.23;
1490 player[i].damagetolerance=300;
1493 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1496 player[i].proportionhead.z=0;
1497 player[i].proportionbody.z=0;
1498 player[i].proportionarms.z=0;
1499 player[i].proportionlegs.z=0;
1502 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1504 player[i].headmorphness=0;
1505 player[i].targetheadmorphness=1;
1506 player[i].headmorphstart=0;
1507 player[i].headmorphend=0;
1509 player[i].pausetime=0;
1512 player[i].jumppower=5;
1514 player[i].permanentdamage=0;
1515 player[i].superpermanentdamage=0;
1517 player[i].forwardkeydown=0;
1518 player[i].leftkeydown=0;
1519 player[i].backkeydown=0;
1520 player[i].rightkeydown=0;
1521 player[i].jumpkeydown=0;
1522 player[i].crouchkeydown=0;
1523 player[i].throwkeydown=0;
1525 player[i].collided=-10;
1527 player[i].bloodloss=0;
1528 player[i].weaponactive=-1;
1529 player[i].weaponstuck=-1;
1530 player[i].bleeding=0;
1531 player[i].deathbleeding=0;
1532 player[i].stunned=0;
1533 player[i].hasvictim=0;
1534 player[i].wentforweapon=0;
1537 player[0].aitype=playercontrolled;
1538 player[0].weaponactive=-1;
1542 //player[0].speedmult=1/.9;
1543 player[0].power=1/.9;
1548 //player[0].speedmult=1/.8;
1549 player[0].power=1/.8;
1552 //player[0].weaponstuck=1;
1554 if(difficulty==1)player[0].damagetolerance=250;
1555 if(difficulty==0)player[0].damagetolerance=300;
1556 if(difficulty==0)player[0].armorhead*=1.5;
1557 if(difficulty==0)player[0].armorhigh*=1.5;
1558 if(difficulty==0)player[0].armorlow*=1.5;
1559 cameraloc=player[0].coords;
1561 rotation=player[0].rotation;
1563 hawkcoords=player[0].coords;
1566 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1567 //weapons.numweapons=numplayers;
1568 for(i=0;i<weapons.numweapons;i++)
1570 weapons.bloody[i]=0;
1571 weapons.blooddrip[i]=0;
1572 weapons.blooddripdelay[i]=0;
1573 weapons.onfire[i]=0;
1574 weapons.flamedelay[i]=0;
1575 weapons.damage[i]=0;
1576 //weapons.type[i]=sword;
1577 if(weapons.type[i]==sword){
1578 weapons.mass[i]=1.5;
1579 weapons.tipmass[i]=1;
1580 weapons.length[i]=.8;
1582 if(weapons.type[i]==staff){
1584 weapons.tipmass[i]=1;
1585 weapons.length[i]=1.5;
1587 if(weapons.type[i]==knife){
1589 weapons.tipmass[i]=1.2;
1590 weapons.length[i]=.25;
1592 weapons.position[i]=-1000;
1593 weapons.tippoint[i]=-1000;
1596 /* for(i=0;i<32;i++){
1598 OPENAL_StopSound(i);
1601 LOG("Starting background music...");
1603 OPENAL_StopSound(OPENAL_ALL);
1604 if(environment==snowyenvironment)
1608 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1609 OPENAL_SetPaused(channels[stream_wind], false);
1610 OPENAL_SetVolume(channels[stream_wind], 256);
1613 else if(environment==desertenvironment)
1617 //PlaySoundEx(desertambient,
1618 // samp[desertambient], NULL, true);
1619 PlayStreamEx(stream_desertambient,
1620 strm[stream_desertambient], NULL, true);
1621 OPENAL_SetPaused(channels[stream_desertambient], false);
1622 OPENAL_SetVolume(channels[stream_desertambient], 256);
1625 else if(environment==grassyenvironment)
1629 //PlaySoundEx(wind, samp[wind], NULL, true);
1630 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1631 OPENAL_SetPaused(channels[stream_wind], false);
1632 OPENAL_SetVolume(channels[stream_wind], 100);
1635 oldmusicvolume[0]=0;
1636 oldmusicvolume[1]=0;
1637 oldmusicvolume[2]=0;
1638 oldmusicvolume[3]=0;
1641 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1642 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1643 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1644 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1645 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1646 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1647 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1648 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1663 static int i,k,j,l,m;
1664 static XYZ facing,flatfacing,absflatfacing;
1665 static XYZ rotatetarget;
1667 static float oldtargetrotation;
1668 static int target, numgood;
1669 static XYZ tempcoords1,tempcoords2;
1672 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1673 static int whichhit;
1674 static bool donesomething;
1675 static bool oldjumpkeydown;
1679 float headprop,bodyprop,armprop,legprop;
1682 displaytime[i]+=multiplier;
1685 static unsigned char theKeyMap[16];
1686 GetKeys( theKeyMap );
1691 static bool mainmenutogglekeydown;
1693 if(mainmenu&&endgame==1)mainmenu=10;
1694 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1696 displaytext[0][j]=' ';
1701 mainmenutogglekeydown=1;
1703 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)){
1705 if(mainmenu==1||mainmenu==2||mainmenu==0){
1706 if(mainmenu==0&&!winfreeze)mainmenu=2;
1707 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1708 else if(mainmenu==0&&winfreeze){
1709 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1711 else stealthloading=0;
1713 if(!stealthloading){
1714 float gLoc[3]={0,0,0};
1715 float vel[3]={0,0,0};
1716 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1717 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1718 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1719 OPENAL_SetVolume(channels[firestartsound], 256);
1720 OPENAL_SetPaused(channels[firestartsound], false);
1721 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1732 for(i=0;i<campaignnumlevels;i++){
1734 levelhighlight[i]=0;
1739 if(accountcampaignchoicesmade[accountactive])
1740 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1741 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1742 levelvisible[levelorder[i+1]]=1;
1744 int whichlevelstart;
1745 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1746 if(whichlevelstart<0){
1747 campaignchoicenum=1;
1748 campaignchoicewhich[0]=0;
1752 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1753 if(campaignchoicenum)
1754 for(i=0;i<campaignchoicenum;i++){
1755 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1756 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1757 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1764 if(firstload)TickOnceAfter();
1765 if(!firstload)LoadStuff();
1782 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1783 //accountcampaignchoicesmade[accountactive]++;
1786 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1794 OPENAL_SetPaused(channels[music3], true);
1798 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1799 if(mainmenu&&musictoggle){
1800 if(mainmenu==1||mainmenu==2||mainmenu==100){
1801 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
1802 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1803 OPENAL_SetPaused(channels[stream_music3], false);
1804 OPENAL_SetVolume(channels[stream_music3], 256);
1805 OPENAL_SetPaused(channels[music1], true);
1809 OPENAL_SetPaused(channels[stream_music3], true);
1810 OPENAL_SetPaused(channels[music1], false);
1814 float gLoc[3]={0,0,0};
1815 float vel[3]={0,0,0};
1816 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1817 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1818 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1819 OPENAL_SetVolume(channels[fireendsound], 256);
1820 OPENAL_SetPaused(channels[fireendsound], false);
1821 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1829 if(newdetail>2)newdetail=detail;
1830 if(newdetail<0)newdetail=detail;
1831 if(newscreenwidth<0)newscreenwidth=screenwidth;
1832 if(newscreenheight<0)newscreenheight=screenheight;
1834 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1835 opstream << "Screenwidth:\n";
1836 opstream << newscreenwidth;
1837 opstream << "\nScreenheight:\n";
1838 opstream << newscreenheight;
1839 opstream << "\nMouse sensitivity:\n";
1840 opstream << usermousesensitivity;
1841 opstream << "\nBlur(0,1):\n";
1842 opstream << ismotionblur;
1843 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1844 opstream << newdetail;
1845 opstream << "\nFloating jump:\n";
1846 opstream << floatjump;
1847 opstream << "\nMouse jump:\n";
1848 opstream << mousejump;
1849 opstream << "\nAmbient sound:\n";
1850 opstream << ambientsound;
1851 opstream << "\nBlood (0,1,2):\n";
1852 opstream << bloodtoggle;
1853 opstream << "\nAuto slomo:\n";
1854 opstream << autoslomo;
1855 opstream << "\nFoliage:\n";
1856 opstream << foliage;
1857 opstream << "\nMusic:\n";
1858 opstream << musictoggle;
1859 opstream << "\nTrilinear:\n";
1860 opstream << trilinear;
1861 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1863 opstream << "\nInvert mouse:\n";
1864 opstream << invertmouse;
1865 opstream << "\nGamespeed:\n";
1866 if(oldgamespeed==0)oldgamespeed=1;
1867 opstream << oldgamespeed;
1868 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1869 opstream << difficulty;
1870 opstream << "\nDamage effects(blackout, doublevision):\n";
1871 opstream << damageeffects;
1872 opstream << "\nText:\n";
1873 opstream << texttoggle;
1874 opstream << "\nDebug:\n";
1875 opstream << debugmode;
1876 opstream << "\nVBL Sync:\n";
1877 opstream << vblsync;
1878 opstream << "\nShow Points:\n";
1879 opstream << showpoints;
1880 opstream << "\nAlways Blur:\n";
1881 opstream << alwaysblur;
1882 opstream << "\nImmediate mode (turn on on G5):\n";
1883 opstream << immediate;
1884 opstream << "\nVelocity blur:\n";
1885 opstream << velocityblur;
1886 opstream << "\nVolume:\n";
1888 opstream << "\nForward key:\n";
1889 opstream << KeyToChar(forwardkey);
1890 opstream << "\nBack key:\n";
1891 opstream << KeyToChar(backkey);
1892 opstream << "\nLeft key:\n";
1893 opstream << KeyToChar(leftkey);
1894 opstream << "\nRight key:\n";
1895 opstream << KeyToChar(rightkey);
1896 opstream << "\nJump key:\n";
1897 opstream << KeyToChar(jumpkey);
1898 opstream << "\nCrouch key:\n";
1899 opstream << KeyToChar(crouchkey);
1900 opstream << "\nDraw key:\n";
1901 opstream << KeyToChar(drawkey);
1902 opstream << "\nThrow key:\n";
1903 opstream << KeyToChar(throwkey);
1904 opstream << "\nAttack key:\n";
1905 opstream << KeyToChar(attackkey);
1906 opstream << "\nChat key:\n";
1907 opstream << KeyToChar(chatkey);
1910 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
1911 float gLoc[3]={0,0,0};
1912 float vel[3]={0,0,0};
1913 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1914 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1915 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1916 OPENAL_SetVolume(channels[fireendsound], 256);
1917 OPENAL_SetPaused(channels[fireendsound], false);
1918 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1926 if(mainmenu==3&&gameon)mainmenu=2;
1927 if(mainmenu==3&&!gameon)mainmenu=1;
1928 if(mainmenu==5&&gameon)mainmenu=2;
1929 if(mainmenu==5&&!gameon)mainmenu=1;
1930 if(mainmenu==4)mainmenu=3;
1931 if(mainmenu==6)mainmenu=5;
1932 if(mainmenu==7)mainmenu=1;
1933 if(mainmenu==9)mainmenu=5;
1934 if(mainmenu==11)mainmenu=5;
1935 if(mainmenu==13)mainmenu=12;
1936 if(mainmenu==10)mainmenu=5;
1942 mainmenutogglekeydown=1;
1944 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1945 mainmenutogglekeydown=0;
1949 /*static bool minimaptogglekeydown;
1950 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1952 minimaptogglekeydown=1;
1954 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1955 minimaptogglekeydown=0;
1959 static bool minimaptogglekeydown;
1960 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
1961 if(tutorialstage!=51)
1962 tutorialstagetime=tutorialmaxtime;
1963 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
1964 OPENAL_SetVolume(channels[consolefailsound], 128);
1965 OPENAL_SetPaused(channels[consolefailsound], false);
1966 minimaptogglekeydown=1;
1968 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1969 minimaptogglekeydown=0;
1974 if(mainmenu==1||mainmenu==2){
1975 if(Button()&&!oldbutton&&selected==1){
1977 float gLoc[3]={0,0,0};
1978 float vel[3]={0,0,0};
1979 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1980 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1981 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1982 OPENAL_SetVolume(channels[firestartsound], 256);
1983 OPENAL_SetPaused(channels[firestartsound], false);
1984 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1993 if(accountactive!=-1)mainmenu=5;
2000 if(firstload)TickOnceAfter();
2001 if(!firstload)LoadStuff();
2007 OPENAL_SetPaused(channels[music3], true); */
2013 OPENAL_SetPaused(channels[stream_music3], true);
2014 OPENAL_SetPaused(channels[music1], false);
2018 if(Button()&&!oldbutton&&selected==2){
2019 float gLoc[3]={0,0,0};
2020 float vel[3]={0,0,0};
2021 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2022 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2023 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2024 OPENAL_SetVolume(channels[firestartsound], 256);
2025 OPENAL_SetPaused(channels[firestartsound], false);
2026 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2038 if(newdetail>2)newdetail=detail;
2039 if(newdetail<0)newdetail=detail;
2040 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2041 if(newscreenwidth<0)newscreenwidth=screenwidth;
2042 if(newscreenheight>3000)newscreenheight=screenheight;
2043 if(newscreenheight<0)newscreenheight=screenheight;
2046 if(Button()&&!oldbutton&&selected==3){
2047 float gLoc[3]={0,0,0};
2048 float vel[3]={0,0,0};
2049 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2050 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2051 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2052 OPENAL_SetVolume(channels[fireendsound], 256);
2053 OPENAL_SetPaused(channels[fireendsound], false);
2054 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2065 OPENAL_SetPaused(channels[stream_music3], true);
2073 if(Button())oldbutton=1;
2078 if(Button()&&!oldbutton&&selected!=-1){
2079 float gLoc[3]={0,0,0};
2080 float vel[3]={0,0,0};
2081 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2082 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2083 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2084 OPENAL_SetVolume(channels[firestartsound], 256);
2085 OPENAL_SetPaused(channels[firestartsound], false);
2086 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2088 if(Button()&&!oldbutton&&selected==0){
2090 extern SDL_Rect **resolutions;
2091 bool isCustomResolution = true;
2093 for (int i = 0; (!found) && (resolutions[i]); i++)
2095 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2096 isCustomResolution = false;
2098 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2101 if (resolutions[i] != NULL)
2103 newscreenwidth = (int) resolutions[i]->w;
2104 newscreenheight = (int) resolutions[i]->h;
2106 else if (isCustomResolution)
2108 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2110 newscreenwidth = (int) resolutions[0]->w;
2111 newscreenheight = (int) resolutions[0]->h;
2115 newscreenwidth = screenwidth;
2116 newscreenheight = screenheight;
2121 newscreenwidth = (int) resolutions[0]->w;
2122 newscreenheight = (int) resolutions[0]->h;
2130 newscreenwidth = (int) resolutions[0]->w;
2131 newscreenheight = (int) resolutions[0]->h;
2136 if(Button()&&!oldbutton&&selected==1){
2138 if(newdetail>2)newdetail=0;
2140 if(Button()&&!oldbutton&&selected==2){
2142 if(bloodtoggle>2)bloodtoggle=0;
2144 if(Button()&&!oldbutton&&selected==3){
2146 if(difficulty>2)difficulty=0;
2148 if(Button()&&!oldbutton&&selected==4){
2149 ismotionblur=1-ismotionblur;
2151 if(Button()&&!oldbutton&&selected==5){
2154 if(Button()&&!oldbutton&&selected==6){
2155 musictoggle=1-musictoggle;
2158 OPENAL_SetPaused(channels[music1], true);
2159 OPENAL_SetPaused(channels[stream_music2], true);
2160 OPENAL_SetPaused(channels[stream_music3], true);
2163 oldmusicvolume[i]=0;
2169 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2170 OPENAL_SetPaused(channels[stream_music3], false);
2171 OPENAL_SetVolume(channels[stream_music3], 256);
2174 if(Button()&&!oldbutton&&selected==9){
2175 invertmouse=1-invertmouse;
2177 if(Button()&&!oldbutton&&selected==10){
2178 usermousesensitivity+=.2;
2179 if(usermousesensitivity>2)usermousesensitivity=.2;
2181 if(Button()&&!oldbutton&&selected==11){
2183 if(volume>1.0001f)volume=0;
2184 OPENAL_SetSFXMasterVolume((int)(volume*255));
2186 if(Button()&&!oldbutton&&selected==7){
2187 /*float gLoc[3]={0,0,0};
2188 float vel[3]={0,0,0};
2189 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2190 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2191 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2192 OPENAL_SetVolume(channels[firestartsound], 256);
2193 OPENAL_SetPaused(channels[firestartsound], false);
2194 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2207 if(Button()&&!oldbutton&&selected==8){
2208 float gLoc[3]={0,0,0};
2209 float vel[3]={0,0,0};
2210 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2211 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2212 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2213 OPENAL_SetVolume(channels[fireendsound], 256);
2214 OPENAL_SetPaused(channels[fireendsound], false);
2215 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2223 if(newdetail>2)newdetail=detail;
2224 if(newdetail<0)newdetail=detail;
2225 if(newscreenwidth<0)newscreenwidth=screenwidth;
2226 if(newscreenheight<0)newscreenheight=screenheight;
2229 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2230 opstream << "Screenwidth:\n";
2231 opstream << newscreenwidth;
2232 opstream << "\nScreenheight:\n";
2233 opstream << newscreenheight;
2234 opstream << "\nMouse sensitivity:\n";
2235 opstream << usermousesensitivity;
2236 opstream << "\nBlur(0,1):\n";
2237 opstream << ismotionblur;
2238 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2239 opstream << newdetail;
2240 opstream << "\nFloating jump:\n";
2241 opstream << floatjump;
2242 opstream << "\nMouse jump:\n";
2243 opstream << mousejump;
2244 opstream << "\nAmbient sound:\n";
2245 opstream << ambientsound;
2246 opstream << "\nBlood (0,1,2):\n";
2247 opstream << bloodtoggle;
2248 opstream << "\nAuto slomo:\n";
2249 opstream << autoslomo;
2250 opstream << "\nFoliage:\n";
2251 opstream << foliage;
2252 opstream << "\nMusic:\n";
2253 opstream << musictoggle;
2254 opstream << "\nTrilinear:\n";
2255 opstream << trilinear;
2256 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2258 opstream << "\nInvert mouse:\n";
2259 opstream << invertmouse;
2260 opstream << "\nGamespeed:\n";
2261 if(oldgamespeed==0)oldgamespeed=1;
2262 opstream << oldgamespeed;
2263 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2264 opstream << difficulty;
2265 opstream << "\nDamage effects(blackout, doublevision):\n";
2266 opstream << damageeffects;
2267 opstream << "\nText:\n";
2268 opstream << texttoggle;
2269 opstream << "\nDebug:\n";
2270 opstream << debugmode;
2271 opstream << "\nVBL Sync:\n";
2272 opstream << vblsync;
2273 opstream << "\nShow Points:\n";
2274 opstream << showpoints;
2275 opstream << "\nAlways Blur:\n";
2276 opstream << alwaysblur;
2277 opstream << "\nImmediate mode (turn on on G5):\n";
2278 opstream << immediate;
2279 opstream << "\nVelocity blur:\n";
2280 opstream << velocityblur;
2281 opstream << "\nVolume:\n";
2283 opstream << "\nForward key:\n";
2284 opstream << KeyToChar(forwardkey);
2285 opstream << "\nBack key:\n";
2286 opstream << KeyToChar(backkey);
2287 opstream << "\nLeft key:\n";
2288 opstream << KeyToChar(leftkey);
2289 opstream << "\nRight key:\n";
2290 opstream << KeyToChar(rightkey);
2291 opstream << "\nJump key:\n";
2292 opstream << KeyToChar(jumpkey);
2293 opstream << "\nCrouch key:\n";
2294 opstream << KeyToChar(crouchkey);
2295 opstream << "\nDraw key:\n";
2296 opstream << KeyToChar(drawkey);
2297 opstream << "\nThrow key:\n";
2298 opstream << KeyToChar(throwkey);
2299 opstream << "\nAttack key:\n";
2300 opstream << KeyToChar(attackkey);
2301 opstream << "\nChat key:\n";
2302 opstream << KeyToChar(chatkey);
2305 if(mainmenu==3&&gameon)mainmenu=2;
2306 if(mainmenu==3&&!gameon)mainmenu=1;
2308 if(Button())oldbutton=1;
2312 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2313 float gLoc[3]={0,0,0};
2314 float vel[3]={0,0,0};
2315 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2316 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2317 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2318 OPENAL_SetVolume(channels[firestartsound], 256);
2319 OPENAL_SetPaused(channels[firestartsound], false);
2320 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2322 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2330 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2332 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2333 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2334 float gLoc[3]={0,0,0};
2335 float vel[3]={0,0,0};
2336 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2337 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2338 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2339 OPENAL_SetVolume(channels[fireendsound], 256);
2340 OPENAL_SetPaused(channels[fireendsound], false);
2341 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2345 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2346 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2350 if(keyselect==0)forwardkey=keynum;
2351 if(keyselect==1)backkey=keynum;
2352 if(keyselect==2)leftkey=keynum;
2353 if(keyselect==3)rightkey=keynum;
2354 if(keyselect==4)crouchkey=keynum;
2355 if(keyselect==5)jumpkey=keynum;
2356 if(keyselect==6)drawkey=keynum;
2357 if(keyselect==7)throwkey=keynum;
2358 if(keyselect==8)attackkey=keynum;
2363 if(Button()&&!oldbutton&&selected==9){
2364 float gLoc[3]={0,0,0};
2365 float vel[3]={0,0,0};
2366 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2367 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2368 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2369 OPENAL_SetVolume(channels[fireendsound], 256);
2370 OPENAL_SetPaused(channels[fireendsound], false);
2371 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2381 if(newdetail>2)newdetail=detail;
2382 if(newdetail<0)newdetail=detail;
2383 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2384 if(newscreenwidth<0)newscreenwidth=screenwidth;
2385 if(newscreenheight>3000)newscreenheight=screenheight;
2386 if(newscreenheight<0)newscreenheight=screenheight;
2393 accountcampaignchoicesmade[accountactive]=0;
2394 accountcampaignscore[accountactive]=0;
2395 accountcampaigntime[accountactive]=0;
2399 if(Button()&&!oldbutton&&selected==1){
2400 float gLoc[3]={0,0,0};
2401 float vel[3]={0,0,0};
2402 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2403 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2404 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2405 OPENAL_SetVolume(channels[firestartsound], 256);
2406 OPENAL_SetPaused(channels[firestartsound], false);
2407 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2420 if(firstload)TickOnceAfter();
2421 if(!firstload)LoadStuff();
2428 OPENAL_SetPaused(channels[stream_music3], true);
2430 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2431 float gLoc[3]={0,0,0};
2432 float vel[3]={0,0,0};
2433 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2434 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2435 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2436 OPENAL_SetVolume(channels[firestartsound], 256);
2437 OPENAL_SetPaused(channels[firestartsound], false);
2438 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2451 if(firstload)TickOnceAfter();
2452 if(!firstload)LoadStuff();
2468 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2469 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2473 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2478 OPENAL_SetPaused(channels[stream_music3], true);
2480 if(Button()&&!oldbutton&&selected==4){
2481 float gLoc[3]={0,0,0};
2482 float vel[3]={0,0,0};
2483 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2484 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2485 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2486 OPENAL_SetVolume(channels[fireendsound], 256);
2487 OPENAL_SetPaused(channels[fireendsound], false);
2488 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2496 if(mainmenu==5&&gameon)mainmenu=2;
2497 if(mainmenu==5&&!gameon)mainmenu=1;
2499 if(Button()&&!oldbutton&&selected==5){
2500 float gLoc[3]={0,0,0};
2501 float vel[3]={0,0,0};
2502 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2503 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2504 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2505 OPENAL_SetVolume(channels[fireendsound], 256);
2506 OPENAL_SetPaused(channels[fireendsound], false);
2507 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2517 if(Button()&&!oldbutton&&selected==3){
2518 float gLoc[3]={0,0,0};
2519 float vel[3]={0,0,0};
2520 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2521 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2522 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2523 OPENAL_SetVolume(channels[firestartsound], 256);
2524 OPENAL_SetPaused(channels[firestartsound], false);
2525 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2535 if(Button()&&!oldbutton&&selected==2){
2536 float gLoc[3]={0,0,0};
2537 float vel[3]={0,0,0};
2538 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2539 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2540 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2541 OPENAL_SetVolume(channels[firestartsound], 256);
2542 OPENAL_SetPaused(channels[firestartsound], false);
2543 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2553 if(Button())oldbutton=1;
2557 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2558 float gLoc[3]={0,0,0};
2559 float vel[3]={0,0,0};
2560 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2561 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2562 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2563 OPENAL_SetVolume(channels[firestartsound], 256);
2564 OPENAL_SetPaused(channels[firestartsound], false);
2565 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2577 targetlevel=selected;
2578 if(firstload)TickOnceAfter();
2579 if(!firstload)LoadStuff();
2581 Loadlevel(selected);
2587 OPENAL_SetPaused(channels[stream_music3], true);
2589 if(Button()&&!oldbutton&&selected==numchallengelevels){
2590 float gLoc[3]={0,0,0};
2591 float vel[3]={0,0,0};
2592 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2593 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2594 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2595 OPENAL_SetVolume(channels[fireendsound], 256);
2596 OPENAL_SetPaused(channels[fireendsound], false);
2597 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2607 if(Button())oldbutton=1;
2611 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2612 float gLoc[3]={0,0,0};
2613 float vel[3]={0,0,0};
2614 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2615 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2616 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2617 OPENAL_SetVolume(channels[firestartsound], 256);
2618 OPENAL_SetPaused(channels[firestartsound], false);
2619 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2631 targetlevel=selected;
2632 if(firstload)TickOnceAfter();
2633 if(!firstload)LoadStuff();
2635 Loadlevel(selected);
2641 OPENAL_SetPaused(channels[stream_music3], true);
2643 if(Button()&&!oldbutton&&selected==numchallengelevels){
2644 float gLoc[3]={0,0,0};
2645 float vel[3]={0,0,0};
2646 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2647 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2648 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2649 OPENAL_SetVolume(channels[fireendsound], 256);
2650 OPENAL_SetPaused(channels[fireendsound], false);
2651 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2661 if(Button())oldbutton=1;
2666 if(Button()&&!oldbutton&&selected==3){
2667 float gLoc[3]={0,0,0};
2668 float vel[3]={0,0,0};
2669 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2670 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2671 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2672 OPENAL_SetVolume(channels[fireendsound], 256);
2673 OPENAL_SetPaused(channels[fireendsound], false);
2674 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2684 if(Button())oldbutton=1;
2689 if(Button()&&!oldbutton&&selected!=-1){
2690 float gLoc[3]={0,0,0};
2691 float vel[3]={0,0,0};
2692 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2693 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2694 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2695 OPENAL_SetVolume(channels[firestartsound], 256);
2696 OPENAL_SetPaused(channels[firestartsound], false);
2697 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2699 if(Button()&&!oldbutton&&selected==1){
2700 float gLoc[3]={0,0,0};
2701 float vel[3]={0,0,0};
2702 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2703 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2704 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2705 OPENAL_SetVolume(channels[fireendsound], 256);
2706 OPENAL_SetPaused(channels[fireendsound], false);
2707 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2715 for(i=accountactive;i<numaccounts-1;i++){
2716 accountdifficulty[i]=accountdifficulty[i+1];
2717 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2718 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2719 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2721 accountpoints[i]=accountpoints[i+1];
2723 accounthighscore[i][j]=accounthighscore[i+1][j];
2724 accountfasttime[i][j]=accountfasttime[i+1][j];
2727 accountunlocked[i][j]=accountunlocked[i+1][j];
2730 accountname[i][j]=accountname[i+1][j];
2732 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2733 accountprogress[i]=accountprogress[i+1];
2734 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2735 accountcampaignscore[i]=accountcampaignscore[i+1];
2736 accountcampaigntime[i]=accountcampaigntime[i+1];
2745 if(Button()&&!oldbutton&&selected==2){
2746 float gLoc[3]={0,0,0};
2747 float vel[3]={0,0,0};
2748 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2749 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2750 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2751 OPENAL_SetVolume(channels[fireendsound], 256);
2752 OPENAL_SetPaused(channels[fireendsound], false);
2753 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2763 if(Button())oldbutton=1;
2767 if(Button()&&!oldbutton&&selected!=-1){
2768 float gLoc[3]={0,0,0};
2769 float vel[3]={0,0,0};
2770 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2771 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2772 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2773 OPENAL_SetVolume(channels[firestartsound], 256);
2774 OPENAL_SetPaused(channels[firestartsound], false);
2775 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2777 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2780 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2781 accountactive=selected-1;
2789 if(Button()&&!oldbutton&&selected==numaccounts+1){
2790 float gLoc[3]={0,0,0};
2791 float vel[3]={0,0,0};
2792 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2793 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2794 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2795 OPENAL_SetVolume(channels[fireendsound], 256);
2796 OPENAL_SetPaused(channels[fireendsound], false);
2797 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2808 displaytext[0][j]=' ';
2814 if(Button())oldbutton=1;
2818 if(Button()&&!oldbutton&&selected!=-1){
2819 float gLoc[3]={0,0,0};
2820 float vel[3]={0,0,0};
2821 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2822 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2823 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2824 OPENAL_SetVolume(channels[firestartsound], 256);
2825 OPENAL_SetPaused(channels[firestartsound], false);
2826 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2828 if(selected==0)accountdifficulty[accountactive]=0;
2829 if(selected==1)accountdifficulty[accountactive]=1;
2830 if(selected==2)accountdifficulty[accountactive]=2;
2841 if(Button())oldbutton=1;
2846 if(Button())oldbutton=1;
2849 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2852 if(newdetail>2)newdetail=detail;
2853 if(newdetail<0)newdetail=detail;
2854 if(newscreenwidth<0)newscreenwidth=screenwidth;
2855 if(newscreenheight<0)newscreenheight=screenheight;
2857 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2858 opstream << "Screenwidth:\n";
2859 opstream << newscreenwidth;
2860 opstream << "\nScreenheight:\n";
2861 opstream << newscreenheight;
2862 opstream << "\nMouse sensitivity:\n";
2863 opstream << usermousesensitivity;
2864 opstream << "\nBlur(0,1):\n";
2865 opstream << ismotionblur;
2866 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2867 opstream << newdetail;
2868 opstream << "\nFloating jump:\n";
2869 opstream << floatjump;
2870 opstream << "\nMouse jump:\n";
2871 opstream << mousejump;
2872 opstream << "\nAmbient sound:\n";
2873 opstream << ambientsound;
2874 opstream << "\nBlood (0,1,2):\n";
2875 opstream << bloodtoggle;
2876 opstream << "\nAuto slomo:\n";
2877 opstream << autoslomo;
2878 opstream << "\nFoliage:\n";
2879 opstream << foliage;
2880 opstream << "\nMusic:\n";
2881 opstream << musictoggle;
2882 opstream << "\nTrilinear:\n";
2883 opstream << trilinear;
2884 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2886 opstream << "\nInvert mouse:\n";
2887 opstream << invertmouse;
2888 opstream << "\nGamespeed:\n";
2889 if(oldgamespeed==0)oldgamespeed=1;
2890 opstream << oldgamespeed;
2891 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2892 opstream << difficulty;
2893 opstream << "\nDamage effects(blackout, doublevision):\n";
2894 opstream << damageeffects;
2895 opstream << "\nText:\n";
2896 opstream << texttoggle;
2897 opstream << "\nDebug:\n";
2898 opstream << debugmode;
2899 opstream << "\nVBL Sync:\n";
2900 opstream << vblsync;
2901 opstream << "\nShow Points:\n";
2902 opstream << showpoints;
2903 opstream << "\nAlways Blur:\n";
2904 opstream << alwaysblur;
2905 opstream << "\nImmediate mode (turn on on G5):\n";
2906 opstream << immediate;
2907 opstream << "\nVelocity blur:\n";
2908 opstream << velocityblur;
2909 opstream << "\nVolume:\n";
2911 opstream << "\nForward key:\n";
2912 opstream << KeyToChar(forwardkey);
2913 opstream << "\nBack key:\n";
2914 opstream << KeyToChar(backkey);
2915 opstream << "\nLeft key:\n";
2916 opstream << KeyToChar(leftkey);
2917 opstream << "\nRight key:\n";
2918 opstream << KeyToChar(rightkey);
2919 opstream << "\nJump key:\n";
2920 opstream << KeyToChar(jumpkey);
2921 opstream << "\nCrouch key:\n";
2922 opstream << KeyToChar(crouchkey);
2923 opstream << "\nDraw key:\n";
2924 opstream << KeyToChar(drawkey);
2925 opstream << "\nThrow key:\n";
2926 opstream << KeyToChar(throwkey);
2927 opstream << "\nAttack key:\n";
2928 opstream << KeyToChar(attackkey);
2929 opstream << "\nChat key:\n";
2930 opstream << KeyToChar(chatkey);
2935 if(mainmenu==1||mainmenu==2){
2936 if(loaddistrib>4)transition+=multiplier/8;
2944 OPENAL_SetFrequency(channels[stream_music3], 22050);
2948 if(IsKeyDown(theKeyMap, i)){
2949 togglekeydelay[i]+=multiplier;
2950 if(togglekeydelay[i]>.4){
2952 togglekeydelay[i]=.36;
2955 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
2956 for(j=255;j>=displayselected+1;j--){
2957 displaytext[0][j]=displaytext[0][j-1];
2959 displaytext[0][displayselected]=KeyToSingleChar(i);
2960 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
2964 if(i==MAC_DELETE_KEY&&displayselected!=0){
2965 for(j=displayselected-1;j<255;j++){
2966 displaytext[0][j]=displaytext[0][j+1];
2968 displaytext[0][255]=' ';
2972 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
2975 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
2978 if(i==MAC_RETURN_KEY&&entername){
2979 if(displaychars[0]){
2981 strcpy(accountname[numaccounts-1],displaytext[0]);
2982 accountactive=numaccounts-1;
2983 accountdifficulty[accountactive]=1;
2984 accountprogress[accountactive]=0;
2985 accountpoints[accountactive]=0;
2986 accountcampaigntime[accountactive]=0;
2987 accountcampaignscore[accountactive]=0;
2988 accountcampaignfasttime[accountactive]=0;
2989 accountcampaignhighscore[accountactive]=0;
2991 accounthighscore[accountactive][j]=0;
2992 accountfasttime[accountactive][j]=0;
2995 accountunlocked[accountactive][j]=0;
2997 accountcampaignchoicesmade[accountactive]=0;
3000 displaytext[0][j]=' ';
3014 float gLoc[3]={0,0,0};
3015 float vel[3]={0,0,0};
3016 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3017 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3018 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3019 OPENAL_SetVolume(channels[firestartsound], 256);
3020 OPENAL_SetPaused(channels[firestartsound], false);
3021 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3024 displaytext[0][j]=' ';
3032 if(i==MAC_RETURN_KEY&&mainmenu==13){
3033 if(displaychars[0]){
3034 sprintf (registrationname, "%s", displaytext[0]);
3035 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3045 float gLoc[3]={0,0,0};
3046 float vel[3]={0,0,0};
3047 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3048 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3049 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3050 OPENAL_SetVolume(channels[firestartsound], 256);
3051 OPENAL_SetPaused(channels[firestartsound], false);
3052 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3055 displaytext[0][j]=' ';
3066 togglekeydelay[i]=0;
3070 displayblinkdelay-=multiplier;
3071 if(displayblinkdelay<=0){
3072 displayblinkdelay=.3;
3073 displayblink=1-displayblink;
3079 if(hostile==1)hostiletime+=multiplier;
3081 if(!winfreeze)leveltime+=multiplier;
3082 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3089 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3091 chattogglekeydown=1;
3092 togglekey[chatkey]=1;
3093 togglekeydelay[chatkey]=-20;
3096 if(!IsKeyDown(theKeyMap, chatkey)){
3097 chattogglekeydown=0;
3102 if(IsKeyDown(theKeyMap, i)){
3103 togglekeydelay[i]+=multiplier;
3104 if(togglekeydelay[i]>.4){
3106 togglekeydelay[i]=.36;
3109 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3110 for(j=255;j>=displayselected+1;j--){
3111 displaytext[0][j]=displaytext[0][j-1];
3113 displaytext[0][displayselected]=KeyToSingleChar(i);
3114 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3118 if(i==MAC_DELETE_KEY&&displayselected!=0){
3119 for(j=displayselected-1;j<255;j++){
3120 displaytext[0][j]=displaytext[0][j+1];
3122 displaytext[0][255]=' ';
3126 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3129 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3132 if(i==MAC_RETURN_KEY){
3133 if(displaychars[0]){
3134 /*for(j=0;j<displaychars[0];j++){
3135 talkname[j]=displaytext[0][j];
3137 talkname[displaychars[0]]='\0';
3138 sprintf (chatname, "%s: %s",playerName,talkname);
3139 //NetworkSendInformation(chatname);
3142 displaytext[0][j]=' ';
3154 togglekeydelay[i]=0;
3158 displayblinkdelay-=multiplier;
3159 if(displayblinkdelay<=0){
3160 displayblinkdelay=.3;
3161 displayblink=1-displayblink;
3165 if(chatting)keyboardfrozen=1;
3167 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3170 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3172 freezetogglekeydown=1;
3175 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3176 freezetogglekeydown=0;
3179 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3181 if(!console)freeze=0;
3183 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3185 consoletogglekeydown=1;
3188 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3189 consoletogglekeydown=0;
3192 if(console)freeze=1;
3194 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3196 if(IsKeyDown(theKeyMap, i)){
3197 togglekeydelay[i]+=multiplier;
3198 if(togglekeydelay[i]>.4){
3200 togglekeydelay[i]=.36;
3203 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3204 for(j=255;j>=consoleselected+1;j--){
3205 consoletext[0][j]=consoletext[0][j-1];
3207 consoletext[0][consoleselected]=KeyToSingleChar(i);
3208 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3212 else if(i==MAC_ENTER_KEY){
3213 for(j=255;j>=consoleselected+1;j--){
3214 consoletext[0][j]=consoletext[0][j-1];
3216 consoletext[0][consoleselected]='\n';
3220 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3221 for(j=consoleselected-1;j<255;j++){
3222 consoletext[0][j]=consoletext[0][j+1];
3224 consoletext[0][255]=' ';
3228 if(i==MAC_ARROW_UP_KEY){
3229 if(archiveselected<14)archiveselected++;
3231 consolechars[0]=consolechars[archiveselected];
3232 consoletext[0][j]=consoletext[archiveselected][j];
3233 consoleselected=consolechars[0];
3236 if(i==MAC_ARROW_DOWN_KEY){
3237 if(archiveselected>0)archiveselected--;
3239 consolechars[0]=consolechars[archiveselected];
3240 consoletext[0][j]=consoletext[archiveselected][j];
3241 consoleselected=consolechars[0];
3244 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3247 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3250 if(i==MAC_RETURN_KEY){
3253 if(stripfx(consoletext[0], "quit ")||stripfx(consoletext[0], "exit ")){
3254 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3255 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3256 OPENAL_SetPaused(channels[consolesuccesssound], false);
3260 /*if(stripfx(consoletext[0], "send ")){
3261 for(j=5;j<consolechars[0];j++){
3262 talkname[j-5]=consoletext[0][j];
3264 talkname[consolechars[0]-5]='\0';
3265 sprintf (chatname, "%s: %s",playerName,talkname);
3266 //NetworkSendInformation(chatname);
3269 if(stripfx(consoletext[0], "name ")){
3271 numchars=consolechars[0]-5;
3272 if(numchars>32)numchars=32;
3273 for(j=5;j<numchars+5;j++){
3274 talkname[j-5]=consoletext[0][j];
3276 talkname[numchars]='\0';
3277 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3278 //NetworkSendInformation(chatname);
3279 sprintf (playerName, "%s",talkname);
3280 //NetworkSendName(playerName);
3283 if(stripfx(consoletext[0], "map ")){
3295 for(j=4;j<consolechars[0];j++){
3296 mapname[j-4+11]=consoletext[0][j];
3298 mapname[consolechars[0]-4+11]='\0';
3304 /*if(stripfx(consoletext[0], "connect ")&&!ishost){
3306 unsigned char playerNameStr[32];
3307 char theIPAddress[256];
3309 NMUInt32 port = 25710;
3311 strcpy(playerName, "Client");
3312 GameC2PStr( playerName, playerNameStr );
3314 for(j=0;j<consolechars[0]-8;j++){
3315 theIPAddress[j]=consoletext[0][j+8];
3317 theIPAddress[consolechars[0]-8]='\0';
3319 sprintf( thePort, "%li", port );
3320 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3323 if(consolechars[0]>0){
3326 consoletext[k][j]=consoletext[k-1][j];
3328 consolechars[k]=consolechars[k-1];
3331 consoletext[0][j]=' ';
3333 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3334 else sprintf (consoletext[0], "Could not open connection");
3336 consolechars[0]=255;
3343 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3344 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3345 OPENAL_SetPaused(channels[consolesuccesssound], false);
3347 if(consolechars[0]>0){
3350 consoletext[k][j]=consoletext[k-1][j];
3352 consolechars[k]=consolechars[k-1];
3355 consoletext[0][j]=' ';
3357 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3359 consolechars[0]=255;
3365 if(stripfx(consoletext[0], "host ")){
3366 unsigned char gameNameStr[32], playerNameStr[32];
3367 char gameName[32];//, playerName[32];
3375 strcpy(gameName, "Host's game");
3376 strcpy(playerName, "Host");
3377 GameC2PStr( gameName, gameNameStr );
3378 GameC2PStr( playerName, playerNameStr );
3380 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3383 if(consolechars[0]>0){
3386 consoletext[k][j]=consoletext[k-1][j];
3388 consolechars[k]=consolechars[k-1];
3391 consoletext[0][j]=' ';
3393 sprintf (consoletext[0], "Error #%d!!!",v);
3395 consolechars[0]=255;
3402 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3403 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3404 OPENAL_SetPaused(channels[consolesuccesssound], false);
3406 if(consolechars[0]>0){
3409 consoletext[k][j]=consoletext[k-1][j];
3411 consolechars[k]=consolechars[k-1];
3414 consoletext[0][j]=' ';
3416 sprintf (consoletext[0], "Game hosted");
3418 consolechars[0]=255;
3424 if(stripfx(consoletext[0], "save ")){
3436 for(j=5;j<consolechars[0];j++){
3437 mapname[j-5+11]=consoletext[0][j];
3439 mapname[consolechars[0]-5+11]='\0';
3441 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3442 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3443 OPENAL_SetPaused(channels[consolesuccesssound], false);
3450 tfile=fopen( ConvertFileName(mapname), "wb" );
3451 fpackf(tfile, "Bi", mapvers);
3452 //fpackf(tfile, "Bi", indemo);
3453 fpackf(tfile, "Bi", maptype);
3454 fpackf(tfile, "Bi", hostile);
3455 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3456 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3457 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3458 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);
3459 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3460 for(j=0;j<player[0].num_weapons;j++){
3461 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3464 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3465 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3466 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3467 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3469 fpackf(tfile, "Bi", player[0].numclothes);
3471 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3473 fpackf(tfile, "Bi", numdialogues);
3475 for(k=0;k<numdialogues;k++){
3476 fpackf(tfile, "Bi", numdialogueboxes[k]);
3477 fpackf(tfile, "Bi", dialoguetype[k]);
3479 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3480 fpackf(tfile, "Bf", participantrotation[k][l]);
3482 if(numdialogueboxes)
3483 for(l=0;l<numdialogueboxes[k];l++){
3484 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3485 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3486 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3487 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3488 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3490 templength=strlen(dialoguetext[k][l]);
3491 fpackf(tfile, "Bi",(templength));
3492 for(m=0;m<templength;m++){
3493 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3494 if(dialoguetext[k][l][m]=='\0')break;
3497 templength=strlen(dialoguename[k][l]);
3498 fpackf(tfile, "Bi",templength);
3499 for(m=0;m<templength;m++){
3500 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3501 if(dialoguename[k][l][m]=='\0')break;
3504 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3505 fpackf(tfile, "Bi", participantfocus[k][l]);
3506 fpackf(tfile, "Bi", participantaction[k][l]);
3509 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3511 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3515 if(player[0].numclothes)
3516 for(k=0;k<player[0].numclothes;k++){
3517 templength=strlen(player[0].clothes[k]);
3518 fpackf(tfile, "Bi", templength);
3519 for(l=0;l<templength;l++)
3520 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3521 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3524 fpackf(tfile, "Bi", environment);
3526 fpackf(tfile, "Bi", objects.numobjects);
3528 if(objects.numobjects)
3529 for(k=0;k<objects.numobjects;k++){
3530 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]);
3533 fpackf(tfile, "Bi", numhotspots);
3535 for(i=0;i<numhotspots;i++){
3536 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3537 templength=strlen(hotspottext[i]);
3538 fpackf(tfile, "Bi",templength);
3539 for(l=0;l<templength;l++)
3540 fpackf(tfile, "Bb", hotspottext[i][l]);
3543 fpackf(tfile, "Bi", numplayers);
3544 if(numplayers>1&&numplayers<maxplayers)
3545 for(j=1;j<numplayers;j++){
3546 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);
3547 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3548 for(k=0;k<player[j].num_weapons;k++){
3549 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3551 if(player[j].numwaypoints<30){
3552 fpackf(tfile, "Bi", player[j].numwaypoints);
3553 for(k=0;k<player[j].numwaypoints;k++){
3554 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3555 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3556 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3557 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3559 fpackf(tfile, "Bi", player[j].waypoint);
3562 player[j].numwaypoints=0;
3563 player[j].waypoint=0;
3564 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3567 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3568 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3569 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3570 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3572 if(player[j].creature==wolftype){
3573 headprop=player[j].proportionhead.x/1.1;
3574 bodyprop=player[j].proportionbody.x/1.1;
3575 armprop=player[j].proportionarms.x/1.1;
3576 legprop=player[j].proportionlegs.x/1.1;
3579 if(player[j].creature==rabbittype){
3580 headprop=player[j].proportionhead.x/1.2;
3581 bodyprop=player[j].proportionbody.x/1.05;
3582 armprop=player[j].proportionarms.x/1.00;
3583 legprop=player[j].proportionlegs.x/1.1;
3586 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3590 fpackf(tfile, "Bi", player[j].numclothes);
3591 if(player[j].numclothes)
3592 for(k=0;k<player[j].numclothes;k++){
3594 templength=strlen(player[j].clothes[k]);
3595 fpackf(tfile, "Bi", templength);
3596 for(l=0;l<templength;l++)
3597 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3598 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3602 fpackf(tfile, "Bi", numpathpoints);
3604 for(j=0;j<numpathpoints;j++){
3605 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3606 for(k=0;k<numpathpointconnect[j];k++){
3607 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3611 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3619 tfile=fopen( mapname, "wb" );
3620 fwrite( &mapvers, 1, sizeof(int), tfile );
3621 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3622 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3623 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3624 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3625 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3626 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3627 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3628 for(j=0;j<player[0].num_weapons;j++){
3629 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3632 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3633 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3634 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3635 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3636 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3637 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3638 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3639 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3640 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3641 fwrite( &player[0].power, 1, sizeof(int), tfile );
3642 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3644 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3645 if(player[0].numclothes)
3646 for(k=0;k<player[0].numclothes;k++){
3648 templength=strlen(player[0].clothes[k]);
3649 fwrite( &templength,1,sizeof(int),tfile);
3650 for(l=0;l<templength;l++)
3651 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3652 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3653 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3654 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3657 fwrite( &environment, 1, sizeof(int), tfile );
3659 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3661 for(k=0;k<objects.numobjects;k++){
3662 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3663 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3664 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3665 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3666 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3667 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3668 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3671 fwrite( &numplayers, 1, sizeof(int), tfile );
3672 if(numplayers>1&&numplayers<maxplayers)
3673 for(j=1;j<numplayers;j++){
3674 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3675 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3676 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3677 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3678 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3679 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3680 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3681 for(k=0;k<player[j].num_weapons;k++){
3682 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3684 if(player[j].numwaypoints<30){
3685 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3686 for(k=0;k<player[j].numwaypoints;k++){
3687 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3688 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3689 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3691 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3692 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3695 player[j].numwaypoints=0;
3696 player[j].waypoint=0;
3697 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3698 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3699 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3701 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3702 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3703 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3704 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3705 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3706 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3707 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3708 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3709 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3710 fwrite( &player[j].power, 1, sizeof(int), tfile );
3711 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3713 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3714 if(player[j].numclothes)
3715 for(k=0;k<player[j].numclothes;k++){
3717 templength=strlen(player[j].clothes[k]);
3718 fwrite( &templength,1,sizeof(int),tfile);
3719 for(l=0;l<templength;l++)
3720 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3721 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3722 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3723 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3726 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3728 for(j=0;j<numpathpoints;j++){
3729 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3730 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3731 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3732 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3733 for(k=0;k<numpathpointconnect[j];k++){
3734 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3738 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3739 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3740 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3742 fwrite( &mapradius, 1, sizeof(float), tfile );
3748 if(stripfx(consoletext[0], "save ")){
3760 for(j=5;j<consolechars[0];j++){
3761 mapname[j-5+11]=consoletext[0][j];
3763 mapname[consolechars[0]-5+11]='\0';
3765 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3766 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3767 OPENAL_SetPaused(channels[consolesuccesssound], false);
3770 tfile=fopen( mapname, "wb" );
3771 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
3772 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3773 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3774 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3775 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3776 for(j=0;j<player[0].num_weapons;j++){
3777 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3779 fwrite( &environment, 1, sizeof(int), tfile );
3781 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3782 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
3783 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
3784 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
3785 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
3787 fwrite( &numplayers, 1, sizeof(int), tfile );
3788 if(numplayers>1&&numplayers<maxplayers)
3789 for(j=1;j<numplayers;j++){
3790 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
3791 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3792 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3793 for(k=0;k<player[j].num_weapons;k++){
3794 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3796 if(player[j].numwaypoints<30){
3797 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3798 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
3799 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3800 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3803 player[j].numwaypoints=0;
3804 player[j].waypoint=0;
3805 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3806 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3807 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3810 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3812 for(j=0;j<numpathpoints;j++){
3813 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
3814 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3815 for(k=0;k<numpathpointconnect[j];k++){
3816 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3822 if(stripfx(consoletext[0], "cellar door ")||stripfx(consoletext[0], "cellardoor ")){
3823 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
3826 /*if(stripfx(consoletext[0], "Pants ")){
3827 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
3828 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
3832 if(stripfx(consoletext[0], "tintr ")||stripfx(consoletext[0], "Tintr ")){
3833 for(j=6;j<consolechars[0];j++){
3834 mapname[j-6]=consoletext[0][j];
3837 tintr=atof(mapname);
3842 if(stripfx(consoletext[0], "speed ")||stripfx(consoletext[0], "Speed ")){
3843 for(j=6;j<consolechars[0];j++){
3844 mapname[j-6]=consoletext[0][j];
3847 player[0].speedmult=atof(mapname);
3852 if(stripfx(consoletext[0], "strength ")||stripfx(consoletext[0], "Strength ")){
3853 for(j=9;j<consolechars[0];j++){
3854 mapname[j-9]=consoletext[0][j];
3857 player[0].power=atof(mapname);
3862 if(stripfx(consoletext[0], "viewdistance ")||stripfx(consoletext[0], "Viewdistance ")){
3863 for(j=13;j<consolechars[0];j++){
3864 mapname[j-13]=consoletext[0][j];
3867 viewdistance=atof(mapname)*100;
3872 if(stripfx(consoletext[0], "fadestart ")||stripfx(consoletext[0], "Fadestart ")){
3873 for(j=10;j<consolechars[0];j++){
3874 mapname[j-10]=consoletext[0][j];
3877 fadestart=atof(mapname);
3882 if(stripfx(consoletext[0], "power ")||stripfx(consoletext[0], "Power ")){
3883 for(j=6;j<consolechars[0];j++){
3884 mapname[j-6]=consoletext[0][j];
3887 player[0].power=atof(mapname);
3892 if(stripfx(consoletext[0], "slomo ")||stripfx(consoletext[0], "Slomo ")){
3893 for(j=6;j<consolechars[0];j++){
3894 mapname[j-6]=consoletext[0][j];
3897 slomospeed=atof(mapname);
3904 if(stripfx(consoletext[0], "slofreq ")||stripfx(consoletext[0], "Slofreq ")){
3905 for(j=8;j<consolechars[0];j++){
3906 mapname[j-8]=consoletext[0][j];
3909 slomofreq=atoi(mapname);
3914 if(stripfx(consoletext[0], "size ")||stripfx(consoletext[0], "Size ")){
3915 for(j=5;j<consolechars[0];j++){
3916 mapname[j-5]=consoletext[0][j];
3919 player[0].scale=atof(mapname)*.2;
3924 if(stripfx(consoletext[0], "sizenear ")||stripfx(consoletext[0], "Sizenear ")){
3926 float closestdist=-1;
3929 for(i=1;i<numplayers;i++){
3930 distance=findDistancefast(&player[i].coords,&player[0].coords);
3931 if(closestdist==-1||distance<closestdist){
3932 closestdist=distance;
3937 for(j=9;j<consolechars[0];j++){
3938 mapname[j-9]=consoletext[0][j];
3941 player[closest].scale=atof(mapname)*.2;
3946 if(stripfx(consoletext[0], "proportionnear ")||stripfx(consoletext[0], "Proportionnear ")){
3951 float closestdist=-1;
3954 for(i=1;i<numplayers;i++){
3955 distance=findDistancefast(&player[i].coords,&player[0].coords);
3956 if(closestdist==-1||distance<closestdist){
3957 closestdist=distance;
3965 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3966 mapname[j-startpoint]=consoletext[0][j];
3968 if(consoletext[0][j]=='\0')alldone=1;
3970 mapname[j-startpoint]='\0';
3972 headprop=atof(mapname);
3976 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3977 mapname[j-startpoint]=consoletext[0][j];
3979 if(consoletext[0][j]=='\0')alldone=1;
3981 mapname[j-startpoint]='\0';
3983 bodyprop=atof(mapname);
3987 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3988 mapname[j-startpoint]=consoletext[0][j];
3990 if(consoletext[0][j]=='\0')alldone=1;
3992 mapname[j-startpoint]='\0';
3994 armprop=atof(mapname);
3998 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
3999 mapname[j-startpoint]=consoletext[0][j];
4001 if(consoletext[0][j]=='\0')alldone=1;
4003 mapname[j-startpoint]='\0';
4005 legprop=atof(mapname);
4007 if(player[closest].creature==wolftype){
4008 player[closest].proportionhead=1.1*headprop;
4009 player[closest].proportionbody=1.1*bodyprop;
4010 player[closest].proportionarms=1.1*armprop;
4011 player[closest].proportionlegs=1.1*legprop;
4014 if(player[closest].creature==rabbittype){
4015 player[closest].proportionhead=1.2*headprop;
4016 player[closest].proportionbody=1.05*bodyprop;
4017 player[closest].proportionarms=1.00*armprop;
4018 player[closest].proportionlegs=1.1*legprop;
4019 player[closest].proportionlegs.y=1.05*legprop;
4026 if(stripfx(consoletext[0], "sizemin ")||stripfx(consoletext[0], "Sizemin ")){
4027 for(i=1;i<numplayers;i++){
4028 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4034 if(stripfx(consoletext[0], "tutorial ")||stripfx(consoletext[0], "Tutorial ")){
4035 for(j=9;j<consolechars[0];j++){
4036 mapname[j-9]=consoletext[0][j];
4039 tutoriallevel=atoi(mapname);
4045 if(stripfx(consoletext[0], "tintg ")||stripfx(consoletext[0], "Tintg ")){
4046 for(j=6;j<consolechars[0];j++){
4047 mapname[j-6]=consoletext[0][j];
4050 tintg=atof(mapname);
4055 if(stripfx(consoletext[0], "tintb ")||stripfx(consoletext[0], "Tintb ")){
4056 for(j=6;j<consolechars[0];j++){
4057 mapname[j-6]=consoletext[0][j];
4060 tintb=atof(mapname);
4065 if(stripfx(consoletext[0], "hostile ")){
4066 for(j=8;j<consolechars[0];j++){
4067 mapname[j-8]=consoletext[0][j];
4070 hostile=atoi(mapname);
4076 if(stripfx(consoletext[0], "type active ")){
4077 editoractive=typeactive;
4082 if(stripfx(consoletext[0], "indemo ")){
4084 hotspot[numhotspots]=player[0].coords;
4085 hotspotsize[numhotspots]=0;
4086 hotspottype[numhotspots]=-111;
4088 strcpy(hotspottext[numhotspots],"mapname");
4094 if(stripfx(consoletext[0], "notindemo ")){
4101 if(stripfx(consoletext[0], "type sitting ")){
4102 editoractive=typesitting;
4107 if(stripfx(consoletext[0], "type sitting wall ")){
4108 editoractive=typesittingwall;
4113 if(stripfx(consoletext[0], "type sleeping ")){
4114 editoractive=typesleeping;
4118 if(stripfx(consoletext[0], "type dead1 ")){
4119 editoractive=typedead1;
4123 if(stripfx(consoletext[0], "type dead2 ")){
4124 editoractive=typedead2;
4128 if(stripfx(consoletext[0], "type dead3 ")){
4129 editoractive=typedead3;
4132 if(stripfx(consoletext[0], "type dead4 ")){
4133 editoractive=typedead4;
4138 if(stripfx(consoletext[0], "path keepwalking ")){
4139 editorpathtype=wpkeepwalking;
4144 if(stripfx(consoletext[0], "path pause ")){
4145 editorpathtype=wppause;
4150 if(stripfx(consoletext[0], "mapkilleveryone ")){
4151 maptype=mapkilleveryone;
4156 if(stripfx(consoletext[0], "mapgosomewhere ")){
4157 maptype=mapgosomewhere;
4162 if(stripfx(consoletext[0], "mapkillsomeone ")){
4163 maptype=mapkillsomeone;
4169 if(stripfx(consoletext[0], "mapkillmost ")){
4170 maptype=mapkillmost;
4176 if(stripfx(consoletext[0], "hs ")){
4180 hotspot[numhotspots]=player[0].coords;
4185 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4186 mapname[j-startpoint]=consoletext[0][j];
4188 if(consoletext[0][j]=='\0')alldone=1;
4190 mapname[j-startpoint]='\0';
4192 hotspotsize[numhotspots]=atof(mapname);
4196 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4197 mapname[j-startpoint]=consoletext[0][j];
4199 if(consoletext[0][j]=='\0')alldone=1;
4201 mapname[j-startpoint]='\0';
4203 hotspottype[numhotspots]=atoi(mapname);
4207 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4208 mapname[j-startpoint]=consoletext[0][j];
4210 if(consoletext[0][j]=='\0')alldone=1;
4212 mapname[j-startpoint]='\n';
4213 mapname[j-startpoint+1]='\0';
4215 strcpy(hotspottext[numhotspots],mapname);
4222 if(stripfx(consoletext[0], "dialogue ")){
4229 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4230 mapname[j-startpoint]=consoletext[0][j];
4232 if(consoletext[0][j]=='\0')alldone=1;
4234 mapname[j-startpoint]='\0';
4237 dialoguetype[numdialogues]=atoi(mapname);
4255 for(j=startpoint;j<consolechars[0];j++){
4256 mapname[j-startpoint+16]=consoletext[0][j];
4258 mapname[consolechars[0]-startpoint+16]='.';
4259 mapname[consolechars[0]-startpoint+17]='t';
4260 mapname[consolechars[0]-startpoint+18]='x';
4261 mapname[consolechars[0]-startpoint+19]='t';
4262 mapname[consolechars[0]-startpoint+20]='\0';
4264 for(j=0;j<max_dialoguelength;j++){
4266 dialoguetext[numdialogues][j][k]='\0';
4269 dialoguename[numdialogues][j][k]='\0';
4273 ifstream ipstream(ConvertFileName(mapname));
4274 ipstream.ignore(256,':');
4275 ipstream >> numdialogueboxes[numdialogues];
4276 for(i=0;i<numdialogueboxes[numdialogues];i++){
4277 ipstream.ignore(256,':');
4278 ipstream.ignore(256,':');
4279 ipstream.ignore(256,' ');
4280 ipstream >> dialogueboxlocation[numdialogues][i];
4281 ipstream.ignore(256,':');
4282 ipstream >> dialogueboxcolor[numdialogues][i][0];
4283 ipstream >> dialogueboxcolor[numdialogues][i][1];
4284 ipstream >> dialogueboxcolor[numdialogues][i][2];
4285 ipstream.ignore(256,':');
4286 ipstream.getline(dialoguename[numdialogues][i],64);
4287 ipstream.ignore(256,':');
4288 ipstream.ignore(256,' ');
4289 ipstream.getline(dialoguetext[numdialogues][i],128);
4291 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4293 ipstream.ignore(256,':');
4294 ipstream >> dialogueboxsound[numdialogues][i];
4297 for(i=0;i<numdialogueboxes[numdialogues];i++){
4298 for(j=0;j<numplayers;j++){
4299 participantfacing[numdialogues][i][j]=player[j].facing;
4306 whichdialogue=numdialogues;
4314 if(stripfx(consoletext[0], "fixdialogue ")){
4322 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4323 mapname[j-startpoint]=consoletext[0][j];
4325 if(consoletext[0][j]=='\0')alldone=1;
4327 mapname[j-startpoint]='\0';
4330 whichdi=atoi(mapname);
4348 for(j=startpoint;j<consolechars[0];j++){
4349 mapname[j-startpoint+16]=consoletext[0][j];
4351 mapname[consolechars[0]-startpoint+16]='.';
4352 mapname[consolechars[0]-startpoint+17]='t';
4353 mapname[consolechars[0]-startpoint+18]='x';
4354 mapname[consolechars[0]-startpoint+19]='t';
4355 mapname[consolechars[0]-startpoint+20]='\0';
4357 for(j=0;j<max_dialoguelength;j++){
4359 dialoguetext[whichdi][j][k]='\0';
4362 dialoguename[whichdi][j][k]='\0';
4366 ifstream ipstream(ConvertFileName(mapname));
4367 ipstream.ignore(256,':');
4368 ipstream >> numdialogueboxes[whichdi];
4369 for(i=0;i<numdialogueboxes[whichdi];i++){
4370 ipstream.ignore(256,':');
4371 ipstream.ignore(256,':');
4372 ipstream.ignore(256,' ');
4373 ipstream >> dialogueboxlocation[whichdi][i];
4374 ipstream.ignore(256,':');
4375 ipstream >> dialogueboxcolor[whichdi][i][0];
4376 ipstream >> dialogueboxcolor[whichdi][i][1];
4377 ipstream >> dialogueboxcolor[whichdi][i][2];
4378 ipstream.ignore(256,':');
4379 ipstream.getline(dialoguename[whichdi][i],64);
4380 ipstream.ignore(256,':');
4381 ipstream.ignore(256,' ');
4382 ipstream.getline(dialoguetext[whichdi][i],128);
4384 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4386 ipstream.ignore(256,':');
4387 ipstream >> dialogueboxsound[whichdi][i];
4395 if(stripfx(consoletext[0], "fixtype ")){
4403 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4404 mapname[j-startpoint]=consoletext[0][j];
4406 if(consoletext[0][j]=='\0')alldone=1;
4408 mapname[j-startpoint]='\0';
4409 dialoguetype[0]=atoi(mapname);
4417 if(stripfx(consoletext[0], "fixrotation ")){
4418 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4423 if(stripfx(consoletext[0], "ddialogue ")){
4425 if(numdialogues<0)numdialogues=0;
4430 if(stripfx(consoletext[0], "immobile ")){
4431 player[0].immobile=1;
4435 if(stripfx(consoletext[0], "mobile ")){
4436 player[0].immobile=0;
4440 if(stripfx(consoletext[0], "play ")){
4447 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4448 mapname[j-startpoint]=consoletext[0][j];
4450 if(consoletext[0][j]=='\0')alldone=1;
4452 mapname[j-startpoint]='\0';
4455 whichdialogue=atoi(mapname);
4457 if(numdialogues>whichdialogue){
4458 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4459 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4460 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4461 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4462 player[participantfocus[whichdialogue][i]].velocity=0;
4463 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4464 player[participantfocus[whichdialogue][i]].targetframe=0;
4472 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4476 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4477 temppos=temppos-viewer;
4478 Normalise(&temppos);
4488 whichsoundplay=rabbitchitter;
4489 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4490 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4491 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4492 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4493 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4494 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4495 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4496 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4497 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4498 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4499 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4500 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4501 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4502 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4503 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4504 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4505 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4506 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4507 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4508 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4509 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4510 OPENAL_SetVolume(channels[whichsoundplay], 256);
4511 OPENAL_SetPaused(channels[whichsoundplay], false);
4519 if(stripfx(consoletext[0], "dhs ")){
4521 if(numhotspots<0)numhotspots=0;
4526 if(stripfx(consoletext[0], "proportion ")||stripfx(consoletext[0], "Proportion ")){
4533 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4534 mapname[j-startpoint]=consoletext[0][j];
4536 if(consoletext[0][j]=='\0')alldone=1;
4538 mapname[j-startpoint]='\0';
4540 headprop=atof(mapname);
4544 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4545 mapname[j-startpoint]=consoletext[0][j];
4547 if(consoletext[0][j]=='\0')alldone=1;
4549 mapname[j-startpoint]='\0';
4551 bodyprop=atof(mapname);
4555 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4556 mapname[j-startpoint]=consoletext[0][j];
4558 if(consoletext[0][j]=='\0')alldone=1;
4560 mapname[j-startpoint]='\0';
4562 armprop=atof(mapname);
4566 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4567 mapname[j-startpoint]=consoletext[0][j];
4569 if(consoletext[0][j]=='\0')alldone=1;
4571 mapname[j-startpoint]='\0';
4573 legprop=atof(mapname);
4575 if(player[0].creature==wolftype){
4576 player[0].proportionhead=1.1*headprop;
4577 player[0].proportionbody=1.1*bodyprop;
4578 player[0].proportionarms=1.1*armprop;
4579 player[0].proportionlegs=1.1*legprop;
4582 if(player[0].creature==rabbittype){
4583 player[0].proportionhead=1.2*headprop;
4584 player[0].proportionbody=1.05*bodyprop;
4585 player[0].proportionarms=1.00*armprop;
4586 player[0].proportionlegs=1.1*legprop;
4587 player[0].proportionlegs.y=1.05*legprop;
4593 if(stripfx(consoletext[0], "allimmobile ")||stripfx(consoletext[0], "Allimmobile ")){
4594 for(i=0;i<numplayers;i++){
4595 if(i>0)player[i].immobile=1;
4601 if(stripfx(consoletext[0], "default ")||stripfx(consoletext[0], "Default ")){
4602 player[0].armorhead=1;
4603 player[0].armorhigh=1;
4604 player[0].armorlow=1;
4605 player[0].protectionhead=1;
4606 player[0].protectionhigh=1;
4607 player[0].protectionlow=1;
4608 player[0].metalhead=1;
4609 player[0].metalhigh=1;
4610 player[0].metallow=1;
4612 player[0].speedmult=1;
4615 if(player[0].creature==wolftype){
4616 player[0].proportionhead=1.1;
4617 player[0].proportionbody=1.1;
4618 player[0].proportionarms=1.1;
4619 player[0].proportionlegs=1.1;
4622 if(player[0].creature==rabbittype){
4623 player[0].proportionhead=1.2;
4624 player[0].proportionbody=1.05;
4625 player[0].proportionarms=1.00;
4626 player[0].proportionlegs=1.1;
4627 player[0].proportionlegs.y=1.05;
4630 player[0].numclothes=0;
4631 LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
4632 &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4634 editoractive=typeactive;
4635 player[0].immobile=0;
4642 if(stripfx(consoletext[0], "tint ")||stripfx(consoletext[0], "Tint ")){
4648 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4649 mapname[j-startpoint]=consoletext[0][j];
4651 if(consoletext[0][j]=='\0')alldone=1;
4653 mapname[j-startpoint]='\0';
4655 tintr=atof(mapname);
4659 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4660 mapname[j-startpoint]=consoletext[0][j];
4662 if(consoletext[0][j]=='\0')alldone=1;
4664 mapname[j-startpoint]='\0';
4666 tintg=atof(mapname);
4670 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4671 mapname[j-startpoint]=consoletext[0][j];
4673 if(consoletext[0][j]=='\0')alldone=1;
4675 mapname[j-startpoint]='\0';
4677 tintb=atof(mapname);
4682 if(stripfx(consoletext[0], "sky tint ")||stripfx(consoletext[0], "Sky Tint ")){
4688 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4689 mapname[j-startpoint]=consoletext[0][j];
4691 if(consoletext[0][j]=='\0')alldone=1;
4693 mapname[j-startpoint]='\0';
4695 skyboxr=atof(mapname);
4699 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4700 mapname[j-startpoint]=consoletext[0][j];
4702 if(consoletext[0][j]=='\0')alldone=1;
4704 mapname[j-startpoint]='\0';
4706 skyboxg=atof(mapname);
4710 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4711 mapname[j-startpoint]=consoletext[0][j];
4713 if(consoletext[0][j]=='\0')alldone=1;
4715 mapname[j-startpoint]='\0';
4717 skyboxb=atof(mapname);
4719 skyboxlightr=skyboxr;
4720 skyboxlightg=skyboxg;
4721 skyboxlightb=skyboxb;
4725 //if(skyboxtexture){
4726 terrain.DoShadows();
4727 objects.DoShadows();
4729 else terrain.DoLighting();
4734 if(stripfx(consoletext[0], "sky light ")||stripfx(consoletext[0], "Sky Light ")){
4740 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4741 mapname[j-startpoint]=consoletext[0][j];
4743 if(consoletext[0][j]=='\0')alldone=1;
4745 mapname[j-startpoint]='\0';
4747 skyboxlightr=atof(mapname);
4751 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4752 mapname[j-startpoint]=consoletext[0][j];
4754 if(consoletext[0][j]=='\0')alldone=1;
4756 mapname[j-startpoint]='\0';
4758 skyboxlightg=atof(mapname);
4762 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4763 mapname[j-startpoint]=consoletext[0][j];
4765 if(consoletext[0][j]=='\0')alldone=1;
4767 mapname[j-startpoint]='\0';
4769 skyboxlightb=atof(mapname);
4773 //if(skyboxtexture){
4774 terrain.DoShadows();
4775 objects.DoShadows();
4777 else terrain.DoLighting();
4782 if(stripfx(consoletext[0], "skybox ")||stripfx(consoletext[0], "Skybox ")){
4783 skyboxtexture=1-skyboxtexture;
4786 //if(skyboxtexture){
4787 terrain.DoShadows();
4788 objects.DoShadows();
4790 else terrain.DoLighting();
4795 if(stripfx(consoletext[0], "protection ")||stripfx(consoletext[0], "Protection ")){
4801 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4802 mapname[j-startpoint]=consoletext[0][j];
4804 if(consoletext[0][j]=='\0')alldone=1;
4806 mapname[j-startpoint]='\0';
4808 player[0].protectionhead=atof(mapname);
4812 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4813 mapname[j-startpoint]=consoletext[0][j];
4815 if(consoletext[0][j]=='\0')alldone=1;
4817 mapname[j-startpoint]='\0';
4819 player[0].protectionhigh=atof(mapname);
4823 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4824 mapname[j-startpoint]=consoletext[0][j];
4826 if(consoletext[0][j]=='\0')alldone=1;
4828 mapname[j-startpoint]='\0';
4830 player[0].protectionlow=atof(mapname);
4835 if(stripfx(consoletext[0], "armor ")||stripfx(consoletext[0], "Armor ")){
4841 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4842 mapname[j-startpoint]=consoletext[0][j];
4844 if(consoletext[0][j]=='\0')alldone=1;
4846 mapname[j-startpoint]='\0';
4848 player[0].armorhead=atof(mapname);
4852 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4853 mapname[j-startpoint]=consoletext[0][j];
4855 if(consoletext[0][j]=='\0')alldone=1;
4857 mapname[j-startpoint]='\0';
4859 player[0].armorhigh=atof(mapname);
4863 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4864 mapname[j-startpoint]=consoletext[0][j];
4866 if(consoletext[0][j]=='\0')alldone=1;
4868 mapname[j-startpoint]='\0';
4870 player[0].armorlow=atof(mapname);
4875 if(stripfx(consoletext[0], "protectionreset ")||stripfx(consoletext[0], "Protectionreset ")){
4876 for(i=0;i<numplayers;i++){
4877 player[i].protectionhead=1.0;
4878 player[i].protectionhigh=1.0;
4879 player[i].protectionlow=1.0;
4880 player[i].armorhead=1.0;
4881 player[i].armorhigh=1.0;
4882 player[i].armorlow=1.0;
4888 if(stripfx(consoletext[0], "protectionnear ")||stripfx(consoletext[0], "Protectionnear ")){
4890 float closestdist=-1;
4893 for(i=1;i<numplayers;i++){
4894 distance=findDistancefast(&player[i].coords,&player[0].coords);
4895 if(closestdist==-1||distance<closestdist){
4896 closestdist=distance;
4906 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4907 mapname[j-startpoint]=consoletext[0][j];
4909 if(consoletext[0][j]=='\0')alldone=1;
4911 mapname[j-startpoint]='\0';
4913 player[closest].protectionhead=atof(mapname);
4917 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4918 mapname[j-startpoint]=consoletext[0][j];
4920 if(consoletext[0][j]=='\0')alldone=1;
4922 mapname[j-startpoint]='\0';
4924 player[closest].protectionhigh=atof(mapname);
4928 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4929 mapname[j-startpoint]=consoletext[0][j];
4931 if(consoletext[0][j]=='\0')alldone=1;
4933 mapname[j-startpoint]='\0';
4935 player[closest].protectionlow=atof(mapname);
4940 if(stripfx(consoletext[0], "armornear ")||stripfx(consoletext[0], "Armornear ")){
4942 float closestdist=-1;
4945 for(i=1;i<numplayers;i++){
4946 distance=findDistancefast(&player[i].coords,&player[0].coords);
4947 if(closestdist==-1||distance<closestdist){
4948 closestdist=distance;
4957 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4958 mapname[j-startpoint]=consoletext[0][j];
4960 if(consoletext[0][j]=='\0')alldone=1;
4962 mapname[j-startpoint]='\0';
4964 player[closest].armorhead=atof(mapname);
4968 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4969 mapname[j-startpoint]=consoletext[0][j];
4971 if(consoletext[0][j]=='\0')alldone=1;
4973 mapname[j-startpoint]='\0';
4975 player[closest].armorhigh=atof(mapname);
4979 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4980 mapname[j-startpoint]=consoletext[0][j];
4982 if(consoletext[0][j]=='\0')alldone=1;
4984 mapname[j-startpoint]='\0';
4986 player[closest].armorlow=atof(mapname);
4992 if(stripfx(consoletext[0], "metal ")||stripfx(consoletext[0], "Metal ")){
4998 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4999 mapname[j-startpoint]=consoletext[0][j];
5001 if(consoletext[0][j]=='\0')alldone=1;
5003 mapname[j-startpoint]='\0';
5005 player[0].metalhead=atof(mapname);
5009 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5010 mapname[j-startpoint]=consoletext[0][j];
5012 if(consoletext[0][j]=='\0')alldone=1;
5014 mapname[j-startpoint]='\0';
5016 player[0].metalhigh=atof(mapname);
5020 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5021 mapname[j-startpoint]=consoletext[0][j];
5023 if(consoletext[0][j]=='\0')alldone=1;
5026 mapname[j-startpoint]='\0';
5028 player[0].metallow=atof(mapname);
5033 if(stripfx(consoletext[0], "noclothesnear ")||stripfx(consoletext[0], "Noclothesnear ")){
5035 float closestdist=-1;
5038 for(i=1;i<numplayers;i++){
5039 distance=findDistancefast(&player[i].coords,&player[0].coords);
5040 if(closestdist==-1||distance<closestdist){
5041 closestdist=distance;
5045 player[closest].numclothes=0;
5046 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
5047 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5052 if(stripfx(consoletext[0], "noclothes ")||stripfx(consoletext[0], "Noclothes ")){
5055 player[closest].numclothes=0;
5056 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
5057 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5061 if((stripfx(consoletext[0], "Clothes ")||stripfx(consoletext[0], "clothes "))){
5077 for(j=8;j<consolechars[0];j++){
5078 mapname[j-8+15]=consoletext[0][j];
5080 mapname[consolechars[0]-8+15]='.';
5081 mapname[consolechars[0]-8+16]='p';
5082 mapname[consolechars[0]-8+17]='n';
5083 mapname[consolechars[0]-8+18]='g';
5084 mapname[consolechars[0]-8+19]='\0';
5086 //:Data:Textures:Pants.png
5088 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5089 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5090 strcpy(player[0].clothes[player[0].numclothes],mapname);
5091 player[0].clothestintr[player[0].numclothes]=tintr;
5092 player[0].clothestintg[player[0].numclothes]=tintg;
5093 player[0].clothestintb[player[0].numclothes]=tintb;
5094 player[0].numclothes++;
5100 if(stripfx(consoletext[0], "belt ")||stripfx(consoletext[0], "belt ")){
5101 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5106 if(stripfx(consoletext[0], "Cellophane ")||stripfx(consoletext[0], "cellophane ")){
5107 cellophane=1-cellophane;
5110 for(i=0;i<numplayers;i++){
5111 player[i].proportionhead.z=0;
5112 player[i].proportionbody.z=0;
5113 player[i].proportionarms.z=0;
5114 player[i].proportionlegs.z=0;
5119 for(i=0;i<numplayers;i++){
5120 player[i].proportionhead.z=player[i].proportionhead.x;
5121 player[i].proportionbody.z=player[i].proportionbody.x;
5122 player[i].proportionarms.z=player[i].proportionarms.x;
5123 player[i].proportionlegs.z=player[i].proportionlegs.x;
5130 if((stripfx(consoletext[0], "Clothesnear ")||stripfx(consoletext[0], "clothesnear "))){
5146 for(j=12;j<consolechars[0];j++){
5147 mapname[j-12+15]=consoletext[0][j];
5149 mapname[consolechars[0]-12+15]='.';
5150 mapname[consolechars[0]-12+16]='p';
5151 mapname[consolechars[0]-12+17]='n';
5152 mapname[consolechars[0]-12+18]='g';
5153 mapname[consolechars[0]-12+19]='\0';
5155 //:Data:Textures:Pants.png
5157 float closestdist=-1;
5160 for(i=1;i<numplayers;i++){
5161 distance=findDistancefast(&player[i].coords,&player[0].coords);
5162 if(closestdist==-1||distance<closestdist){
5163 closestdist=distance;
5168 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5169 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5170 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5171 player[closest].clothestintr[player[closest].numclothes]=tintr;
5172 player[closest].clothestintg[player[closest].numclothes]=tintg;
5173 player[closest].clothestintb[player[closest].numclothes]=tintb;
5174 player[closest].numclothes++;
5180 if(stripfx(consoletext[0], "funnybunny ")||stripfx(consoletext[0], "funny bunny ")){
5181 player[0].skeleton.id=0;
5182 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);
5183 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5184 player[0].creature=rabbittype;
5187 player[0].proportionhead=1.2;
5188 player[0].proportionbody=1.05;
5189 player[0].proportionarms=1.00;
5190 player[0].proportionlegs=1.1;
5191 player[0].proportionlegs.y=1.05;
5192 player[0].headless=0;
5194 player[0].damagetolerance=200;
5198 if(stripfx(consoletext[0], "wolfieisgod ")||stripfx(consoletext[0], "wolfie is god ")){
5199 player[0].skeleton.id=0;
5200 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);
5201 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5202 player[0].creature=wolftype;
5204 player[0].proportionhead=1.1;
5205 player[0].proportionbody=1.1;
5206 player[0].proportionarms=1.1;
5207 player[0].proportionlegs=1.1;
5208 player[0].proportionlegs.y=1.1;
5209 player[0].scale=.23;
5211 player[0].damagetolerance=300;
5215 /*if(stripfx(consoletext[0], "kungfu ")||stripfx(consoletext[0], "kung fu ")){
5216 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5219 if(stripfx(consoletext[0], "rambo ")){
5220 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5223 if(stripfx(consoletext[0], "david ")){
5224 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5227 if(stripfx(consoletext[0], "wolf ")){
5228 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5231 if(stripfx(consoletext[0], "darkwolf ")){
5232 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5235 if(stripfx(consoletext[0], "snowwolf ")){
5236 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5239 if(stripfx(consoletext[0], "lizardwolf ")){
5240 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5243 if(stripfx(consoletext[0], "white ")){
5244 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5247 if(stripfx(consoletext[0], "brown ")){
5248 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5251 if(stripfx(consoletext[0], "black ")){
5252 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5255 if(consolechars[0]>0){
5258 consoletext[k][j]=consoletext[k-1][j];
5260 consolechars[k]=consolechars[k-1];
5263 consoletext[0][j]=' ';
5269 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5270 OPENAL_SetVolume(channels[consolefailsound], 256);
5271 OPENAL_SetPaused(channels[consolefailsound], false);
5280 togglekeydelay[i]=0;
5284 consoleblinkdelay-=multiplier;
5285 if(consoleblinkdelay<=0){
5286 consoleblinkdelay=.3;
5287 consoleblink=1-consoleblink;
5291 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5294 if(newdetail>2)newdetail=detail;
5295 if(newdetail<0)newdetail=detail;
5296 if(newscreenwidth<0)newscreenwidth=screenwidth;
5297 if(newscreenheight<0)newscreenheight=screenheight;
5299 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5300 opstream << "Screenwidth:\n";
5301 opstream << newscreenwidth;
5302 opstream << "\nScreenheight:\n";
5303 opstream << newscreenheight;
5304 opstream << "\nMouse sensitivity:\n";
5305 opstream << usermousesensitivity;
5306 opstream << "\nBlur(0,1):\n";
5307 opstream << ismotionblur;
5308 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5309 opstream << newdetail;
5310 opstream << "\nFloating jump:\n";
5311 opstream << floatjump;
5312 opstream << "\nMouse jump:\n";
5313 opstream << mousejump;
5314 opstream << "\nAmbient sound:\n";
5315 opstream << ambientsound;
5316 opstream << "\nBlood (0,1,2):\n";
5317 opstream << bloodtoggle;
5318 opstream << "\nAuto slomo:\n";
5319 opstream << autoslomo;
5320 opstream << "\nFoliage:\n";
5321 opstream << foliage;
5322 opstream << "\nMusic:\n";
5323 opstream << musictoggle;
5324 opstream << "\nTrilinear:\n";
5325 opstream << trilinear;
5326 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5328 opstream << "\nInvert mouse:\n";
5329 opstream << invertmouse;
5330 opstream << "\nGamespeed:\n";
5331 if(oldgamespeed==0)oldgamespeed=1;
5332 opstream << oldgamespeed;
5333 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5334 opstream << difficulty;
5335 opstream << "\nDamage effects(blackout, doublevision):\n";
5336 opstream << damageeffects;
5337 opstream << "\nText:\n";
5338 opstream << texttoggle;
5339 opstream << "\nDebug:\n";
5340 opstream << debugmode;
5341 opstream << "\nVBL Sync:\n";
5342 opstream << vblsync;
5343 opstream << "\nShow Points:\n";
5344 opstream << showpoints;
5345 opstream << "\nAlways Blur:\n";
5346 opstream << alwaysblur;
5347 opstream << "\nImmediate mode (turn on on G5):\n";
5348 opstream << immediate;
5349 opstream << "\nVelocity blur:\n";
5350 opstream << velocityblur;
5351 opstream << "\nVolume:\n";
5353 opstream << "\nForward key:\n";
5354 opstream << KeyToChar(forwardkey);
5355 opstream << "\nBack key:\n";
5356 opstream << KeyToChar(backkey);
5357 opstream << "\nLeft key:\n";
5358 opstream << KeyToChar(leftkey);
5359 opstream << "\nRight key:\n";
5360 opstream << KeyToChar(rightkey);
5361 opstream << "\nJump key:\n";
5362 opstream << KeyToChar(jumpkey);
5363 opstream << "\nCrouch key:\n";
5364 opstream << KeyToChar(crouchkey);
5365 opstream << "\nDraw key:\n";
5366 opstream << KeyToChar(drawkey);
5367 opstream << "\nThrow key:\n";
5368 opstream << KeyToChar(throwkey);
5369 opstream << "\nAttack key:\n";
5370 opstream << KeyToChar(attackkey);
5371 opstream << "\nChat key:\n";
5372 opstream << KeyToChar(chatkey);
5377 static int oldwinfreeze;
5378 if(winfreeze&&!oldwinfreeze){
5379 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
5380 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5381 OPENAL_SetVolume(channels[consolesuccesssound], 256);
5382 OPENAL_SetPaused(channels[consolesuccesssound], false);
5384 if(winfreeze==0)oldwinfreeze=winfreeze;
5385 else oldwinfreeze++;
5387 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5388 if(winfreeze)winfreeze=0;
5391 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5397 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5400 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5402 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5404 static bool oldbuttondialogue;
5406 if(indialogue!=-1)talkdelay=1;
5407 talkdelay-=multiplier;
5410 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5411 for(i=0;i<numdialogues;i++){
5412 int realdialoguetype;
5414 if(dialoguetype[i]>49){
5415 realdialoguetype=dialoguetype[i]-50;
5418 else if(dialoguetype[i]>39){
5419 realdialoguetype=dialoguetype[i]-40;
5422 else if(dialoguetype[i]>29){
5423 realdialoguetype=dialoguetype[i]-30;
5426 else if(dialoguetype[i]>19){
5427 realdialoguetype=dialoguetype[i]-20;
5430 else if(dialoguetype[i]>9){
5431 realdialoguetype=dialoguetype[i]-10;
5435 realdialoguetype=dialoguetype[i];
5438 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5439 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5441 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5442 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5443 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5444 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5445 player[participantfocus[whichdialogue][j]].velocity=0;
5446 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5447 player[participantfocus[whichdialogue][j]].targetframe=0;
5452 dialoguegonethrough[i]++;
5453 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5454 static float gLoc[3];
5455 static float vel[3];
5457 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5458 temppos=temppos-viewer;
5459 Normalise(&temppos);
5464 gLoc[2]=temppos.z;vel[0]=0;
5468 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5469 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5470 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5471 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5472 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5473 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5474 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5475 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5476 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5477 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5478 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5479 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5480 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5481 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5482 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5483 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5484 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5485 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5486 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5487 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5488 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5489 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5490 OPENAL_SetVolume(channels[whichsoundplay], 256);
5491 OPENAL_SetPaused(channels[whichsoundplay], false);
5493 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5498 windvar+=multiplier;
5499 smoketex+=multiplier;
5500 tutorialstagetime+=multiplier;
5502 static float hotspotvisual[40];
5506 for(i=0;i<numhotspots;i++)
5507 hotspotvisual[i]-=multiplier/320;
5509 for(i=0;i<numhotspots;i++){
5510 //if(hotspottype[i]<=10)
5511 while(hotspotvisual[i]<0){
5513 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5514 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5515 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5516 hotspotsprite+=hotspot[i];
5517 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5518 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5522 for(i=0;i<numhotspots;i++){
5523 if(hotspottype[i]<=10&&hotspottype[i]>0){
5524 hotspot[i]=player[hotspottype[i]].coords;
5530 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5533 if(tutorialstage<=1){
5538 if(tutorialstage==1){
5541 if(tutorialstage==2){
5544 if(tutorialstage==3){
5545 tutorialmaxtime=600;
5547 if(tutorialstage==4){
5548 tutorialmaxtime=1000;
5550 if(tutorialstage==5){
5551 tutorialmaxtime=600;
5553 if(tutorialstage==6){
5554 tutorialmaxtime=600;
5556 if(tutorialstage==7){
5557 tutorialmaxtime=600;
5559 if(tutorialstage==8){
5560 tutorialmaxtime=600;
5562 if(tutorialstage==9){
5563 tutorialmaxtime=600;
5565 if(tutorialstage==10){
5568 if(tutorialstage==11){
5569 tutorialmaxtime=1000;
5571 if(tutorialstage==12){
5572 tutorialmaxtime=1000;
5574 if(tutorialstage==13){
5577 if(tutorialstage==14){
5589 player[1].coords=(temp+temp2)/2;
5593 gLoc[0]=player[1].coords.x;
5594 gLoc[1]=player[1].coords.y;
5595 gLoc[2]=player[1].coords.z;
5599 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5600 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5601 OPENAL_SetVolume(channels[fireendsound], 256);
5602 OPENAL_SetPaused(channels[fireendsound], false);
5604 for(i=0;i<player[1].skeleton.num_joints;i++){
5606 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5607 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5608 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;
5609 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5610 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5615 if(tutorialstage==15){
5616 tutorialmaxtime=500;
5618 if(tutorialstage==16){
5619 tutorialmaxtime=500;
5621 if(tutorialstage==17){
5622 tutorialmaxtime=500;
5624 if(tutorialstage==18){
5625 tutorialmaxtime=500;
5627 if(tutorialstage==19){
5629 //tutorialmaxtime=500;
5631 if(tutorialstage==20){
5632 tutorialmaxtime=500;
5634 if(tutorialstage==21){
5635 tutorialmaxtime=500;
5642 if(tutorialstage==22){
5643 tutorialmaxtime=500;
5645 if(tutorialstage==23){
5646 tutorialmaxtime=500;
5648 if(tutorialstage==24){
5649 tutorialmaxtime=500;
5651 if(tutorialstage==25){
5652 tutorialmaxtime=500;
5654 if(tutorialstage==26){
5657 if(tutorialstage==27){
5661 player[1].aitype=attacktypecutoff;
5663 if(tutorialstage==28){
5664 tutorialmaxtime=400;
5666 if(tutorialstage==29){
5667 tutorialmaxtime=400;
5668 player[0].escapednum=0;
5670 if(tutorialstage==30){
5674 player[1].aitype=passivetype;
5676 if(tutorialstage==31){
5679 if(tutorialstage==32){
5682 if(tutorialstage==33){
5683 tutorialmaxtime=400;
5686 player[1].aitype=attacktypecutoff;
5688 if(tutorialstage==34){
5689 tutorialmaxtime=400;
5691 if(tutorialstage==35){
5692 tutorialmaxtime=400;
5694 if(tutorialstage==36){
5698 player[1].aitype=passivetype;
5700 if(tutorialstage==37){
5706 player[1].aitype=attacktypecutoff;
5708 if(tutorialstage==38){
5712 player[1].aitype=passivetype;
5714 if(tutorialstage==39){
5725 weapons.owner[weapons.numweapons]=-1;
5726 weapons.type[weapons.numweapons]=knife;
5727 weapons.damage[weapons.numweapons]=0;
5728 weapons.mass[weapons.numweapons]=1;
5729 weapons.tipmass[weapons.numweapons]=1.2;
5730 weapons.length[weapons.numweapons]=.25;
5731 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5732 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5734 weapons.velocity[weapons.numweapons]=0.1;
5735 weapons.tipvelocity[weapons.numweapons]=0.1;
5736 weapons.missed[weapons.numweapons]=1;
5737 weapons.hitsomething[weapons.numweapons]=0;
5738 weapons.freetime[weapons.numweapons]=0;
5739 weapons.firstfree[weapons.numweapons]=1;
5740 weapons.physics[weapons.numweapons]=1;
5742 weapons.numweapons++;
5744 if(tutorialstage==40){
5745 tutorialmaxtime=300;
5747 if(tutorialstage==41){
5748 tutorialmaxtime=300;
5750 if(tutorialstage==42){
5753 if(tutorialstage==43){
5754 tutorialmaxtime=300;
5756 if(tutorialstage==44){
5758 player[0].weaponactive=-1;
5759 player[0].num_weapons=0;
5760 player[1].weaponactive=0;
5761 player[1].num_weapons=1;
5762 player[1].weaponids[0]=0;
5766 player[1].aitype=attacktypecutoff;
5768 tutorialmaxtime=300;
5770 if(tutorialstage==45){
5772 player[0].weaponactive=-1;
5773 player[0].num_weapons=0;
5774 player[1].weaponactive=0;
5775 player[1].num_weapons=1;
5776 player[1].weaponids[0]=0;
5778 tutorialmaxtime=300;
5780 if(tutorialstage==46){
5782 player[0].weaponactive=-1;
5783 player[0].num_weapons=0;
5784 player[1].weaponactive=0;
5785 player[1].num_weapons=1;
5786 player[1].weaponids[0]=0;
5788 weapons.type[0]=sword;
5790 tutorialmaxtime=300;
5793 if(tutorialstage==47){
5805 weapons.owner[weapons.numweapons]=-1;
5806 weapons.type[weapons.numweapons]=sword;
5807 weapons.damage[weapons.numweapons]=0;
5808 weapons.mass[weapons.numweapons]=1;
5809 weapons.tipmass[weapons.numweapons]=1.2;
5810 weapons.length[weapons.numweapons]=.25;
5811 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5812 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5814 weapons.velocity[weapons.numweapons]=0.1;
5815 weapons.tipvelocity[weapons.numweapons]=0.1;
5816 weapons.missed[weapons.numweapons]=1;
5817 weapons.hitsomething[weapons.numweapons]=0;
5818 weapons.freetime[weapons.numweapons]=0;
5819 weapons.firstfree[weapons.numweapons]=1;
5820 weapons.physics[weapons.numweapons]=1;
5824 player[0].weaponactive=0;
5825 player[0].num_weapons=1;
5826 player[0].weaponids[0]=1;
5827 player[1].weaponactive=0;
5828 player[1].num_weapons=1;
5829 player[1].weaponids[0]=0;
5831 weapons.numweapons++;
5833 if(tutorialstage==48){
5836 player[1].aitype=passivetype;
5842 player[0].weaponactive=0;
5843 player[0].num_weapons=1;
5844 player[0].weaponids[0]=1;
5845 player[1].weaponactive=0;
5846 player[1].num_weapons=1;
5847 player[1].weaponids[0]=0;
5849 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
5850 else weapons.type[0]=staff;
5852 weapons.numweapons++;
5854 if(tutorialstage==49){
5857 player[1].aitype=passivetype;
5859 tutorialmaxtime=200;
5861 weapons.position[1]=1000;
5862 weapons.tippoint[1]=1000;
5864 weapons.numweapons=1;
5866 player[1].weaponactive=-1;
5867 player[1].num_weapons=0;
5868 player[0].weaponactive=0;
5869 player[0].num_weapons=1;
5870 player[0].weaponids[0]=0;
5872 weapons.type[0]=knife;
5874 weapons.numweapons++;
5876 if(tutorialstage==50){
5882 gLoc[0]=player[1].coords.x;
5883 gLoc[1]=player[1].coords.y;
5884 gLoc[2]=player[1].coords.z;
5888 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5889 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5890 OPENAL_SetVolume(channels[fireendsound], 256);
5891 OPENAL_SetPaused(channels[fireendsound], false);
5893 for(i=0;i<player[1].skeleton.num_joints;i++){
5895 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5896 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5897 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;
5898 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5899 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5903 player[1].num_weapons=0;
5904 player[1].weaponstuck=-1;
5905 player[1].weaponactive=-1;
5907 weapons.numweapons=0;
5909 weapons.owner[0]=-1;
5910 weapons.velocity[0]=0.1;
5911 weapons.tipvelocity[0]=-0.1;
5912 weapons.missed[0]=1;
5913 weapons.hitsomething[0]=0;
5914 weapons.freetime[0]=0;
5915 weapons.firstfree[0]=1;
5916 weapons.physics[0]=1;
5918 if(tutorialstage==51){
5919 tutorialmaxtime=80000;
5921 if(tutorialstage<=51)tutorialstagetime=0;
5925 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
5926 if(tutorialstage==3){
5927 if(deltah||deltav)tutorialsuccess+=multiplier;
5929 if(tutorialstage==4){
5930 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
5932 if(tutorialstage==5){
5933 if(player[0].jumpkeydown)tutorialsuccess=1;
5935 if(tutorialstage==6){
5936 if(player[0].isCrouch())tutorialsuccess=1;
5938 if(tutorialstage==7){
5939 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
5941 if(tutorialstage==8){
5942 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
5944 if(tutorialstage==9){
5945 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
5947 if(tutorialstage==11){
5948 if(player[0].isWallJump())tutorialsuccess=1;
5950 if(tutorialstage==12){
5951 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
5953 if(tutorialstage==15){
5954 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
5956 if(tutorialstage==16){
5957 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
5959 if(tutorialstage==17){
5960 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
5962 if(tutorialstage==18){
5963 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
5965 if(tutorialstage==19){
5966 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
5968 if(tutorialstage==20){
5969 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
5971 if(tutorialstage==21){
5972 if(bonus==cannon)tutorialsuccess=1;
5974 if(tutorialstage==22){
5975 if(bonus==spinecrusher)tutorialsuccess=1;
5977 if(tutorialstage==23){
5978 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
5980 if(tutorialstage==24){
5981 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
5983 if(tutorialstage==25){
5984 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
5986 if(tutorialstage==28){
5987 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
5989 if(tutorialstage==29){
5990 if(player[0].escapednum==2){
5994 player[1].aitype=passivetype;
5997 if(tutorialstage==33){
5998 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6000 if(tutorialstage==34){
6001 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6003 if(tutorialstage==35){
6004 if(animation[player[0].targetanimation].attack==reversal){
6008 player[1].aitype=passivetype;
6011 if(tutorialstage==40){
6012 if(player[0].num_weapons>0)tutorialsuccess=1;
6014 if(tutorialstage==41){
6015 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6017 if(tutorialstage==43){
6018 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6020 if(tutorialstage==44){
6021 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6023 if(tutorialstage==45){
6024 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6026 if(tutorialstage==46){
6027 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6029 if(tutorialstage==49){
6030 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6032 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6035 if(tutorialstagetime==tutorialmaxtime-3){
6036 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6037 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6038 OPENAL_SetPaused(channels[consolesuccesssound], false);
6041 if(tutorialsuccess>=1){
6042 if(tutorialstage==34||tutorialstage==35)
6043 tutorialstagetime=tutorialmaxtime-1;
6048 if(tutorialstage<14||tutorialstage>=50){
6049 player[1].coords.y=300;
6050 player[1].velocity=0;
6054 if(tutoriallevel!=1){
6055 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6056 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6057 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6058 OPENAL_SetPaused(channels[consolesuccesssound], false);
6063 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6064 OPENAL_SetVolume(channels[fireendsound], 256);
6065 OPENAL_SetPaused(channels[fireendsound], false);
6068 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6069 else bonusnum[bonus]+=0.15;
6070 if(tutoriallevel)bonusvalue=0;
6071 bonusvalue/=bonusnum[bonus];
6072 bonustotal+=bonusvalue;
6074 bonustime+=multiplier;
6076 if(environment==snowyenvironment){
6077 precipdelay-=multiplier;
6078 while(precipdelay<0){
6080 if(!detail)precipdelay+=.04;
6081 XYZ footvel,footpoint;
6084 footpoint=viewer+viewerfacing*6;
6085 footpoint.y+=((float)abs(Random()%1200))/100-6;
6086 footpoint.x+=((float)abs(Random()%1200))/100-6;
6087 footpoint.z+=((float)abs(Random()%1200))/100-6;
6088 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6091 for(k=0;k<numplayers;k++){
6092 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6093 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6095 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){
6096 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6097 else if(player[k].rotation>player[k].targetrotation){
6098 player[k].rotation-=multiplier*player[k].turnspeed;
6100 else if(player[k].rotation<player[k].targetrotation){
6101 player[k].rotation+=multiplier*player[k].turnspeed;
6106 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))){
6107 player[k].turnspeed*=2;
6108 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6109 else if(player[k].rotation>player[k].targetrotation){
6110 player[k].rotation-=multiplier*player[k].turnspeed;
6112 else if(player[k].rotation<player[k].targetrotation){
6113 player[k].rotation+=multiplier*player[k].turnspeed;
6115 player[k].turnspeed/=2;
6118 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6119 player[k].turnspeed*=4;
6120 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6121 else if(player[k].rotation>player[k].targetrotation){
6122 player[k].rotation-=multiplier*player[k].turnspeed;
6124 else if(player[k].rotation<player[k].targetrotation){
6125 player[k].rotation+=multiplier*player[k].turnspeed;
6127 player[k].turnspeed/=4;
6130 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6131 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6133 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6134 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6137 if(player[k].collide<-.3)player[k].collide=-.3;
6138 if(player[k].collide>1)player[k].collide=1;
6139 player[k].collide-=multiplier*30;
6141 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6142 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6144 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6145 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6146 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6147 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6148 lowpoint=player[k].coords;
6149 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6150 else lowpoint.y+=1.3;
6151 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){
6152 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6154 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6155 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6157 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6158 flatfacing=lowpoint-player[k].coords;
6159 player[k].coords=lowpoint;
6160 player[k].coords.y-=1.3;
6161 player[k].collide=1;
6163 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6164 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6165 tempcoords1=lowpoint;
6166 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6167 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6169 player[k].targetanimation=walljumpleftanim;
6170 player[k].targetframe=0;
6173 gLoc[0]=player[k].coords.x;
6174 gLoc[1]=player[k].coords.y;
6175 gLoc[2]=player[k].coords.z;
6179 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6180 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6181 OPENAL_SetVolume(channels[movewhooshsound], 256);
6182 OPENAL_SetPaused(channels[movewhooshsound], false);
6183 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6185 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6186 player[k].rotation=-asin(0-lowpointtarget.x);
6187 player[k].rotation*=360/6.28;
6188 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6189 player[k].targetrotation=player[k].rotation;
6190 player[k].lowrotation=player[k].rotation;
6191 if(k==0)numwallflipped++;
6195 lowpoint=tempcoords1;
6196 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6197 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6198 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6200 player[k].targetanimation=walljumprightanim;
6201 player[k].targetframe=0;
6204 gLoc[0]=player[k].coords.x;
6205 gLoc[1]=player[k].coords.y;
6206 gLoc[2]=player[k].coords.z;
6210 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6211 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6212 OPENAL_SetVolume(channels[movewhooshsound], 256);
6213 OPENAL_SetPaused(channels[movewhooshsound], false);
6214 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6216 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6217 player[k].rotation=-asin(0-lowpointtarget.x);
6218 player[k].rotation*=360/6.28;
6219 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6220 player[k].targetrotation=player[k].rotation;
6221 player[k].lowrotation=player[k].rotation;
6222 if(k==0)numwallflipped++;
6226 lowpoint=tempcoords1;
6227 lowpointtarget=lowpoint+player[k].facing*2;
6228 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6229 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6231 player[k].targetanimation=walljumpbackanim;
6232 player[k].targetframe=0;
6235 gLoc[0]=player[k].coords.x;
6236 gLoc[1]=player[k].coords.y;
6237 gLoc[2]=player[k].coords.z;
6241 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6242 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6243 OPENAL_SetVolume(channels[movewhooshsound], 256);
6244 OPENAL_SetPaused(channels[movewhooshsound], false);
6245 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6247 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6248 player[k].rotation=-asin(0-lowpointtarget.x);
6249 player[k].rotation*=360/6.28;
6250 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6251 player[k].targetrotation=player[k].rotation;
6252 player[k].lowrotation=player[k].rotation;
6253 if(k==0)numwallflipped++;
6257 lowpoint=tempcoords1;
6258 lowpointtarget=lowpoint-player[k].facing*2;
6259 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6260 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6262 player[k].targetanimation=walljumpfrontanim;
6263 player[k].targetframe=0;
6266 gLoc[0]=player[k].coords.x;
6267 gLoc[1]=player[k].coords.y;
6268 gLoc[2]=player[k].coords.z;
6272 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6273 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6274 OPENAL_SetVolume(channels[movewhooshsound], 256);
6275 OPENAL_SetPaused(channels[movewhooshsound], false);
6276 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6278 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6279 player[k].rotation=-asin(0-lowpointtarget.x);
6280 player[k].rotation*=360/6.28;
6281 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6282 player[k].rotation+=180;
6283 player[k].targetrotation=player[k].rotation;
6284 player[k].lowrotation=player[k].rotation;
6285 if(k==0)numwallflipped++;
6293 else if(objects.type[i]==rocktype){
6294 lowpoint2=player[k].coords;
6295 lowpoint=player[k].coords;
6297 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6298 player[k].coords=colpoint;
6299 player[k].collide=1;
6302 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6303 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6305 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6307 player[k].targetframe=0;
6308 player[k].onterrain=1;
6310 if(player[k].id==0){
6311 OPENAL_SetPaused(channels[whooshsound], true);
6312 OPENAL_SetVolume(channels[whooshsound], 0);
6315 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6316 if(player[k].isFlip())player[k].jumppower=-4;
6317 player[k].targetanimation=player[k].getLanding();
6320 gLoc[0]=player[k].coords.x;
6321 gLoc[1]=player[k].coords.y;
6322 gLoc[2]=player[k].coords.z;
6323 vel[0]=player[k].velocity.x;
6324 vel[1]=player[k].velocity.y;
6325 vel[2]=player[k].velocity.z;
6326 PlaySoundEx( landsound, samp[landsound], NULL, true);
6327 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6328 OPENAL_SetVolume(channels[landsound], 128);
6329 OPENAL_SetPaused(channels[landsound], false);
6331 envsound[numenvsounds]=player[k].coords;
6332 envsoundvol[numenvsounds]=16;
6333 envsoundlife[numenvsounds]=.4;
6342 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6343 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6344 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6345 lowpoint=player[k].coords;
6347 if(objects.type[i]!=rocktype)
6348 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6349 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6350 player[k].coords=lowpoint;
6351 player[k].coords.y-=1.35;
6352 player[k].collide=1;
6354 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)){
6355 lowpoint=player[k].coords;
6356 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6357 lowpoint=player[k].coords;
6361 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6362 lowpointtarget=lowpoint+facing*1.4;
6363 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6365 lowpoint=player[k].coords;
6367 lowpointtarget=lowpoint+facing*1.4;
6369 lowpointtarget2=lowpointtarget;
6371 lowpointtarget3=lowpointtarget;
6373 lowpointtarget4=lowpointtarget;
6375 lowpointtarget5=lowpointtarget;
6377 lowpointtarget6=lowpointtarget;
6379 lowpointtarget7=lowpoint;
6381 lowpointtarget2.x+=.1;
6383 lowpointtarget3.z+=.1;
6385 lowpointtarget4.x-=.1;
6387 lowpointtarget5.z-=.1;
6389 lowpointtarget6.y+=45/13;
6390 lowpointtarget6+=facing*.6;
6391 lowpointtarget7.y+=90/13;
6392 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6393 if(objects.friction[i]>.5)
6396 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6397 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6398 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6399 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)
6401 lowpoint=player[k].coords;
6402 lowpoint.y+=(float)j/13;
6403 lowpointtarget=lowpoint+facing*1.4;
6404 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6408 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6411 if(j<=25&&player[k].targetanimation==jumpdownanim){
6414 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6415 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6416 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)*/){
6417 lowpoint=player[k].coords;
6418 lowpoint.y+=(float)j/13;
6419 lowpointtarget=lowpoint+facing*1.3;
6420 flatfacing=player[k].coords;
6421 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6422 player[k].coords.y=lowpointtarget.y-.07;
6423 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6425 if(j>10||!player[k].isRun()){
6426 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6427 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6431 gLoc[0]=player[k].coords.x;
6432 gLoc[1]=player[k].coords.y;
6433 gLoc[2]=player[k].coords.z;
6434 vel[0]=player[k].velocity.x;
6435 vel[1]=player[k].velocity.y;
6436 vel[2]=player[k].velocity.z;
6437 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6438 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6439 OPENAL_SetVolume(channels[jumpsound], 128);
6440 OPENAL_SetPaused(channels[jumpsound], false);
6442 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6443 player[k].rotation=-asin(0-lowpointtarget.x);
6444 player[k].rotation*=360/6.28;
6445 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6446 player[k].targetrotation=player[k].rotation;
6447 player[k].lowrotation=player[k].rotation;
6449 //player[k].velocity=lowpointtarget*.03;
6450 player[k].velocity=0;
6452 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6453 //player[k].currentanimation=climbanim;
6454 player[k].targetanimation=climbanim;
6455 player[k].jumppower=0;
6456 player[k].jumpclimb=1;
6458 player[k].transspeed=6;
6461 //player[k].currentframe=1;
6462 player[k].targetframe=1;
6464 //player[k].currentframe=0;
6465 player[k].targetframe=0;
6466 //player[k].currentanimation=hanganim;
6467 player[k].targetanimation=hanganim;
6468 player[k].jumppower=0;
6482 if(player[k].collide<=0){
6483 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()){
6484 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)){
6485 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6486 player[k].targetanimation=jumpdownanim;
6487 player[k].targetframe=0;
6492 gLoc[0]=player[k].coords.x;
6493 gLoc[1]=player[k].coords.y;
6494 gLoc[2]=player[k].coords.z;
6495 vel[0]=player[k].velocity.x;
6496 vel[1]=player[k].velocity.y;
6497 vel[2]=player[k].velocity.z;
6499 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6500 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6501 OPENAL_SetVolume(channels[whooshsound], 128);
6502 OPENAL_SetPaused(channels[whooshsound], false);
6505 player[k].velocity.y+=gravity;
6510 player[k].realoldcoords=player[k].coords;
6513 static XYZ oldviewer;
6516 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6517 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6518 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6519 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6520 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6521 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6522 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6523 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6527 player[0].forwardkeydown=0;
6528 player[0].leftkeydown=0;
6529 player[0].backkeydown=0;
6530 player[0].rightkeydown=0;
6531 player[0].jumpkeydown=0;
6532 player[0].crouchkeydown=0;
6533 player[0].drawkeydown=0;
6534 player[0].throwkeydown=0;
6537 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6540 static bool endkeydown;
6547 facing=DoRotation(facing,-rotation2,0,0);
6548 facing=DoRotation(facing,0,0-rotation,0);
6553 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6555 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6556 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6557 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6558 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6559 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6560 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6561 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)
6562 ||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)
6563 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6565 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6566 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6567 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6568 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6569 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6570 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6571 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6572 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6573 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6574 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6575 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6577 participantfocus[whichdialogue][indialogue]=whichend;
6578 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6579 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6582 participantfocus[whichdialogue][indialogue]=-1;
6584 if(player[participantfocus[whichdialogue][indialogue]].dead){
6589 dialoguecamera[whichdialogue][indialogue]=viewer;
6590 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6591 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6593 if(indialogue<numdialogueboxes[whichdialogue]){
6594 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6595 static float gLoc[3];
6596 static float vel[3];
6598 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6599 temppos=temppos-viewer;
6600 Normalise(&temppos);
6605 gLoc[2]=temppos.z;vel[0]=0;
6609 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6610 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6611 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6612 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6613 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6614 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6615 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6616 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6617 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6618 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6619 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6620 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6621 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6622 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6623 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6624 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6625 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6626 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6627 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6628 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6629 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6630 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6631 OPENAL_SetVolume(channels[whichsoundplay], 256);
6632 OPENAL_SetPaused(channels[whichsoundplay], false);
6636 for(j=0;j<numplayers;j++){
6637 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6642 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)
6643 ||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)
6646 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6647 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6648 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6649 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6650 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6651 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6652 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6653 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6654 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6655 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6656 participantfacing[whichdialogue][indialogue][whichend]=facing;
6658 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)
6659 &&!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)
6660 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6663 if(indialogue>=numdialogueboxes[whichdialogue]){
6670 OPENAL_SetPaused(channels[whooshsound], true);
6671 viewer=dialoguecamera[whichdialogue][indialogue];
6672 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
6673 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
6675 rotation=dialoguecamerarotation[whichdialogue][indialogue];
6676 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
6677 if(dialoguetime>0.5)
6678 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)
6679 ||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)
6680 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
6683 if(indialogue<numdialogueboxes[whichdialogue]){
6684 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6685 static float gLoc[3];
6686 static float vel[3];
6688 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6689 temppos=temppos-viewer;
6690 Normalise(&temppos);
6695 gLoc[2]=temppos.z;vel[0]=0;
6699 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6700 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6701 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6702 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6703 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6704 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6705 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6706 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6707 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6708 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6709 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6710 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6711 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6712 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6713 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6714 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6715 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6716 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6717 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6718 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6719 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
6720 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
6721 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6722 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6723 OPENAL_SetVolume(channels[whichsoundplay], 256);
6724 OPENAL_SetPaused(channels[whichsoundplay], false);
6726 if(dialogueboxsound[whichdialogue][indialogue]==-5){
6727 hotspot[numhotspots]=player[0].coords;
6728 hotspotsize[numhotspots]=10;
6729 hotspottype[numhotspots]=-1;
6733 if(dialogueboxsound[whichdialogue][indialogue]==-6){
6737 if(player[participantfocus[whichdialogue][indialogue]].dead){
6745 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)
6746 &&!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)
6747 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6750 if(indialogue>=numdialogueboxes[whichdialogue]){
6754 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
6757 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
6760 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
6762 for(i=1;i<numplayers;i++){
6763 player[i].aitype = attacktypecutoff;
6770 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
6771 else oldbuttondialogue=1;
6773 static float keyrefreshdelay=0,bigrefreshdelay=0;
6777 /*keyrefreshdelay-=multiplier;
6778 bigrefreshdelay-=multiplier;
6780 if(keyrefreshdelay<=0){
6781 static int concat[4];
6783 concat[0]=player[0].forwardkeydown;
6784 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
6785 concat[0]=concat[0]*2+player[0].rightkeydown;
6786 concat[0]=concat[0]*2+player[0].leftkeydown;
6787 concat[0]=concat[0]*2+player[0].backkeydown;
6788 concat[0]=concat[0]*2+player[0].jumpkeydown;
6789 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
6790 concat[0]=concat[0]*2+player[0].crouchkeydown;
6792 concat[1]=player[0].crouchtogglekeydown;
6793 concat[1]=concat[1]*2+player[0].drawkeydown;
6794 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
6795 concat[1]=concat[1]*2+player[0].throwkeydown;
6796 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
6797 concat[1]=concat[1]*2+player[0].attackkeydown;
6799 //concat[2]=(char)((int)(rotation/2)%180);
6801 //concat[3]=(char)((int)(rotation2/2)%180);
6803 chatname[0]=concat[0]-128;
6804 chatname[1]=concat[1]-128;
6805 //chatname[2]=concat[2]-128;
6806 //chatname[3]=concat[3]-128;
6808 memcpy(chatname+temppoint,&rotation,sizeof(float));
6809 temppoint+=sizeof(float);
6810 memcpy(chatname+temppoint,&rotation2,sizeof(float));
6811 temppoint+=sizeof(float);
6813 chatname[temppoint]='\0';
6815 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
6816 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
6817 //keyrefreshdelay=.01;
6818 keyrefreshdelay=.03;
6821 if(bigrefreshdelay<=0){
6824 memcpy(chatname+temppoint,&i,sizeof(int));
6825 temppoint+=sizeof(int);
6826 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
6827 temppoint+=sizeof(float);
6828 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
6829 temppoint+=sizeof(float);
6830 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
6831 temppoint+=sizeof(float);
6832 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
6833 temppoint+=sizeof(float);
6834 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
6835 temppoint+=sizeof(float);
6836 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
6837 temppoint+=sizeof(int);
6838 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
6839 temppoint+=sizeof(int);
6840 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
6841 temppoint+=sizeof(float);
6842 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
6843 temppoint+=sizeof(float);
6844 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
6845 temppoint+=sizeof(float);
6846 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
6847 temppoint+=sizeof(int);
6848 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
6849 temppoint+=sizeof(int);
6850 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
6851 temppoint+=sizeof(float);
6852 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
6853 temppoint+=sizeof(float);
6854 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
6855 temppoint+=sizeof(float);
6856 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
6857 temppoint+=sizeof(int);
6858 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
6859 temppoint+=sizeof(int);
6860 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
6861 temppoint+=sizeof(int);
6862 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
6863 temppoint+=sizeof(int);
6864 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
6865 temppoint+=sizeof(int);
6866 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
6867 temppoint+=sizeof(int);
6868 chatname[temppoint]='\0';
6870 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);
6871 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
6872 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
6874 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);
6876 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
6877 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
6879 //bigrefreshdelay=.02;
6884 if(!player[0].jumpkeydown){
6885 player[0].jumptogglekeydown=0;
6887 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
6890 dialoguetime+=multiplier;
6891 skybox.cloudmove+=multiplier;
6892 hawkrotation+=multiplier*25;
6894 realhawkcoords.x=25;
6895 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
6896 hawkcalldelay-=multiplier/2;
6898 if(hawkcalldelay<=0)
6900 static float gLoc[3];
6901 static float vel[3];
6902 gLoc[0]=realhawkcoords.x;
6903 gLoc[1]=realhawkcoords.y;
6904 gLoc[2]=realhawkcoords.z;
6908 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
6909 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
6910 OPENAL_SetVolume(channels[hawksound], 128);
6911 OPENAL_SetPaused(channels[hawksound], false);
6913 hawkcalldelay=16+abs(Random()%8);
6915 static float temptexdetail;
6918 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
6919 player[0].damagetolerance=200000;
6922 player[0].permanentdamage=0;
6923 player[0].superpermanentdamage=0;
6926 whichchar = abs(Random()%7);
6927 registrationname[whichchar]+=1;
6931 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
6933 if(environment>2)environment=0;
6934 Setenvironment(environment);
6940 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
6944 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
6945 cameramode=1-cameramode;
6946 cameratogglekeydown=1;
6949 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
6950 cameratogglekeydown=0;
6953 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
6954 if(player[0].num_weapons>0){
6955 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
6956 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
6957 else weapons.type[player[0].weaponids[0]]=sword;
6958 if(weapons.type[player[0].weaponids[0]]==sword){
6959 weapons.mass[player[0].weaponids[0]]=1.5;
6960 weapons.tipmass[player[0].weaponids[0]]=1;
6961 weapons.length[player[0].weaponids[0]]=.8;
6963 if(weapons.type[player[0].weaponids[0]]==staff){
6964 weapons.mass[player[0].weaponids[0]]=2;
6965 weapons.tipmass[player[0].weaponids[0]]=1;
6966 weapons.length[player[0].weaponids[0]]=1.5;
6969 if(weapons.type[player[0].weaponids[0]]==knife){
6970 weapons.mass[player[0].weaponids[0]]=1;
6971 weapons.tipmass[player[0].weaponids[0]]=1.2;
6972 weapons.length[player[0].weaponids[0]]=.25;
6976 /*for(i=0;i<objects.numobjects;i++){
6977 if(objects.type[i]==treeleavestype){
6978 for(j=0;j<objects.numobjects;j++){
6979 if(objects.type[j]==treetrunktype)
6980 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
6981 objects.scale[i]=objects.scale[j];
6985 detailtogglekeydown=1;
6988 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
6990 float closestdist=-1;
6993 for(i=1;i<numplayers;i++){
6994 distance=findDistancefast(&player[i].coords,&player[0].coords);
6995 if(closestdist==-1||distance<closestdist){
6996 closestdist=distance;
7001 if(player[closest].num_weapons)
7003 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7004 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7005 else weapons.type[player[closest].weaponids[0]]=sword;
7006 if(weapons.type[player[closest].weaponids[0]]==sword){
7007 weapons.mass[player[closest].weaponids[0]]=1.5;
7008 weapons.tipmass[player[closest].weaponids[0]]=1;
7009 weapons.length[player[closest].weaponids[0]]=.8;
7011 if(weapons.type[player[0].weaponids[0]]==staff){
7012 weapons.mass[player[0].weaponids[0]]=2;
7013 weapons.tipmass[player[0].weaponids[0]]=1;
7014 weapons.length[player[0].weaponids[0]]=1.5;
7016 if(weapons.type[player[closest].weaponids[0]]==knife){
7017 weapons.mass[player[closest].weaponids[0]]=1;
7018 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7019 weapons.length[player[closest].weaponids[0]]=.25;
7022 if(!player[closest].num_weapons)
7024 player[closest].weaponids[0]=weapons.numweapons;
7025 weapons.owner[weapons.numweapons]=closest;
7026 weapons.type[weapons.numweapons]=knife;
7027 weapons.damage[weapons.numweapons]=0;
7028 weapons.numweapons++;
7029 player[closest].num_weapons=1;
7030 if(weapons.type[player[closest].weaponids[0]]==sword){
7031 weapons.mass[player[closest].weaponids[0]]=1.5;
7032 weapons.tipmass[player[closest].weaponids[0]]=1;
7033 weapons.length[player[closest].weaponids[0]]=.8;
7035 if(weapons.type[player[closest].weaponids[0]]==knife){
7036 weapons.mass[player[closest].weaponids[0]]=1;
7037 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7038 weapons.length[player[closest].weaponids[0]]=.25;
7042 detailtogglekeydown=1;
7045 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7047 float closestdist=-1;
7050 for(i=1;i<numplayers;i++){
7051 distance=findDistancefast(&player[i].coords,&player[0].coords);
7052 if(closestdist==-1||distance<closestdist){
7053 closestdist=distance;
7058 player[closest].rotation+=multiplier*50;
7059 player[closest].targetrotation=player[closest].rotation;
7063 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7065 float closestdist=-1;
7068 for(i=1;i<numplayers;i++){
7069 distance=findDistancefast(&player[i].coords,&player[0].coords);
7070 if(closestdist==-1||distance<closestdist){
7071 closestdist=distance;
7075 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7078 player[closest].whichskin++;
7079 if(player[closest].whichskin>9)player[closest].whichskin=0;
7080 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7082 LoadTextureSave(creatureskin[player[closest].creature][player[closest].whichskin],
7083 &player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7086 if(player[closest].numclothes){
7087 for(i=0;i<player[closest].numclothes;i++){
7088 tintr=player[closest].clothestintr[i];
7089 tintg=player[closest].clothestintg[i];
7090 tintb=player[closest].clothestintb[i];
7091 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7093 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7096 detailtogglekeydown=1;
7099 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7101 float closestdist=-1;
7104 for(i=1;i<numplayers;i++){
7105 distance=findDistancefast(&player[i].coords,&player[0].coords);
7106 if(closestdist==-1||distance<closestdist){
7107 closestdist=distance;
7112 if(player[closest].creature==wolftype){
7113 headprop=player[closest].proportionhead.x/1.1;
7114 bodyprop=player[closest].proportionbody.x/1.1;
7115 armprop=player[closest].proportionarms.x/1.1;
7116 legprop=player[closest].proportionlegs.x/1.1;
7119 if(player[closest].creature==rabbittype){
7120 headprop=player[closest].proportionhead.x/1.2;
7121 bodyprop=player[closest].proportionbody.x/1.05;
7122 armprop=player[closest].proportionarms.x/1.00;
7123 legprop=player[closest].proportionlegs.x/1.1;
7127 if(player[closest].creature==rabbittype){
7128 player[closest].skeleton.id=closest;
7129 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);
7130 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7131 player[closest].whichskin=0;
7132 player[closest].creature=wolftype;
7134 player[closest].proportionhead=1.1;
7135 player[closest].proportionbody=1.1;
7136 player[closest].proportionarms=1.1;
7137 player[closest].proportionlegs=1.1;
7138 player[closest].proportionlegs.y=1.1;
7139 player[closest].scale=.23*5*player[0].scale;
7141 player[closest].damagetolerance=300;
7145 player[closest].skeleton.id=closest;
7146 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);
7147 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7148 player[closest].whichskin=0;
7149 player[closest].creature=rabbittype;
7151 player[closest].proportionhead=1.2;
7152 player[closest].proportionbody=1.05;
7153 player[closest].proportionarms=1.00;
7154 player[closest].proportionlegs=1.1;
7155 player[closest].proportionlegs.y=1.05;
7156 player[closest].scale=.2*5*player[0].scale;
7158 player[closest].damagetolerance=200;
7161 if(player[closest].creature==wolftype){
7162 player[closest].proportionhead=1.1*headprop;
7163 player[closest].proportionbody=1.1*bodyprop;
7164 player[closest].proportionarms=1.1*armprop;
7165 player[closest].proportionlegs=1.1*legprop;
7168 if(player[closest].creature==rabbittype){
7169 player[closest].proportionhead=1.2*headprop;
7170 player[closest].proportionbody=1.05*bodyprop;
7171 player[closest].proportionarms=1.00*armprop;
7172 player[closest].proportionlegs=1.1*legprop;
7173 player[closest].proportionlegs.y=1.05*legprop;
7177 detailtogglekeydown=1;
7180 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7181 detailtogglekeydown=0;
7184 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7187 slomotogglekeydown=1;
7191 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7193 float closestdist=-1;
7195 XYZ flatfacing2,flatvelocity2;
7198 for(i=1;i<numplayers;i++){
7199 distance=findDistancefast(&player[i].coords,&player[0].coords);
7200 if(distance<144&&!player[i].headless)
7201 if(closestdist==-1||distance<closestdist){
7202 closestdist=distance;
7204 blah = player[i].coords;
7209 XYZ headspurtdirection;
7210 int i = player[closest].skeleton.jointlabels[head];
7211 for(k=0;k<player[closest].skeleton.num_joints; k++){
7212 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7213 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7214 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;
7215 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7216 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7217 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7218 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7219 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7220 Normalise(&headspurtdirection);
7221 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7222 flatvelocity2+=headspurtdirection*8;
7223 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7225 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7235 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7236 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7237 OPENAL_SetVolume(channels[splattersound], 256);
7238 OPENAL_SetPaused(channels[splattersound], false);
7240 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7241 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7242 OPENAL_SetVolume(channels[breaksound2], 100);
7243 OPENAL_SetPaused(channels[breaksound2], false);
7245 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7246 player[closest].RagDoll(0);
7247 player[closest].dead=2;
7248 player[closest].headless=1;
7249 player[closest].DoBloodBig(3,165);
7254 explodetogglekeydown=1;
7257 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7259 float closestdist=-1;
7261 XYZ flatfacing2,flatvelocity2;
7264 for(i=1;i<numplayers;i++){
7265 distance=findDistancefast(&player[i].coords,&player[0].coords);
7267 if(closestdist==-1||distance<closestdist){
7268 closestdist=distance;
7270 blah=player[i].coords;
7284 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7285 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7286 OPENAL_SetVolume(channels[splattersound], 256);
7287 OPENAL_SetPaused(channels[splattersound], false);
7289 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7290 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7291 OPENAL_SetVolume(channels[breaksound2], 600);
7292 OPENAL_SetPaused(channels[breaksound2], false);
7294 for(i=0;i<player[closest].skeleton.num_joints; i++){
7295 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7296 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7297 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;
7298 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7299 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7300 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7301 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7302 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7303 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7304 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7307 for(i=0;i<player[closest].skeleton.num_joints; i++){
7308 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7309 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7310 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;
7311 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7312 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7313 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7314 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7315 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7316 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7319 for(i=0;i<player[closest].skeleton.num_joints; i++){
7320 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7321 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7322 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;
7323 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7324 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7325 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7326 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7327 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7328 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7331 for(i=0;i<player[closest].skeleton.num_joints; i++){
7332 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7333 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7334 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;
7335 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7336 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7337 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7338 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7339 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7340 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7344 for(j=0;j<numplayers; j++){
7346 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7347 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7348 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7349 player[j].skeleton.longdead=0;
7350 player[j].RagDoll(0);
7351 for(i=0;i<player[j].skeleton.num_joints; i++){
7352 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7353 if(findDistancefast(&temppos,&player[closest].coords)<25){
7354 flatvelocity2=temppos-player[closest].coords;
7355 Normalise(&flatvelocity2);
7356 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7363 player[closest].DoDamage(10000);
7364 player[closest].RagDoll(0);
7365 player[closest].dead=2;
7366 player[closest].coords=20;
7367 player[closest].skeleton.free=2;
7373 explodetogglekeydown=1;
7376 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7377 explodetogglekeydown=0;
7381 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7383 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7384 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7385 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7386 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7387 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7388 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7389 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7391 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7392 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7393 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7394 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7395 for(j=0;j<player[0].num_weapons;j++){
7396 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7398 fwrite( &environment, 1, sizeof(int), tfile );
7400 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7401 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7402 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7403 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7404 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7406 fwrite( &numplayers, 1, sizeof(int), tfile );
7407 if(numplayers>1&&numplayers<maxplayers)
7408 for(i=1;i<numplayers;i++){
7409 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7410 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7411 for(j=0;j<player[i].num_weapons;j++){
7412 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7414 if(player[i].numwaypoints<30){
7415 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7416 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7417 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7418 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7421 player[i].numwaypoints=0;
7422 player[i].waypoint=0;
7423 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7424 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7425 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7431 slomotogglekeydown=1;
7434 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7435 slomotogglekeydown=0;
7439 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7440 player[0].onfire=1-player[0].onfire;
7441 if(player[0].onfire){
7442 player[0].CatchFire();
7444 if(!player[0].onfire){
7447 gLoc[0]=player[0].coords.x;
7448 gLoc[1]=player[0].coords.y;
7449 gLoc[2]=player[0].coords.z;
7453 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7454 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7455 OPENAL_SetVolume(channels[fireendsound], 256);
7456 OPENAL_SetPaused(channels[fireendsound], false);
7457 OPENAL_SetPaused(channels[stream_firesound], true);
7459 slomotogglekeydown=1;
7462 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7463 if(player[0].bleeding<=0)
7464 player[0].DoBlood(1,255);
7468 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7470 float closestdist=-1;
7473 for(i=1;i<numplayers;i++){
7474 distance=findDistancefast(&player[i].coords,&player[0].coords);
7475 if(closestdist==-1||distance<closestdist){
7476 closestdist=distance;
7480 if(closestdist>0&&closest>=0){
7481 //player[closest]=player[numplayers-1];
7482 //player[closest].skeleton=player[numplayers-1].skeleton;
7485 drawmodetogglekeydown=1;
7488 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7490 float closestdist=-1;
7493 for(i=1;i<max_objects;i++){
7494 distance=findDistancefast(&objects.position[i],&player[0].coords);
7495 if(closestdist==-1||distance<closestdist){
7496 closestdist=distance;
7500 if(closestdist>0&&closest>=0){
7501 objects.position[closest].y-=500;
7503 drawmodetogglekeydown=1;
7506 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7508 //if(drawmode>2)drawmode=0;
7509 if(objects.numobjects<max_objects-1){
7511 boxcoords.x=player[0].coords.x;
7512 boxcoords.z=player[0].coords.z;
7513 boxcoords.y=player[0].coords.y-3;
7514 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7515 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7516 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7517 float temprotat,temprotat2;
7518 temprotat=editorrotation;
7519 temprotat2=editorrotation2;
7520 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7521 if(temprotat2<0)temprotat2=Random()%360;
7523 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7524 if(editortype==treetrunktype)
7525 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7528 drawmodetogglekeydown=1;
7531 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7532 if(numplayers<maxplayers-1){
7533 player[numplayers].scale=.2*5*player[0].scale;
7534 player[numplayers].creature=rabbittype;
7535 player[numplayers].howactive=editoractive;
7536 player[numplayers].skeleton.id=numplayers;
7537 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);
7539 //texsize=512*512*3/texdetail/texdetail;
7540 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7541 //player[numplayers].skeleton.skinText.resize(texsize);
7543 k=abs(Random()%2)+1;
7545 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7546 player[numplayers].whichskin=0;
7549 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7550 player[numplayers].whichskin=1;
7553 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7554 player[numplayers].whichskin=2;
7557 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7558 player[numplayers].power=1;
7559 player[numplayers].speedmult=1;
7560 player[numplayers].currentanimation=bounceidleanim;
7561 player[numplayers].targetanimation=bounceidleanim;
7562 player[numplayers].currentframe=0;
7563 player[numplayers].targetframe=1;
7564 player[numplayers].target=0;
7565 player[numplayers].bled=0;
7566 player[numplayers].speed=1+(float)(Random()%100)/1000;
7568 player[numplayers].targetrotation=player[0].targetrotation;
7569 player[numplayers].rotation=player[0].rotation;
7571 player[numplayers].velocity=0;
7572 player[numplayers].coords=player[0].coords;
7573 player[numplayers].oldcoords=player[numplayers].coords;
7574 player[numplayers].realoldcoords=player[numplayers].coords;
7576 player[numplayers].id=numplayers;
7577 player[numplayers].skeleton.id=numplayers;
7578 player[numplayers].updatedelay=0;
7579 player[numplayers].normalsupdatedelay=0;
7581 player[numplayers].aitype=passivetype;
7582 player[numplayers].aitarget=0;
7584 if(player[0].creature==wolftype){
7585 headprop=player[0].proportionhead.x/1.1;
7586 bodyprop=player[0].proportionbody.x/1.1;
7587 armprop=player[0].proportionarms.x/1.1;
7588 legprop=player[0].proportionlegs.x/1.1;
7591 if(player[0].creature==rabbittype){
7592 headprop=player[0].proportionhead.x/1.2;
7593 bodyprop=player[0].proportionbody.x/1.05;
7594 armprop=player[0].proportionarms.x/1.00;
7595 legprop=player[0].proportionlegs.x/1.1;
7598 if(player[numplayers].creature==wolftype){
7599 player[numplayers].proportionhead=1.1*headprop;
7600 player[numplayers].proportionbody=1.1*bodyprop;
7601 player[numplayers].proportionarms=1.1*armprop;
7602 player[numplayers].proportionlegs=1.1*legprop;
7605 if(player[numplayers].creature==rabbittype){
7606 player[numplayers].proportionhead=1.2*headprop;
7607 player[numplayers].proportionbody=1.05*bodyprop;
7608 player[numplayers].proportionarms=1.00*armprop;
7609 player[numplayers].proportionlegs=1.1*legprop;
7610 player[numplayers].proportionlegs.y=1.05*legprop;
7613 player[numplayers].headless=0;
7614 player[numplayers].onfire=0;
7617 player[numplayers].proportionhead.z=0;
7618 player[numplayers].proportionbody.z=0;
7619 player[numplayers].proportionarms.z=0;
7620 player[numplayers].proportionlegs.z=0;
7623 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7625 player[numplayers].damagetolerance=200;
7627 player[numplayers].protectionhead=player[0].protectionhead;
7628 player[numplayers].protectionhigh=player[0].protectionhigh;
7629 player[numplayers].protectionlow=player[0].protectionlow;
7630 player[numplayers].armorhead=player[0].armorhead;
7631 player[numplayers].armorhigh=player[0].armorhigh;
7632 player[numplayers].armorlow=player[0].armorlow;
7633 player[numplayers].metalhead=player[0].metalhead;
7634 player[numplayers].metalhigh=player[0].metalhigh;
7635 player[numplayers].metallow=player[0].metallow;
7637 player[numplayers].immobile=player[0].immobile;
7639 player[numplayers].numclothes=player[0].numclothes;
7640 if(player[numplayers].numclothes)
7641 for(i=0;i<player[numplayers].numclothes;i++){
7642 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
7643 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
7644 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
7645 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
7646 tintr=player[numplayers].clothestintr[i];
7647 tintg=player[numplayers].clothestintg[i];
7648 tintb=player[numplayers].clothestintb[i];
7649 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7651 if(player[numplayers].numclothes){
7652 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
7655 player[numplayers].power=player[0].power;
7656 player[numplayers].speedmult=player[0].speedmult;
7658 player[numplayers].damage=0;
7659 player[numplayers].permanentdamage=0;
7660 player[numplayers].superpermanentdamage=0;
7661 player[numplayers].deathbleeding=0;
7662 player[numplayers].bleeding=0;
7663 player[numplayers].numwaypoints=0;
7664 player[numplayers].waypoint=0;
7665 player[numplayers].jumppath=0;
7666 player[numplayers].weaponstuck=-1;
7667 player[numplayers].weaponactive=-1;
7668 player[numplayers].num_weapons=0;
7669 player[numplayers].bloodloss=0;
7670 player[numplayers].dead=0;
7672 player[numplayers].loaded=1;
7676 drawmodetogglekeydown=1;
7679 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
7680 if(player[numplayers-1].numwaypoints<90){
7681 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
7682 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
7683 player[numplayers-1].numwaypoints++;
7685 drawmodetogglekeydown=1;
7688 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7689 if(numpathpoints<30){
7690 bool connected,alreadyconnected;
7693 for(i=0;i<numpathpoints;i++){
7694 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
7696 for(j=0;j<numpathpointconnect[pathpointselected];j++){
7697 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
7699 if(!alreadyconnected){
7700 numpathpointconnect[pathpointselected]++;
7702 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
7708 pathpoint[numpathpoints-1]=player[0].coords;
7709 numpathpointconnect[numpathpoints-1]=0;
7710 if(numpathpoints>1&&pathpointselected!=-1){
7711 numpathpointconnect[pathpointselected]++;
7712 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
7714 pathpointselected=numpathpoints-1;
7717 drawmodetogglekeydown=1;
7720 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
7721 pathpointselected++;
7722 if(pathpointselected>=numpathpoints)pathpointselected=-1;
7723 drawmodetogglekeydown=1;
7725 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7726 pathpointselected--;
7727 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
7728 drawmodetogglekeydown=1;
7730 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7731 if(pathpointselected!=-1){
7733 pathpoint[pathpointselected]=pathpoint[numpathpoints];
7734 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
7735 for(i=0;i<numpathpointconnect[pathpointselected];i++){
7736 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
7738 for(i=0;i<numpathpoints;i++){
7739 for(j=0;j<numpathpointconnect[i];j++){
7740 if(pathpointconnect[i][j]==pathpointselected){
7741 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
7742 numpathpointconnect[i]--;
7744 if(pathpointconnect[i][j]==numpathpoints){
7745 pathpointconnect[i][j]=pathpointselected;
7749 pathpointselected=numpathpoints-1;
7751 drawmodetogglekeydown=1;
7754 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7755 editorenabled=1-editorenabled;
7757 player[0].damagetolerance=100000;
7759 player[0].superpermanentdamage=0;
7760 player[0].bloodloss=0;
7761 player[0].deathbleeding=0;
7764 player[0].damagetolerance=200;
7766 player[0].permanentdamage=0;
7767 player[0].superpermanentdamage=0;
7768 player[0].bloodloss=0;
7769 player[0].deathbleeding=0;
7771 drawmodetogglekeydown=1;
7774 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7776 if(editortype==treeleavestype||editortype==10)editortype--;
7777 if(editortype<0)editortype=firetype;
7778 drawmodetogglekeydown=1;
7781 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7783 if(editortype==treeleavestype||editortype==10)editortype++;
7784 if(editortype>firetype)editortype=0;
7785 drawmodetogglekeydown=1;
7788 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7789 editorrotation-=multiplier*100;
7790 if(editorrotation<-.01)editorrotation=-.01;
7791 drawmodetogglekeydown=1;
7794 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7795 editorrotation+=multiplier*100;
7796 drawmodetogglekeydown=1;
7799 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7800 editorsize+=multiplier;
7801 drawmodetogglekeydown=1;
7804 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7805 editorsize-=multiplier;
7806 if(editorsize<.1)editorsize=.1;
7807 drawmodetogglekeydown=1;
7811 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7812 mapradius-=multiplier*10;
7815 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7816 mapradius+=multiplier*10;
7819 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7820 mapcenter.x+=multiplier*20;
7823 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7824 mapcenter.x-=multiplier*20;
7827 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7828 mapcenter.z+=multiplier*20;
7831 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7832 mapcenter.z-=multiplier*20;
7835 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7836 editorrotation2+=multiplier*100;
7839 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7840 editorrotation2-=multiplier*100;
7841 if(editorrotation2<-.01)editorrotation2=-.01;
7843 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7845 float closestdist=-1;
7847 for(i=0;i<objects.numobjects;i++){
7848 distance=findDistancefast(&objects.position[i],&player[0].coords);
7849 if(closestdist==-1||distance<closestdist){
7850 closestdist=distance;
7854 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
7855 drawmodetogglekeydown=1;
7859 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)){
7860 drawmodetogglekeydown=0;
7863 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
7864 //if(!player[0].skeleton.free)player[0].damage+=500;
7865 player[0].RagDoll(0);
7866 //player[0].spurt=1;
7867 //player[0].DoDamage(1000);
7871 gLoc[0]=player[0].coords.x;
7872 gLoc[1]=player[0].coords.y;
7873 gLoc[2]=player[0].coords.z;
7874 vel[0]=player[0].velocity.x;
7875 vel[1]=player[0].velocity.y;
7876 vel[2]=player[0].velocity.z;
7877 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
7878 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
7879 OPENAL_SetVolume(channels[whooshsound], 128);
7880 OPENAL_SetPaused(channels[whooshsound], false);
7881 //OPENAL_SetPaused(channels[whooshsound], true);
7883 texturesizetogglekeydown=1;
7886 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
7889 float closestdist=-1;
7891 for(i=0;i<objects.numobjects;i++){
7892 if(objects.type[i]==treeleavestype){
7893 objects.scale[i]*=.9;
7896 texturesizetogglekeydown=1;
7899 static XYZ relative;
7900 static int randattack;
7902 static bool playerrealattackkeydown=0;
7904 if(!buttons[0])oldbutton=0;
7905 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
7906 if(oldattackkey)player[0].attackkeydown=0;
7907 if(oldattackkey)playerrealattackkeydown=0;
7908 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
7909 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);
7910 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
7911 for(k=0;k<numplayers;k++){
7912 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
7913 player[k].Reverse();
7917 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
7919 for(k=0;k<numplayers;k++){
7920 if(indialogue!=-1)player[k].attackkeydown=0;
7921 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
7922 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
7923 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)){
7924 player[k].jumppower-=2;
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 for(i=0;i<numplayers;i++){
7929 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
7930 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
7931 player[k].targetanimation=dodgebackanim;
7933 player[k].targetframe=0;
7934 rotatetarget=player[i].coords-player[k].coords;
7935 Normalise(&rotatetarget);
7936 player[k].targetrotation=-asin(0-rotatetarget.x);
7937 player[k].targetrotation*=360/6.28;
7938 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
7940 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
7943 if(player[k].targetanimation!=dodgebackanim){
7944 if(k==0)numflipped++;
7945 player[k].targetanimation=backhandspringanim;
7947 player[k].targetframe=0;
7948 player[k].targetrotation=-rotation+180;
7949 if(player[k].leftkeydown)player[k].targetrotation-=45;
7950 if(player[k].rightkeydown)player[k].targetrotation+=45;
7951 player[k].rotation=player[k].targetrotation;
7952 player[k].jumppower-=2;
7955 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())){
7956 player[k].hasvictim=0;
7958 for(i=0;i<numplayers;i++){
7960 if(!player[k].hasvictim)
7961 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
7962 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){
7963 player[k].victim=&player[i];
7964 player[k].hasvictim=1;
7965 if(player[k].aitype==playercontrolled){
7966 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;
7967 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;
7968 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)&&animation[player[i].targetanimation].height!=lowheight&&!player[k].forwardkeydown&&!player[k].leftkeydown&&!player[k].rightkeydown&&!player[k].crouchkeydown&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
7969 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;
7970 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;
7971 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;
7972 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;
7973 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;
7974 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;
7975 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;
7978 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
7979 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
7980 else randattack=abs(Random()%5);
7981 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
7982 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
7983 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
7984 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
7985 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
7987 if(player[k].weaponactive!=-1){
7988 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;
7989 else if(findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)/*&&animation[player[i].targetanimation].height!=lowheight*/&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife&&player[k].weaponmissdelay<=0)player[k].targetanimation=knifeslashstartanim;
7990 //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;
7991 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;
7992 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;
7993 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;
7994 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;
7995 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;
7999 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8001 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)){
8002 if(player[k].weaponactive==-1){
8003 player[i].targetanimation=sneakattackedanim;
8004 player[i].currentanimation=sneakattackedanim;
8005 player[k].currentanimation=sneakattackanim;
8006 player[k].targetanimation=sneakattackanim;
8007 player[k].oldcoords=player[k].coords;
8008 player[k].coords=player[i].coords;
8010 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8011 player[i].targetanimation=knifesneakattackedanim;
8012 player[i].currentanimation=knifesneakattackedanim;
8013 player[k].currentanimation=knifesneakattackanim;
8014 player[k].targetanimation=knifesneakattackanim;
8015 player[i].oldcoords=player[i].coords;
8016 player[i].coords=player[k].coords;
8018 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8019 player[i].targetanimation=swordsneakattackedanim;
8020 player[i].currentanimation=swordsneakattackedanim;
8021 player[k].currentanimation=swordsneakattackanim;
8022 player[k].targetanimation=swordsneakattackanim;
8023 player[i].oldcoords=player[i].coords;
8024 player[i].coords=player[k].coords;
8026 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8027 player[k].victim=&player[i];
8028 player[k].hasvictim=1;
8029 player[i].targettilt2=0;
8030 player[i].targetframe=1;
8031 player[i].currentframe=0;
8033 player[i].velocity=0;
8034 player[k].targettilt2=player[i].targettilt2;
8035 player[k].currentframe=player[i].currentframe;
8036 player[k].targetframe=player[i].targetframe;
8037 player[k].target=player[i].target;
8038 player[k].velocity=0;
8039 player[k].targetrotation=player[i].rotation;
8040 player[k].rotation=player[i].rotation;
8041 player[i].targetrotation=player[i].rotation;
8044 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8046 player[k].targetframe=0;
8048 //player[k].velocity=0;
8050 rotatetarget=player[i].coords-player[k].coords;
8051 Normalise(&rotatetarget);
8052 player[k].targetrotation=-asin(0-rotatetarget.x);
8053 player[k].targetrotation*=360/6.28;
8054 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8056 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8058 player[k].lastattack3=player[k].lastattack2;
8059 player[k].lastattack2=player[k].lastattack;
8060 player[k].lastattack=player[k].targetanimation;
8061 //player[k].targettilt2=0;
8065 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8066 rotatetarget=player[i].coords-player[k].coords;
8067 Normalise(&rotatetarget);
8068 player[k].targetrotation=-asin(0-rotatetarget.x);
8069 player[k].targetrotation*=360/6.28;
8070 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8071 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8073 player[k].victim=&player[i];
8074 player[k].hasvictim=1;
8075 player[i].targetanimation=knifefollowedanim;
8076 player[i].currentanimation=knifefollowedanim;
8077 player[i].targettilt2=0;
8078 player[i].targettilt2=player[k].targettilt2;
8079 player[i].targetframe=1;
8080 player[i].currentframe=0;
8082 player[i].velocity=0;
8083 player[k].currentanimation=knifefollowanim;
8084 player[k].targetanimation=knifefollowanim;
8085 player[k].targettilt2=player[i].targettilt2;
8086 player[k].currentframe=player[i].currentframe;
8087 player[k].targetframe=player[i].targetframe;
8088 player[k].target=player[i].target;
8089 player[k].velocity=0;
8090 player[k].oldcoords=player[k].coords;
8091 player[i].coords=player[k].coords;
8092 player[i].targetrotation=player[k].targetrotation;
8093 player[i].rotation=player[k].targetrotation;
8094 player[k].rotation=player[k].targetrotation;
8095 player[i].rotation=player[k].targetrotation;
8100 if(player[k].weaponactive!=-1){
8101 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8104 for(i=0;i<numplayers;i++){
8106 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8107 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8108 if(player[i].skeleton.free)
8109 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)))){
8110 player[k].victim=&player[i];
8111 player[k].hasvictim=1;
8112 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8113 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;
8114 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;
8115 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;
8117 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){
8118 player[k].targetanimation=killanim;
8119 for(j=0;j<terrain.numdecals;j++){
8120 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8121 terrain.DeleteDecal(j);
8124 for(l=0;l<objects.numobjects;l++){
8125 if(objects.model[l].type==decalstype)
8126 for(j=0;j<objects.model[l].numdecals;j++){
8127 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8128 objects.model[l].DeleteDecal(j);
8133 if(!player[i].dead||musictype!=2)
8134 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)){
8135 player[k].targetanimation=dropkickanim;
8136 for(j=0;j<terrain.numdecals;j++){
8137 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8138 terrain.DeleteDecal(j);
8141 for(l=0;l<objects.numobjects;l++){
8142 if(objects.model[l].type==decalstype)
8143 for(j=0;j<objects.model[l].numdecals;j++){
8144 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8145 objects.model[l].DeleteDecal(j);
8151 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)){
8153 player[k].targetframe=0;
8155 //player[k].velocity=0;
8157 rotatetarget=player[i].coords-player[k].coords;
8158 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8159 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;
8161 Normalise(&rotatetarget);
8162 player[k].targetrotation=-asin(0-rotatetarget.x);
8163 player[k].targetrotation*=360/6.28;
8164 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8166 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8167 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8170 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8171 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8173 player[k].lastattack3=player[k].lastattack2;
8174 player[k].lastattack2=player[k].lastattack;
8175 player[k].lastattack=player[k].targetanimation;
8177 if(player[k].targetanimation==swordgroundstabanim){
8178 player[k].targetrotation+=30;
8180 //player[k].targettilt2=0;
8186 if(!player[k].hasvictim){
8187 for(i=0;i<numplayers;i++){
8188 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8189 player[k].victim=&player[i];
8190 player[k].hasvictim=1;
8192 if(player[k].hasvictim&&!player[i].skeleton.free)
8193 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8194 player[k].victim=&player[i];
8198 if(player[k].aitype==playercontrolled)
8199 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)){
8201 player[k].targetanimation=rabbitkickanim;
8202 player[k].targetframe=0;
8205 if(animation[player[k].targetanimation].attack&&k==0){
8208 if(player[k].weaponactive!=-1){
8209 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8212 if(player[k].weaponactive!=-1){
8213 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8216 if(player[k].weaponactive!=-1){
8217 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8219 if(armedstaff)numstaffattack++;
8220 else if(armedsword)numswordattack++;
8221 else if(armedknife)numknifeattack++;
8222 else numunarmedattack++;
8229 static float collisionradius;
8231 for(k=0;k<numplayers;k++){
8232 for(i=k;i<numplayers;i++){
8235 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))
8236 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))
8237 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8238 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8239 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)
8240 if(player[i].coords.y>player[k].coords.y-3)
8241 if(player[i].coords.y<player[k].coords.y+3)
8242 if(player[i].coords.x>player[k].coords.x-3)
8243 if(player[i].coords.x<player[k].coords.x+3)
8244 if(player[i].coords.z>player[k].coords.z-3)
8245 if(player[i].coords.z<player[k].coords.z+3){
8246 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)){
8247 if(player[i].onfire||player[k].onfire){
8248 if(!player[i].onfire)player[i].CatchFire();
8249 if(!player[k].onfire)player[k].CatchFire();
8253 tempcoords1=player[i].coords;
8254 tempcoords2=player[k].coords;
8255 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8256 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8257 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8258 if(player[0].hasvictim)
8259 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8260 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8262 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)){
8263 player[k].coords.y=player[i].coords.y;
8264 player[i].velocity=player[k].velocity;
8265 player[i].skeleton.free=0;
8266 player[i].rotation=0;
8267 player[i].RagDoll(0);
8268 player[i].DoDamage(20);
8269 if(k==0)camerashake+=.3;
8270 player[i].skeleton.longdead=0;
8271 player[k].lastcollide=1;
8274 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)){
8275 player[i].coords.y=player[k].coords.y;
8276 player[k].velocity=player[i].velocity;
8277 player[k].skeleton.free=0;
8278 player[k].rotation=0;
8279 player[k].RagDoll(0);
8280 player[k].DoDamage(20);
8281 if(i==0)camerashake+=.3;
8282 player[k].skeleton.longdead=0;
8283 player[i].lastcollide=1;
8286 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)){
8287 rotatetarget=player[k].velocity-player[i].velocity;
8288 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))
8289 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))){
8291 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)){
8292 static float gLoc[3];
8293 static float vel[3];
8294 gLoc[0]=player[i].coords.x;
8295 gLoc[1]=player[i].coords.y;
8296 gLoc[2]=player[i].coords.z;
8297 vel[0]=player[i].velocity.x;
8298 vel[1]=player[i].velocity.y;
8299 vel[2]=player[i].velocity.z;
8300 if(tutoriallevel!=1){
8301 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8302 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8303 OPENAL_SetVolume(channels[heavyimpactsound], 256);
8304 OPENAL_SetPaused(channels[heavyimpactsound], false);
8306 //player[i].velocity=player[k].velocity;
8307 //player[k].velocity=player[i].velocity;
8309 player[i].RagDoll(0);
8310 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8315 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8316 player[k].RagDoll(0);
8317 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8322 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8324 //if(player[i].skeleton.oldfree){
8325 for(j=0;j<player[i].skeleton.num_joints;j++){
8326 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8329 //if(player[k].skeleton.oldfree){
8330 for(j=0;j<player[k].skeleton.num_joints;j++){
8331 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8337 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)){
8339 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8340 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)){
8341 rotatetarget=player[k].coords-player[i].coords;
8342 Normalise(&rotatetarget);
8343 player[k].coords=(player[k].coords+player[i].coords)/2;
8344 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);
8345 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8346 if(player[k].howactive==typeactive||hostile)
8347 if(player[k].isIdle()){
8348 if(player[k].howactive<typesleeping){
8349 player[k].targetanimation=player[k].getStop();
8350 player[k].targetframe=0;
8353 else if(player[k].howactive==typesleeping)
8355 player[k].targetanimation=getupfromfrontanim;
8356 player[k].targetframe=0;
8359 if(!editorenabled)player[k].howactive=typeactive;
8361 if(player[i].howactive==typeactive||hostile)
8362 if(player[i].isIdle()){
8363 if(player[i].howactive<typesleeping){
8364 player[i].targetanimation=player[i].getStop();
8365 player[i].targetframe=0;
8370 player[i].targetanimation=getupfromfrontanim;
8371 player[i].targetframe=0;
8374 if(!editorenabled)player[i].howactive=typeactive;
8378 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){
8379 player[i].velocity=player[k].velocity;
8380 player[k].velocity=player[k].velocity*-.5;
8381 //player[i].velocity.y-=10;
8382 player[k].velocity.y=player[i].velocity.y;
8383 player[i].DoDamage(20);
8384 player[i].RagDoll(0);
8385 player[k].lastcollide=1;
8392 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){
8393 player[k].velocity=player[i].velocity;
8394 player[i].velocity=player[i].velocity*-.3;
8395 //player[k].velocity.y-=10;
8396 player[i].velocity.y=player[k].velocity.y;
8397 player[k].DoDamage(20);
8398 player[k].RagDoll(0);
8399 player[i].lastcollide=1;
8410 player[i].CheckKick();
8411 player[k].CheckKick();
8417 for(k=0;k<numplayers;k++){
8418 for(i=k;i<numplayers;i++){
8420 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))){
8421 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)){
8422 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)){
8423 player[i].victim=&player[k];
8424 player[i].targetanimation=jumpreversedanim;
8425 player[i].currentanimation=jumpreversedanim;
8426 player[k].currentanimation=jumpreversalanim;
8427 player[k].targetanimation=jumpreversalanim;
8428 player[i].targettilt2=0;
8429 player[i].currentframe=0;
8430 player[i].targetframe=1;
8431 player[k].currentframe=0;
8432 player[k].targetframe=1;
8433 if(player[i].coords.y<player[k].coords.y+1){
8434 player[i].targetanimation=rabbitkickreversedanim;
8435 player[i].currentanimation=rabbitkickreversedanim;
8436 player[k].currentanimation=rabbitkickreversalanim;
8437 player[k].targetanimation=rabbitkickreversalanim;
8438 player[k].currentframe=1;
8439 player[k].targetframe=2;
8440 player[i].currentframe=1;
8441 player[i].targetframe=2;
8443 player[k].targettilt2=0;
8445 player[i].velocity=0;
8446 player[k].velocity=0;
8447 player[k].oldcoords=player[k].coords;
8448 player[i].coords=player[k].coords;
8449 player[k].targetrotation=player[i].targetrotation;
8450 player[k].rotation=player[i].targetrotation;
8451 player[k].victim=&player[i];
8452 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8454 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)){
8455 player[k].victim=&player[i];
8456 player[k].targetanimation=jumpreversedanim;
8457 player[k].currentanimation=jumpreversedanim;
8458 player[i].currentanimation=jumpreversalanim;
8459 player[i].targetanimation=jumpreversalanim;
8460 player[k].targettilt2=0;
8461 player[i].targettilt2=0;
8462 player[k].currentframe=0;
8463 player[k].targetframe=1;
8464 player[i].currentframe=0;
8465 player[i].targetframe=1;
8466 if(player[k].coords.y<player[i].coords.y+1){
8467 player[k].targetanimation=rabbitkickreversedanim;
8468 player[k].currentanimation=rabbitkickreversedanim;
8469 player[i].currentanimation=rabbitkickreversalanim;
8470 player[i].targetanimation=rabbitkickreversalanim;
8471 player[k].currentframe=1;
8472 player[k].targetframe=2;
8473 player[i].currentframe=1;
8474 player[i].targetframe=2;
8477 player[k].velocity=0;
8478 player[i].velocity=0;
8479 player[i].oldcoords=player[i].coords;
8480 player[k].coords=player[i].coords;
8481 player[i].targetrotation=player[k].targetrotation;
8482 player[i].rotation=player[k].targetrotation;
8483 player[i].victim=&player[k];
8484 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8491 for(k=0;k<numplayers;k++)
8492 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8501 static float checkdelay;
8502 checkdelay-=multiplier;
8504 static bool checkedcoll[maxplayers][maxplayers];
8505 static bool above[maxplayers];
8507 for(i=0;i<maxplayers;i++){
8508 for(j=0;j<maxplayers;j++){
8509 checkedcoll[i][j]=0;
8513 if(numplayers>1&&checkdelay<=0){
8515 for(k=0;k<numplayers;k++){
8516 if(player[k].skeleton.free!=2)above[k]=-1;
8518 for(i=k;i<numplayers;i++){
8521 if(!checkedcoll[i][k]){
8522 checkedcoll[i][k]=1;
8523 checkedcoll[k][i]=1;
8524 if(player[i].skeleton.free&&player[k].skeleton.free)
8525 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8526 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8527 if(player[i].coords.y>player[k].coords.y-3)
8528 if(player[i].coords.y<player[k].coords.y+3)
8529 if(player[i].coords.x>player[k].coords.x-3)
8530 if(player[i].coords.x<player[k].coords.x+3)
8531 if(player[i].coords.z>player[k].coords.z-3)
8532 if(player[i].coords.z<player[k].coords.z+3)
8533 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)){
8535 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8547 above[moving]=stuck;
8548 for(l=0;l<player[moving].skeleton.num_joints;l++){
8549 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8550 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8552 player[moving].skeleton.joints[l].position.y+=.003;
8553 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8567 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8568 texturesizetogglekeydown=0;
8571 for(k=0;k<numplayers;k++){
8572 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8573 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8574 player[k].DoDamage(1000);
8579 static bool respawnkeydown;
8580 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8581 targetlevel=whichlevel;
8585 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8586 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8591 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8593 if(targetlevel>numchallengelevels-1)targetlevel=0;
8596 slomotogglekeydown=1;
8600 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8602 OPENAL_SetPaused(channels[whooshsound], true);
8604 for(k=0;k<numplayers;k++){
8607 player[k].permanentdamage=0;
8608 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8609 player[k].aitype=passivetype;
8611 player[0].aitype=playercontrolled;
8615 static bool movekey;
8616 static bool connected;
8617 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8618 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8619 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8620 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8621 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8622 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8624 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
8626 for(int i=0;i<numplayers;i++){
8627 if(!player[i].skeleton.free){
8628 oldtargetrotation=player[i].targetrotation;
8629 if(i==0&&indialogue==-1){
8630 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){
8631 if(!cameramode)player[0].targetrotation=-rotation+180;
8632 if(cameramode)player[0].targetrotation=0;
8638 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8639 if(cameramode){facing=flatfacing;}
8641 facing=DoRotation(facing,-rotation2,0,0);
8642 facing=DoRotation(facing,0,0-rotation,0);
8645 player[0].lookrotation=-rotation;
8647 player[i].targetheadrotation=rotation;
8648 player[i].targetheadrotation2=rotation2;
8650 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
8651 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){
8652 player[i].targetrotation=-player[i].lookrotation+180;
8658 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8660 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
8661 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
8663 player[i].targetheadrotation=player[i].lookrotation;
8664 player[i].targetheadrotation2=player[i].lookrotation2;
8667 rotatetarget=participantfacing[whichdialogue][indialogue][i];
8668 Normalise(&rotatetarget);
8669 player[i].targetheadrotation=-asin(0-rotatetarget.x);
8670 player[i].targetheadrotation*=360/6.28;
8671 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
8673 player[i].targetheadrotation*=-1;
8674 player[i].targetheadrotation+=180;
8675 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
8683 player[i].avoidsomething=0;
8685 for(j=0;j<objects.numobjects;j++){
8686 if(objects.onfire[j]){
8687 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
8689 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
8690 player[i].collided=0;
8691 player[i].avoidcollided=1;
8692 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8693 player[i].avoidwhere=objects.position[j];
8699 //Add avoidwhere to players
8701 for(j=0;j<numplayers;j++){
8702 if(player[j].onfire){
8703 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
8705 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
8706 player[i].collided=0;
8707 player[i].avoidcollided=1;
8708 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8709 player[i].avoidwhere=objects.position[j];
8715 if(player[i].collided>.8)player[i].avoidcollided=0;
8716 if(player[i].aitype!=playercontrolled&&indialogue==-1){
8717 player[i].jumpclimb=0;
8719 if(editorenabled)player[i].stunned=1;
8722 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
8723 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;
8725 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
8726 player[i].forwardkeydown=0;
8727 player[i].leftkeydown=0;
8728 player[i].backkeydown=0;
8729 player[i].rightkeydown=0;
8730 player[i].crouchkeydown=0;
8731 player[i].attackkeydown=0;
8732 player[i].jumpkeydown=0;
8733 player[i].throwkeydown=0;
8736 if(player[i].aitype==pathfindtype){
8737 if(player[i].finalpathfindpoint==-1){
8738 float closestdistance;
8744 for(j=0;j<numpathpoints;j++){
8745 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
8746 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
8748 player[i].finaltarget=pathpoint[j];
8751 player[i].finalpathfindpoint=closest;
8752 for(j=0;j<numpathpoints;j++){
8753 if(numpathpointconnect[j])
8754 for(k=0;k<numpathpointconnect[j];k++){
8755 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8756 if(tempdist*tempdist<closestdistance){
8757 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8758 closestdistance=tempdist*tempdist;
8760 player[i].finaltarget=colpoint;
8765 player[i].finalpathfindpoint=closest;
8768 if(player[i].targetpathfindpoint==-1){
8769 float closestdistance;
8775 if(player[i].lastpathfindpoint==-1){
8776 for(j=0;j<numpathpoints;j++){
8777 if(j!=player[i].lastpathfindpoint)
8778 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
8779 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
8783 player[i].targetpathfindpoint=closest;
8784 for(j=0;j<numpathpoints;j++){
8785 if(j!=player[i].lastpathfindpoint)
8786 if(numpathpointconnect[j])
8787 for(k=0;k<numpathpointconnect[j];k++){
8788 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8789 if(tempdist*tempdist<closestdistance){
8790 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8791 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
8792 closestdistance=tempdist*tempdist;
8799 player[i].targetpathfindpoint=closest;
8803 for(j=0;j<numpathpoints;j++){
8804 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
8807 if(numpathpointconnect[j])
8808 for(k=0;k<numpathpointconnect[j];k++){
8809 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
8812 if(numpathpointconnect[player[i].lastpathfindpoint])
8813 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
8814 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
8817 tempdist=findPathDist(j,player[i].finalpathfindpoint);
8818 if(closest==-1||tempdist<closestdistance){
8819 closestdistance=tempdist;
8825 player[i].targetpathfindpoint=closest;
8828 player[i].losupdatedelay-=multiplier;
8830 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
8831 Normalise(&rotatetarget);
8832 player[i].targetrotation=-asin(0-rotatetarget.x);
8833 player[i].targetrotation*=360/6.28;
8834 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8835 player[i].lookrotation=player[i].targetrotation;
8836 //player[i].aiupdatedelay=.05;
8838 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
8839 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8840 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8841 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8842 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
8843 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
8844 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
8845 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
8846 player[i].targetpathfindpoint=-1;
8848 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){
8849 player[i].aitype=passivetype;
8852 player[i].forwardkeydown=1;
8853 player[i].leftkeydown=0;
8854 player[i].backkeydown=0;
8855 player[i].rightkeydown=0;
8856 player[i].crouchkeydown=0;
8857 player[i].attackkeydown=0;
8858 player[i].throwkeydown=0;
8860 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
8862 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
8863 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
8865 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
8866 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))
8867 player[i].aitype=attacktypecutoff;
8868 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
8869 player[i].aitype=attacktypecutoff;
8871 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
8872 player[i].losupdatedelay=.2;
8873 for(j=0;j<numplayers;j++){
8874 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
8875 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
8876 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
8877 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
8878 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
8879 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)){
8880 player[i].aitype=searchtype;
8881 player[i].lastchecktime=12;
8882 player[i].lastseen=player[j].coords;
8883 player[i].lastseentime=12;
8889 if(player[i].aitype==attacktypecutoff&&musictype!=2){
8890 if(player[i].creature!=wolftype){
8891 player[i].stunned=.6;
8892 player[i].surprised=.6;
8897 if(player[i].aitype!=passivetype&&leveltime>.5){
8898 player[i].howactive=typeactive;
8901 if(player[i].aitype==passivetype){
8902 player[i].aiupdatedelay-=multiplier;
8903 player[i].losupdatedelay-=multiplier;
8904 player[i].lastseentime+=multiplier;
8905 player[i].pausetime-=multiplier;
8906 if(player[i].lastseentime>1)player[i].lastseentime=1;
8908 if(player[i].aiupdatedelay<0){
8909 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
8910 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
8911 Normalise(&rotatetarget);
8912 player[i].targetrotation=-asin(0-rotatetarget.x);
8913 player[i].targetrotation*=360/6.28;
8914 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
8915 player[i].lookrotation=player[i].targetrotation;
8916 player[i].aiupdatedelay=.05;
8918 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
8919 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
8920 player[i].waypoint++;
8921 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
8926 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
8927 else player[i].forwardkeydown=0;
8928 player[i].leftkeydown=0;
8929 player[i].backkeydown=0;
8930 player[i].rightkeydown=0;
8931 player[i].crouchkeydown=0;
8932 player[i].attackkeydown=0;
8933 player[i].throwkeydown=0;
8935 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
8936 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
8938 XYZ leftpos,rightpos;
8939 float leftdist,rightdist;
8940 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
8941 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
8942 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
8943 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
8944 if(leftdist<rightdist)player[i].targetrotation+=90;
8945 else player[i].targetrotation-=90;
8949 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
8950 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
8954 if(player[i].howactive<typesleeping)
8955 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
8956 for(j=0;j<numenvsounds;j++){
8957 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
8958 player[i].aitype=attacktypecutoff;
8962 if(player[i].howactive==typesleeping)
8963 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
8964 for(j=0;j<numenvsounds;j++){
8965 if(envsoundvol[j]>14)
8966 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
8967 player[i].aitype=attacktypecutoff;
8971 if(player[i].aitype!=passivetype){
8972 if(player[i].howactive==typesleeping){
8973 player[i].targetanimation=getupfromfrontanim;
8974 player[i].targetframe=0;
8978 player[i].howactive=typeactive;
8982 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
8983 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
8984 player[i].aitype=attacktypecutoff;
8985 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
8986 player[i].aitype=attacktypecutoff;
8988 if(player[i].creature==wolftype){
8990 float smelldistance;
8992 for(j=0;j<numplayers;j++){
8993 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
8994 if(j==0&&player[j].num_weapons>0){
8995 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
8996 if(player[j].num_weapons==2)
8997 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9002 windsmell=windvector;
9003 Normalise(&windsmell);
9004 windsmell=windsmell*2+player[j].coords;
9005 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9006 player[i].aitype=attacktypecutoff;
9011 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9012 player[i].losupdatedelay=.2;
9013 for(j=0;j<numplayers;j++){
9014 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9015 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9016 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9017 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9018 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)){
9019 player[i].lastseentime-=.2;
9020 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9021 else player[i].lastseentime-=.6;
9023 if(player[i].lastseentime<=0){
9024 player[i].aitype=searchtype;
9025 player[i].lastchecktime=12;
9026 player[i].lastseen=player[j].coords;
9027 player[i].lastseentime=12;
9033 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9034 if(player[i].creature!=wolftype){
9035 player[i].stunned=.6;
9036 player[i].surprised=.6;
9038 if(player[i].creature==wolftype){
9039 player[i].stunned=.47;
9040 player[i].surprised=.47;
9046 if(player[i].aitype==searchtype){
9047 player[i].aiupdatedelay-=multiplier;
9048 player[i].losupdatedelay-=multiplier;
9049 if(!player[i].pause)player[i].lastseentime-=multiplier;
9050 player[i].lastchecktime-=multiplier;
9052 if(player[i].isRun()&&!player[i].onground){
9053 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9054 test2=player[i].coords+player[i].facing;
9056 test=player[i].coords+player[i].facing;
9058 j=checkcollide(test2,test,player[i].laststanding);
9059 if(j==-1)j=checkcollide(test2,test);
9061 player[i].velocity=0;
9062 player[i].targetanimation=player[i].getStop();
9063 player[i].targetframe=0;
9065 player[i].targetrotation+=180;
9066 player[i].stunned=.5;
9067 //player[i].aitype=passivetype;
9068 player[i].aitype=pathfindtype;
9069 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9070 player[i].finalpathfindpoint=-1;
9071 player[i].targetpathfindpoint=-1;
9072 player[i].lastpathfindpoint=-1;
9073 player[i].lastpathfindpoint2=-1;
9074 player[i].lastpathfindpoint3=-1;
9075 player[i].lastpathfindpoint4=-1;
9077 else player[i].laststanding=j;
9080 if(player[i].aiupdatedelay<0){
9081 rotatetarget=player[i].lastseen-player[i].coords;
9082 Normalise(&rotatetarget);
9083 player[i].targetrotation=-asin(0-rotatetarget.x);
9084 player[i].targetrotation*=360/6.28;
9085 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9086 player[i].lookrotation=player[i].targetrotation;
9087 player[i].aiupdatedelay=.05;
9088 player[i].forwardkeydown=1;
9090 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9091 player[i].forwardkeydown=0;
9092 player[i].aiupdatedelay=1;
9093 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9094 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9095 player[i].lastchecktime=3;
9098 player[i].leftkeydown=0;
9099 player[i].backkeydown=0;
9100 player[i].rightkeydown=0;
9101 player[i].crouchkeydown=0;
9102 player[i].attackkeydown=0;
9103 player[i].throwkeydown=0;
9105 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9106 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9108 XYZ leftpos,rightpos;
9109 float leftdist,rightdist;
9110 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9111 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9112 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9113 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9114 if(leftdist<rightdist)player[i].targetrotation+=90;
9115 else player[i].targetrotation-=90;
9119 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9120 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9122 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9123 for(j=0;j<numenvsounds;j++){
9124 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9125 player[i].aitype=attacktypecutoff;
9129 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9130 player[i].losupdatedelay=.2;
9131 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9132 {player[i].aitype=attacktypecutoff;
9133 player[i].lastseentime=1;}
9134 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9135 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9136 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9137 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)){
9138 player[i].aitype=attacktypecutoff;
9139 player[i].lastseentime=1;
9142 if(player[i].lastseentime<0){
9143 //player[i].aitype=passivetype;
9145 player[i].aitype=pathfindtype;
9146 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9147 player[i].finalpathfindpoint=-1;
9148 player[i].targetpathfindpoint=-1;
9149 player[i].lastpathfindpoint=-1;
9150 player[i].lastpathfindpoint2=-1;
9151 player[i].lastpathfindpoint3=-1;
9152 player[i].lastpathfindpoint4=-1;
9156 if(player[i].aitype!=gethelptype){
9157 player[i].runninghowlong=0;
9160 if(player[i].aitype==gethelptype){
9161 player[i].runninghowlong+=multiplier;
9162 player[i].aiupdatedelay-=multiplier;
9164 if(player[i].aiupdatedelay<0||player[i].ally==0){
9165 player[i].aiupdatedelay=.2;
9173 if(!player[i].ally){
9174 for(j=0;j<numplayers;j++){
9175 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9176 distance=findDistancefast(&player[i].coords,&player[j].coords);
9177 if(closestdist==-1||distance<closestdist){
9178 closestdist=distance;
9184 if(closest!=-1)player[i].ally=closest;
9185 else player[i].ally=0;
9186 player[i].lastseen=player[0].coords;
9187 player[i].lastseentime=12;
9191 player[i].lastchecktime=12;
9192 //player[i].lastseentime-=.5;
9194 facing=player[i].coords;
9195 flatfacing=player[player[i].ally].coords;
9196 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9197 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9198 if(-1!=checkcollide(facing,flatfacing))
9199 player[i].lastseentime-=.1;
9201 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9202 player[i].aitype=searchtype;
9203 player[i].lastseentime=12;
9206 if(player[i].ally>0){
9207 rotatetarget=player[player[i].ally].coords-player[i].coords;
9208 Normalise(&rotatetarget);
9209 player[i].targetrotation=-asin(0-rotatetarget.x);
9210 player[i].targetrotation*=360/6.28;
9211 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9212 player[i].lookrotation=player[i].targetrotation;
9213 player[i].aiupdatedelay=.05;
9214 player[i].forwardkeydown=1;
9216 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9217 player[i].aitype=searchtype;
9218 player[i].lastseentime=12;
9219 player[player[i].ally].aitype=searchtype;
9220 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9221 player[player[i].ally].lastseen=player[i].lastseen;
9222 player[player[i].ally].lastseentime=player[i].lastseentime;
9223 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9227 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9228 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9230 XYZ leftpos,rightpos;
9231 float leftdist,rightdist;
9232 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9233 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9234 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9235 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9236 if(leftdist<rightdist)player[i].targetrotation+=90;
9237 else player[i].targetrotation-=90;
9242 player[i].leftkeydown=0;
9243 player[i].backkeydown=0;
9244 player[i].rightkeydown=0;
9245 player[i].crouchkeydown=0;
9246 player[i].attackkeydown=0;
9248 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9249 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9252 if(player[i].aitype==getweapontype){
9253 player[i].aiupdatedelay-=multiplier;
9254 player[i].lastchecktime-=multiplier;
9256 if(player[i].aiupdatedelay<0){
9257 player[i].aiupdatedelay=.2;
9265 if(player[i].ally<0){
9266 for(j=0;j<weapons.numweapons;j++){
9267 if(weapons.owner[j]==-1){
9268 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9269 if(closestdist==-1||distance<closestdist){
9270 closestdist=distance;
9276 if(closest!=-1)player[i].ally=closest;
9277 else player[i].ally=-1;
9280 player[i].lastseentime=12;
9282 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9283 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9284 player[i].aitype=attacktypecutoff;
9285 player[i].lastseentime=1;
9288 if(player[i].ally>=0){
9289 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9290 player[i].aitype=attacktypecutoff;
9291 player[i].lastseentime=1;
9293 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9294 Normalise(&rotatetarget);
9295 player[i].targetrotation=-asin(0-rotatetarget.x);
9296 player[i].targetrotation*=360/6.28;
9297 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9298 player[i].lookrotation=player[i].targetrotation;
9299 player[i].aiupdatedelay=.05;
9300 player[i].forwardkeydown=1;
9303 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9304 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9306 XYZ leftpos,rightpos;
9307 float leftdist,rightdist;
9308 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9309 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9310 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9311 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9312 if(leftdist<rightdist)player[i].targetrotation+=90;
9313 else player[i].targetrotation-=90;
9316 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9317 if(abs(Random()%6)){
9318 player[i].crouchkeydown=1;
9319 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9320 if(player[i].isRun()){
9321 player[i].targetframe=0;
9323 player[i].targetanimation=sneakanim;
9326 else player[i].forwardkeydown=0;
9328 else player[i].crouchkeydown=0;
9330 else player[i].crouchkeydown=0;*/
9333 player[i].leftkeydown=0;
9334 player[i].backkeydown=0;
9335 player[i].rightkeydown=0;
9336 player[i].attackkeydown=0;
9337 player[i].throwkeydown=1;
9338 player[i].crouchkeydown=0;
9339 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9340 player[i].drawkeydown=0;
9342 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9343 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9346 if(player[i].aitype==attacktypecutoff){
9347 player[i].aiupdatedelay-=multiplier;
9348 if(player[i].damage<player[i].damagetolerance*2/3)
9349 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)){
9350 player[i].attackkeydown=0;
9351 if(player[i].isIdle())player[i].crouchkeydown=1;
9352 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9353 if(weapons.type[player[0].weaponids[0]]==knife){
9354 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9355 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9356 else player[i].targetanimation=rollanim;
9358 player[i].targetframe=0;
9359 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9360 player[i].wentforweapon=0;
9362 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9363 player[i].targetanimation=flipanim;
9365 player[i].targetframe=0;
9369 player[i].forwardkeydown=0;
9370 player[i].aiupdatedelay=.02;
9372 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9373 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9374 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9376 if(player[i].wentforweapon<3)
9377 for(j=0;j<weapons.numweapons;j++){
9378 if(player[i].creature!=wolftype)
9379 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){
9380 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9381 player[i].wentforweapon++;
9382 player[i].lastchecktime=6;
9383 player[i].aitype=getweapontype;
9388 if(player[i].damage<player[i].damagetolerance/2)
9389 if(animation[player[i].targetanimation].height!=highheight)
9390 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)))){
9391 player[i].crouchkeydown=1;
9393 if(player[i].isRun()&&!player[i].onground){
9394 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9395 test2=player[i].coords+player[i].facing;
9397 test=player[i].coords+player[i].facing;
9399 j=checkcollide(test2,test,player[i].laststanding);
9400 if(j==-1)j=checkcollide(test2,test);
9402 player[i].velocity=0;
9403 player[i].targetanimation=player[i].getStop();
9404 player[i].targetframe=0;
9406 player[i].targetrotation+=180;
9407 player[i].stunned=.5;
9408 //player[i].aitype=passivetype;
9409 player[i].aitype=pathfindtype;
9410 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9411 player[i].finalpathfindpoint=-1;
9412 player[i].targetpathfindpoint=-1;
9413 player[i].lastpathfindpoint=-1;
9414 player[i].lastpathfindpoint2=-1;
9415 player[i].lastpathfindpoint3=-1;
9416 player[i].lastpathfindpoint4=-1;
9418 else player[i].laststanding=j;
9421 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9422 player[i].aitype=pathfindtype;
9423 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9424 player[i].finalpathfindpoint=-1;
9425 player[i].targetpathfindpoint=-1;
9426 player[i].lastpathfindpoint=-1;
9427 player[i].lastpathfindpoint2=-1;
9428 player[i].lastpathfindpoint3=-1;
9429 player[i].lastpathfindpoint4=-1;
9431 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){
9432 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9433 else player[i].drawkeydown=0;
9434 player[i].rabbitkickenabled=Random()%2;
9435 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9436 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9437 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;
9438 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9439 Normalise(&rotatetarget);
9440 player[i].targetrotation=-asin(0-rotatetarget.x);
9441 player[i].targetrotation*=360/6.28;
9442 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9443 player[i].lookrotation=player[i].targetrotation;
9444 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9446 oldkey=player[i].forwardkeydown;
9447 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9448 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;
9449 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9450 else player[i].forwardkeydown=0;
9452 player[i].forwardkeydown=0;
9453 if(Random()%10==0)player[i].forwardkeydown=1;
9454 if(Random()%100==0){
9455 player[i].aitype=pathfindtype;
9456 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9457 player[i].finalpathfindpoint=-1;
9458 player[i].targetpathfindpoint=-1;
9459 player[i].lastpathfindpoint=-1;
9460 player[i].lastpathfindpoint2=-1;
9461 player[i].lastpathfindpoint3=-1;
9462 player[i].lastpathfindpoint4=-1;
9465 player[i].leftkeydown=0;
9466 player[i].backkeydown=0;
9467 player[i].rightkeydown=0;
9468 player[i].crouchkeydown=0;
9469 player[i].throwkeydown=0;
9471 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9472 /*for(j=0;j<numplayers;j++){
9473 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9474 player[i].crouchkeydown=1;
9477 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9478 else player[i].attackkeydown=0;
9479 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9480 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9481 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9482 player[i].attackkeydown=0;
9483 if(player[i].isIdle())player[i].crouchkeydown=1;
9484 player[i].forwardkeydown=0;
9485 player[i].aiupdatedelay=.02;
9488 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9490 for(j=0;j<numplayers;j++){
9491 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)){
9492 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))))){
9493 if(target>=0)target=-1;
9498 if(target>=0)player[target].Reverse();
9501 if(player[i].collided<1)player[i].jumpkeydown=0;
9502 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;
9503 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9504 player[0].jumpkeydown=0;
9505 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9506 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9507 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9509 if(tutoriallevel==1){
9510 if(!canattack)player[i].attackkeydown=0;
9514 facing=player[i].coords;
9515 flatfacing=player[0].coords;
9516 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9517 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9518 if(player[i].occluded>=2)
9519 if(-1!=checkcollide(facing,flatfacing)){
9520 if(!player[i].pause)player[i].lastseentime-=.2;
9521 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9522 player[i].aitype=searchtype;
9523 player[i].lastchecktime=12;
9524 player[i].lastseen=player[0].coords;
9525 player[i].lastseentime=12;
9528 else player[i].lastseentime=1;
9531 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9532 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9533 test=player[0].coords;
9535 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9538 // NOTE: Ask about logic of this call : NOTE
9539 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9540 player[i].stunned>0 ||
9541 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9543 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9544 player[i].targetrotation=player[i].rotation;
9545 player[i].forwardkeydown=0;
9546 player[i].leftkeydown=0;
9547 player[i].backkeydown=0;
9548 player[i].rightkeydown=0;
9549 player[i].jumpkeydown=0;
9550 player[i].attackkeydown=0;
9551 player[i].crouchkeydown=0;
9552 player[i].throwkeydown=0;
9559 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9562 if(player[i].aitype==attacktypecutoff){
9563 rotatetarget=player[0].coords-player[i].coords;
9564 Normalise(&rotatetarget);
9565 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9566 player[i].targetheadrotation*=360/6.28;
9567 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9569 player[i].targetheadrotation*=-1;
9570 player[i].targetheadrotation+=180;
9571 //player[i].targetheadrotation2=0;
9572 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9574 else if(player[i].howactive>=typesleeping){
9575 player[i].targetheadrotation=player[i].targetrotation;
9576 player[i].targetheadrotation2=0;
9579 if(player[i].interestdelay<=0){
9580 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9581 player[i].headtarget=player[i].coords;
9582 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9583 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9584 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9585 player[i].headtarget+=player[i].facing*1.5;
9587 rotatetarget=player[i].headtarget-player[i].coords;
9588 Normalise(&rotatetarget);
9589 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9590 player[i].targetheadrotation*=360/6.28;
9591 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9593 player[i].targetheadrotation*=-1;
9594 player[i].targetheadrotation+=180;
9595 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9597 //if(whichlevel==2)player[i].jumpkeydown=0;
9599 if(animation[player[i].targetanimation].attack==reversed){
9600 //player[i].targetrotation=player[i].rotation;
9601 player[i].forwardkeydown=0;
9602 player[i].leftkeydown=0;
9603 player[i].backkeydown=0;
9604 player[i].rightkeydown=0;
9605 player[i].jumpkeydown=0;
9606 player[i].attackkeydown=0;
9607 //player[i].crouchkeydown=0;
9608 player[i].throwkeydown=0;
9612 player[i].forwardkeydown=0;
9613 player[i].leftkeydown=0;
9614 player[i].backkeydown=0;
9615 player[i].rightkeydown=0;
9616 player[i].jumpkeydown=0;
9617 player[i].crouchkeydown=0;
9618 player[i].drawkeydown=0;
9619 player[i].throwkeydown=0;
9622 if(player[i].collided<-.3)player[i].collided=-.3;
9623 if(player[i].collided>1)player[i].collided=1;
9624 player[i].collided-=multiplier*4;
9625 player[i].whichdirectiondelay-=multiplier;
9626 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
9627 player[i].avoidcollided=-.3;
9628 player[i].whichdirection=abs(Random()%2);
9629 player[i].whichdirectiondelay=.4;
9631 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
9632 player[i].avoidcollided-=multiplier/4;
9633 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
9634 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
9635 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;
9637 if(!player[i].throwkeydown){
9638 player[i].throwtogglekeydown=0;
9640 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
9641 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)){
9642 for(j=0;j<weapons.numweapons;j++){
9643 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)
9644 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
9645 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
9646 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
9647 player[i].throwtogglekeydown=1;
9648 player[i].targetanimation=crouchremoveknifeanim;
9650 player[i].targetframe=0;
9651 rotatetarget=weapons.position[j]-player[i].coords;
9652 Normalise(&rotatetarget);
9653 player[i].targetrotation=-asin(0-rotatetarget.x);
9654 player[i].targetrotation*=360/6.28;
9655 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9656 player[i].hasvictim=0;
9658 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9659 player[i].throwtogglekeydown=1;
9660 player[i].hasvictim=0;
9662 //for(i=0;i<weapons.numweapons;i++){
9663 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))
9664 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
9665 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
9668 gLoc[0]=player[i].coords.x;
9669 gLoc[1]=player[i].coords.y;
9670 gLoc[2]=player[i].coords.z;
9671 vel[0]=player[i].velocity.x;
9672 vel[1]=player[i].velocity.y;
9673 vel[2]=player[i].velocity.z;
9674 if(weapons.type[j]!=staff){
9675 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9676 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9677 OPENAL_SetVolume(channels[knifedrawsound], 128);
9678 OPENAL_SetPaused(channels[knifedrawsound], false);
9681 player[i].weaponactive=0;
9682 weapons.owner[j]=player[i].id;
9683 if(player[i].num_weapons>0){
9684 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9686 player[i].num_weapons++;
9687 player[i].weaponids[0]=j;
9693 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){
9694 if(!player[i].isFlip()){
9695 player[i].throwtogglekeydown=1;
9696 player[i].targetanimation=removeknifeanim;
9698 player[i].targetframe=0;
9699 rotatetarget=weapons.position[j]-player[i].coords;
9700 Normalise(&rotatetarget);
9701 player[i].targetrotation=-asin(0-rotatetarget.x);
9702 player[i].targetrotation*=360/6.28;
9703 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9705 if(player[i].isFlip()){
9706 player[i].throwtogglekeydown=1;
9707 player[i].hasvictim=0;
9709 for(k=0;k<weapons.numweapons;k++){
9710 if(player[i].weaponactive==-1)
9711 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))
9712 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
9715 gLoc[0]=player[i].coords.x;
9716 gLoc[1]=player[i].coords.y;
9717 gLoc[2]=player[i].coords.z;
9718 vel[0]=player[i].velocity.x;
9719 vel[1]=player[i].velocity.y;
9720 vel[2]=player[i].velocity.z;
9721 if(weapons.type[k]!=staff){
9722 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9723 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9724 OPENAL_SetVolume(channels[knifedrawsound], 128);
9725 OPENAL_SetPaused(channels[knifedrawsound], false);
9728 player[i].weaponactive=0;
9729 weapons.owner[k]=player[i].id;
9730 if(player[i].num_weapons>0){
9731 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9733 player[i].num_weapons++;
9734 player[i].weaponids[0]=k;
9741 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9743 for(j=0;j<numplayers;j++){
9744 if(player[i].weaponactive==-1)
9746 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)){
9747 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
9748 player[i].throwtogglekeydown=1;
9749 player[i].victim=&player[j];
9750 player[i].hasvictim=1;
9751 player[i].targetanimation=crouchremoveknifeanim;
9753 player[i].targetframe=0;
9754 rotatetarget=player[j].coords-player[i].coords;
9755 Normalise(&rotatetarget);
9756 player[i].targetrotation=-asin(0-rotatetarget.x);
9757 player[i].targetrotation*=360/6.28;
9758 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9760 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9761 player[i].throwtogglekeydown=1;
9762 player[i].victim=&player[j];
9763 player[i].hasvictim=1;
9764 int k = player[j].weaponids[0];
9765 if(player[i].hasvictim){
9768 gLoc[0]=player[i].coords.x;
9769 gLoc[1]=player[i].coords.y;
9770 gLoc[2]=player[i].coords.z;
9771 vel[0]=player[i].velocity.x;
9772 vel[1]=player[i].velocity.y;
9773 vel[2]=player[i].velocity.z;
9776 if(player[i].victim->weaponstuck!=-1){
9777 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9782 if(weapons.type[k]!=staff){
9783 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9784 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9785 OPENAL_SetVolume(channels[knifedrawsound], 128);
9786 OPENAL_SetPaused(channels[knifedrawsound], false);
9790 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
9791 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
9792 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
9793 OPENAL_SetPaused(channels[fleshstabremovesound], false);
9796 player[i].weaponactive=0;
9797 if(weapons.owner[k]!=-1){
9798 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
9799 else player[i].victim->num_weapons=1;
9801 player[i].victim->skeleton.longdead=0;
9802 player[i].victim->skeleton.free=1;
9803 player[i].victim->skeleton.broken=0;
9805 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
9806 player[i].victim->skeleton.joints[l].velchange=0;
9807 player[i].victim->skeleton.joints[l].locked=0;
9813 Normalise(&relative);
9814 XYZ footvel,footpoint;
9816 footpoint=weapons.position[k];
9817 if(player[i].victim->weaponstuck!=-1){
9818 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9819 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
9820 weapons.bloody[k]=2;
9821 weapons.blooddrip[k]=5;
9822 player[i].victim->weaponstuck=-1;
9823 player[i].victim->bloodloss+=2000;
9824 player[i].victim->DoDamage(2000);
9827 if(player[i].victim->num_weapons>0){
9828 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
9829 if(player[i].victim->weaponids[0]==k)
9830 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
9833 player[i].victim->weaponactive=-1;
9835 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
9836 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
9837 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
9838 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
9841 if(player[i].num_weapons>0){
9842 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9844 player[i].num_weapons++;
9845 player[i].weaponids[0]=k;
9852 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9853 if(weapons.type[player[i].weaponids[0]]==knife){
9854 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
9856 for(j=0;j<numplayers;j++){
9858 if(tutoriallevel!=1||tutorialstage==49)
9860 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)){
9861 if(!player[i].isFlip()){
9862 player[i].throwtogglekeydown=1;
9863 player[i].victim=&player[j];
9864 player[i].targetanimation=knifethrowanim;
9866 player[i].targetframe=0;
9867 rotatetarget=player[j].coords-player[i].coords;
9868 Normalise(&rotatetarget);
9869 player[i].targetrotation=-asin(0-rotatetarget.x);
9870 player[i].targetrotation*=360/6.28;
9871 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9873 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
9875 if(player[i].isFlip()){
9876 if(player[i].weaponactive!=-1){
9877 player[i].throwtogglekeydown=1;
9878 player[i].victim=&player[j];
9880 weapons.owner[player[i].weaponids[0]]=-1;
9881 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);
9884 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
9886 weapons.velocity[player[i].weaponids[0]]=aim*50;
9887 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
9888 weapons.missed[player[i].weaponids[0]]=0;
9889 weapons.freetime[player[i].weaponids[0]]=0;
9890 weapons.firstfree[player[i].weaponids[0]]=1;
9891 weapons.physics[player[i].weaponids[0]]=0;
9892 player[i].num_weapons--;
9893 if(player[i].num_weapons){
9894 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
9896 player[i].weaponactive=-1;
9903 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
9904 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
9906 player[i].throwtogglekeydown=1;
9907 weapons.owner[player[i].weaponids[0]]=-1;
9908 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
9909 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
9910 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
9911 weapons.missed[player[i].weaponids[0]]=1;
9912 weapons.freetime[player[i].weaponids[0]]=0;
9913 weapons.firstfree[player[i].weaponids[0]]=1;
9914 weapons.physics[player[i].weaponids[0]]=1;
9915 player[i].num_weapons--;
9916 if(player[i].num_weapons){
9917 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
9918 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
9921 player[i].weaponactive=-1;
9922 for(j=0;j<numplayers;j++){
9923 player[j].wentforweapon=0;
9930 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
9931 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)){
9932 //Setenvironment(1-environment);
9935 if(player[i].weaponactive!=-1){
9936 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
9938 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
9939 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
9940 player[i].targetanimation=drawrightanim;
9941 player[i].targetframe=0;
9943 player[i].drawtogglekeydown=1;
9945 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){
9946 player[i].targetanimation=drawleftanim;
9947 player[i].targetframe=0;
9949 player[i].drawtogglekeydown=1;
9951 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
9952 player[i].targetanimation=crouchdrawrightanim;
9953 player[i].targetframe=0;
9955 player[i].drawtogglekeydown=1;
9959 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){
9960 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
9961 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
9962 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
9963 player[i].targetframe=0;
9965 player[i].hasvictim=0;
9966 //player[i].attacktogglekeydown=1;
9970 if(!player[i].drawkeydown){
9971 player[i].drawtogglekeydown=0;
9978 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
9980 else absflatfacing=flatfacing;
9983 player[i].forwardkeydown=0;
9984 player[i].leftkeydown=0;
9985 player[i].backkeydown=0;
9986 player[i].rightkeydown=0;
9987 player[i].jumpkeydown=0;
9988 player[i].crouchkeydown=0;
9989 player[i].drawkeydown=0;
9990 player[i].throwkeydown=0;
9994 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
9995 if(!player[i].forwardkeydown){
9996 player[i].forwardstogglekeydown=0;
9998 if(player[i].crouchkeydown){
10002 player[i].superruntoggle=1;
10004 for(j=0;j<numplayers;j++){
10005 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10006 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10007 player[i].superruntoggle=0;
10014 for(j=0;j<numplayers;j++){
10015 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10016 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))){
10017 if(target>=0)target=-1;
10022 if(target>=0)player[target].Reverse();
10023 player[i].lowreversaldelay=.5;
10025 if(player[i].isIdle()){
10026 player[i].targetanimation=player[i].getCrouch();
10027 player[i].target=0;
10028 player[i].targetframe=0;
10029 player[i].transspeed=10;
10031 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10032 player[i].targetanimation=rollanim;
10033 player[i].target=0;
10034 player[i].targetframe=0;
10035 player[i].transspeed=20;
10038 if(!player[i].crouchkeydown){
10040 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10042 if(player[i].isCrouch()){
10044 for(j=0;j<numplayers;j++){
10045 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10046 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10047 if(target>=0)target=-1;
10052 if(target>=0)player[target].Reverse();
10053 player[i].highreversaldelay=.5;
10055 if(player[i].isCrouch()){
10056 if(!player[i].wasCrouch()){
10057 player[i].currentanimation=player[i].getCrouch();
10058 player[i].currentframe=0;
10060 player[i].target=0;
10061 player[i].targetanimation=player[i].getIdle();
10062 player[i].targetframe=0;
10063 player[i].transspeed=10;
10066 if(player[i].targetanimation==sneakanim){
10067 player[i].targetanimation=player[i].getIdle();
10068 player[i].target=0;
10069 player[i].targetframe=0;
10070 player[i].transspeed=10;
10073 if(player[i].forwardkeydown){
10074 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)){
10075 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10076 else player[i].targetanimation=player[i].getRun();
10077 player[i].target=0;
10078 player[i].targetframe=0;
10080 if(player[i].isCrouch()){
10081 player[i].targetanimation=sneakanim;
10082 if(player[i].wasCrouch())player[i].target=0;
10083 player[i].targetframe=0;
10085 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10086 player[i].targetanimation=climbanim;
10087 player[i].target=0;
10088 player[i].targetframe=1;
10089 player[i].jumpclimb=1;
10091 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10092 player[i].velocity+=absflatfacing*5*multiplier;
10094 player[i].forwardstogglekeydown=1;
10097 if (player[i].rightkeydown){
10098 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)){
10099 player[i].targetanimation=player[i].getRun();
10100 player[i].target=0;
10101 player[i].targetframe=0;
10103 if(player[i].isCrouch()){
10104 player[i].targetanimation=sneakanim;
10105 if(player[i].wasCrouch()) player[i].target=0;
10106 player[i].targetframe=0;
10108 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10109 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10111 player[i].targetrotation-=90;
10112 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10113 if(player[i].backkeydown)player[i].targetrotation-=45;
10116 if ( player[i].leftkeydown){
10117 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)){
10118 player[i].targetanimation=player[i].getRun();
10119 player[i].target=0;
10120 player[i].targetframe=0;
10122 if(player[i].isCrouch()){
10123 player[i].targetanimation=sneakanim;
10124 if(player[i].wasCrouch())player[i].target=0;
10125 player[i].targetframe=0;
10127 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10128 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10130 player[i].targetrotation+=90;
10131 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10132 if(player[i].backkeydown)player[i].targetrotation+=45;
10135 if(player[i].backkeydown){
10136 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)){
10137 player[i].targetanimation=player[i].getRun();
10138 player[i].target=0;
10139 player[i].targetframe=0;
10141 if(player[i].isCrouch()){
10142 player[i].targetanimation=sneakanim;
10143 if(player[i].wasCrouch())player[i].target=0;
10144 player[i].targetframe=0;
10146 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10147 player[i].velocity-=absflatfacing*5*multiplier;
10149 if(player[i].targetanimation==hanganim){
10150 player[i].currentanimation=jumpdownanim;
10151 player[i].targetanimation=jumpdownanim;
10152 player[i].target=0;
10153 player[i].currentframe=0;
10154 player[i].targetframe=1;
10155 player[i].velocity=0;
10156 player[i].velocity.y+=gravity;
10157 player[i].coords.y-=1.4;
10158 player[i].grabdelay=1;
10160 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10161 player[i].targetrotation+=180;
10164 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10165 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)){
10166 player[i].jumpstart=0;
10167 player[i].targetanimation=jumpupanim;
10168 player[i].target=0;
10169 player[i].targetframe=0;
10170 player[i].rotation=player[i].targetrotation;
10171 player[i].transspeed=20;
10172 player[i].FootLand(0,1);
10173 player[i].FootLand(1,1);
10177 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10179 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10180 if(!movekey)player[i].velocity=0;
10185 for(j=0;j<numplayers;j++){
10186 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10187 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10188 if(target>=0)target=-1;
10193 if(target>=0)player[i].velocity.y=1;
10194 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10195 player[i].velocity.y=7;
10196 player[i].crouchtogglekeydown=1;
10198 else player[i].velocity.y=5;
10200 if(mousejump&&i==0&&debugmode){
10201 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10202 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10205 player[i].coords.y+=.2;
10206 player[i].jumppower-=1;
10208 static float gLoc[3];
10209 static float vel[3];
10210 gLoc[0]=player[i].coords.x;
10211 gLoc[1]=player[i].coords.y;
10212 gLoc[2]=player[i].coords.z;
10213 vel[0]=player[i].velocity.x;
10214 vel[1]=player[i].velocity.y;
10215 vel[2]=player[i].velocity.z;
10218 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10219 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10220 OPENAL_SetVolume(channels[whooshsound], 128);
10221 OPENAL_SetPaused(channels[whooshsound], false);
10224 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10225 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10226 OPENAL_SetVolume(channels[jumpsound], 128);
10227 OPENAL_SetPaused(channels[jumpsound], false);
10229 if((player[i].isIdle())&&player[i].jumppower>1){
10230 player[i].targetanimation=player[i].getLanding();
10231 player[i].landhard=0;
10232 player[i].target=0;
10233 player[i].targetframe=2;
10234 player[i].jumpstart=1;
10235 player[i].tempdeltav=deltav;
10237 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10238 if(player[i].jumppower>multiplier*6){
10239 player[i].velocity.y+=multiplier*6;
10240 player[i].jumppower-=multiplier*6;
10242 if(player[i].jumppower<=multiplier*6){
10243 player[i].velocity.y+=player[i].jumppower;
10244 player[i].jumppower=0;
10247 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10251 if(player[i].isRun()||player[i].targetanimation==walkanim){
10252 player[i].targetanimation=player[i].getStop();
10253 player[i].target=0;
10254 player[i].targetframe=0;
10256 if(player[i].targetanimation==sneakanim){
10257 player[i].targetanimation=player[i].getCrouch();
10258 if(player[i].currentanimation==sneakanim)player[i].target=0;
10259 player[i].targetframe=0;
10262 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10263 player[i].targetanimation=player[i].getStop();
10264 player[i].target=0;
10265 player[i].targetframe=0;
10267 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10268 player[i].targetanimation=player[i].getStop();
10269 player[i].target=0;
10270 player[i].targetframe=0;
10274 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10278 for(k=0;k<numplayers;k++){
10279 if(abs(player[k].rotation-player[k].targetrotation)>180){
10280 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10281 else player[k].rotation+=360;
10284 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10285 player[k].targetanimation=player[k].getStop();
10286 player[k].targetframe=0;
10287 player[k].target=0;
10290 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10291 player[k].targettilt=0;
10293 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10294 player[k].targettilt=0;
10295 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10296 player[k].jumppower+=multiplier*7;
10297 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10298 //*(1-(player[k].damage/player[k].damagetolerance))
10299 if(player[k].jumppower>5)player[k].jumppower=5;
10302 if(player[k].isRun()){
10303 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10306 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10307 else if(player[k].tilt>player[k].targettilt){
10308 player[k].tilt-=multiplier*150;
10310 else if(player[k].tilt<player[k].targettilt){
10311 player[k].tilt+=multiplier*150;
10314 player[k].grabdelay-=multiplier;
10317 for(k=0;k<numplayers;k++){
10318 player[k].DoAnimations();
10319 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10320 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10325 player[0].righthandmorphstart=0;
10326 player[0].righthandmorphend=1;
10327 player[0].lefthandmorphstart=0;
10328 player[0].lefthandmorphend=1;
10329 player[0].headmorphstart=0;
10330 player[0].headmorphend=2;*/
10333 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10334 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10335 player[0].righthandmorphend=1;
10336 player[0].targetrighthandmorphness=1;
10338 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10339 player[0].lefthandmorphend=0;
10340 player[0].targetlefthandmorphness=1;
10342 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10343 player[0].headmorphend=2;
10344 player[0].targetheadmorphness=1;
10346 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10347 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10348 player[0].righthandmorphend=0;
10349 player[0].targetrighthandmorphness=1;
10351 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10352 player[0].lefthandmorphend=1;
10353 player[0].targetlefthandmorphness=1;
10355 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10356 player[0].headmorphend=0;
10357 player[0].targetheadmorphness=1;
10360 if(numenvsounds!=0)
10361 for(j=numenvsounds-1;j>=0;j--){
10362 envsoundlife[j]-=multiplier;
10363 if(envsoundlife[j]<0){
10365 envsoundlife[j]=envsoundlife[numenvsounds];
10366 envsound[j]=envsound[numenvsounds];
10369 if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
10370 if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
10372 if(tutoriallevel==1){
10389 if(tutorialstage>=51)
10390 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10391 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10392 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
10394 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10395 OPENAL_SetPaused(channels[stream_music3], false);
10396 OPENAL_SetVolume(channels[stream_music3], 256);
10401 float gLoc[3]={0,0,0};
10402 float vel[3]={0,0,0};
10403 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10404 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10405 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10406 OPENAL_SetVolume(channels[fireendsound], 256);
10407 OPENAL_SetPaused(channels[fireendsound], false);
10408 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10416 if(tutorialstage<51)
10417 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10420 gLoc[0]=player[0].coords.x;
10421 gLoc[1]=player[0].coords.y;
10422 gLoc[2]=player[0].coords.z;
10426 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10427 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10428 OPENAL_SetVolume(channels[fireendsound], 256);
10429 OPENAL_SetPaused(channels[fireendsound], false);
10431 player[0].coords=(oldtemp+oldtemp2)/2;
10439 if(tutorialstage>=14&&tutorialstage<50)
10440 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10443 gLoc[0]=player[1].coords.x;
10444 gLoc[1]=player[1].coords.y;
10445 gLoc[2]=player[1].coords.z;
10449 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10450 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10451 OPENAL_SetVolume(channels[fireendsound], 256);
10452 OPENAL_SetPaused(channels[fireendsound], false);
10454 for(int i=0;i<player[1].skeleton.num_joints;i++){
10456 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10457 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10458 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;
10459 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10460 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10464 player[1].coords=(oldtemp+oldtemp2)/2;
10465 for(int i=0;i<player[1].skeleton.num_joints;i++){
10466 player[1].skeleton.joints[i].velocity=0;
10468 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10469 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10470 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;
10471 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10472 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10480 static float gLoc[3];
10484 static float vel[3];
10485 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10486 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10487 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10489 //Set orientation with forward and up vectors
10490 static XYZ upvector;
10494 upvector=DoRotation(upvector,-rotation2+90,0,0);
10495 upvector=DoRotation(upvector,0,0-rotation,0);
10500 facing=DoRotation(facing,-rotation2,0,0);
10501 facing=DoRotation(facing,0,0-rotation,0);
10504 static float ori[6];
10505 ori[0] = -facing.x;
10507 ori[2] = -facing.z;
10508 ori[3] = -upvector.x;
10509 ori[4] = upvector.y;
10510 ori[5] = -upvector.z;
10512 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10519 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10521 freezetogglekeydown=1;
10525 void Game::TickOnce(){
10528 if(directing||indialogue==-1){
10529 rotation+=deltah*.7;
10530 if(!invertmouse)rotation2+=deltav*.7;
10531 if(invertmouse)rotation2-=deltav*.7;
10532 if(rotation2>90)rotation2=90;
10533 if(rotation2<-70)rotation2=-70;
10535 if(mainmenu)rotation+=multiplier*5;
10540 void Game::TickOnceAfter(){
10541 static XYZ colviewer;
10542 static XYZ coltarget;
10545 static float brotate;
10548 static float changedelay;
10549 static bool alldead;
10550 static float unseendelay;
10551 static float cameraspeed;
10555 if(environment==snowyenvironment)music1=stream_music1snow;
10556 if(environment==grassyenvironment)music1=stream_music1grass;
10557 if(environment==desertenvironment)music1=stream_music1desert;
10562 for(i=0;i<numplayers;i++){
10563 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)){
10564 musictype=stream_music2;
10568 if(player[0].dead)musictype=stream_music3;
10571 if(musictype==stream_music2){
10575 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10576 unseendelay-=multiplier;
10578 musictype=stream_music2;
10584 musictype=stream_music3;
10585 musicvolume[2]=512;
10592 if(musictype!=oldmusictype&&musictype==stream_music2){
10593 static float gLoc[3];
10594 static float vel[3];
10595 gLoc[0]=cameraloc.x;
10596 gLoc[1]=cameraloc.y;
10597 gLoc[2]=cameraloc.z;
10601 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
10602 OPENAL_SetVolume(channels[alarmsound], 512);
10603 OPENAL_SetPaused(channels[alarmsound], false);
10607 musicselected=musictype;
10609 if(musicselected==music1)musicvolume[0]+=multiplier*450;
10610 else musicvolume[0]-=multiplier*450;
10611 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
10612 else musicvolume[1]-=multiplier*450;
10613 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
10614 else musicvolume[2]-=multiplier*450;
10616 if(musicselected==music1)musicvolume[0]+=multiplier*100;
10617 else musicvolume[0]-=multiplier*450;
10618 if(musicselected==music2)musicvolume[1]+=multiplier*150;
10619 else if(player[0].dead)musicvolume[1]-=multiplier*450;
10620 else musicvolume[1]-=multiplier*100;
10621 if(musicselected==music3)musicvolume[2]+=multiplier*450;
10622 else musicvolume[2]-=multiplier*450;*/
10625 if(musicvolume[i]<0)musicvolume[i]=0;
10626 if(musicvolume[i]>512)musicvolume[i]=512;
10629 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
10632 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
10633 PlayStreamEx( music1, strm[music1], NULL, true);
10634 OPENAL_SetPaused(channels[music1], false);
10636 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
10637 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
10638 OPENAL_SetPaused(channels[stream_music2], false);
10640 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
10641 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10642 OPENAL_SetPaused(channels[stream_music3], false);
10647 OPENAL_SetPaused(channels[music1], true);
10648 OPENAL_SetPaused(channels[stream_music2], true);
10649 OPENAL_SetPaused(channels[stream_music3], true);
10652 oldmusicvolume[i]=0;
10658 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
10659 OPENAL_SetPaused(channels[music1], true);
10661 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
10662 OPENAL_SetPaused(channels[stream_music2], true);
10664 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
10665 OPENAL_SetPaused(channels[stream_music3], true);
10668 if(musicvolume[0]!=oldmusicvolume[0]){
10669 OPENAL_SetVolume(channels[music1], musicvolume[0]);
10671 if(musicvolume[1]!=oldmusicvolume[1]){
10672 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
10674 if(musicvolume[2]!=oldmusicvolume[2]){
10675 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
10679 oldmusicvolume[i]=musicvolume[i];
10685 for(i=0;i<numhotspots;i++){
10686 if(hotspottype[i]>10&&hotspottype[i]<20){
10687 if(player[hotspottype[i]-10].dead==0){
10690 else if(killhotspot==2)
10694 if(killhotspot==2)killhotspot=0;
10699 for(i=0;i<numhotspots;i++){
10700 if(hotspottype[i]==-1){
10701 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
10708 for(i=1;i<numplayers;i++){
10709 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
10711 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
10713 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
10714 if(player[0].dead&&changedelay<=0){
10716 targetlevel=whichlevel;
10720 for(i=1;i<numplayers;i++){
10721 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
10725 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
10727 targetlevel=whichlevel+1;
10728 if(targetlevel>numchallengelevels-1)targetlevel=0;
10730 if(winhotspot||windialogue){
10732 targetlevel=whichlevel+1;
10733 if(targetlevel>numchallengelevels-1)targetlevel=0;
10739 targetlevel=whichlevel+1;
10740 if(targetlevel>numchallengelevels-1)targetlevel=0;
10743 if(changedelay>0&&!player[0].dead&&!won){
10744 //high scores, awards, win
10747 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10748 accountcampaignchoicesmade[accountactive]++;
10749 accountcampaignscore[accountactive]+=bonustotal;
10751 accountcampaigntime[accountactive]+=leveltime;
10752 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
10754 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10760 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
10761 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
10763 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10779 if(!editorenabled&&gameon&&!mainmenu){
10780 if(changedelay!=-999)changedelay-=multiplier/7;
10781 if(player[0].dead)targetlevel=whichlevel;
10782 if(loading==2&&!campaign){
10790 float gLoc[3]={0,0,0};
10791 float vel[3]={0,0,0};
10792 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10793 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10794 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10795 OPENAL_SetVolume(channels[firestartsound], 256);
10796 OPENAL_SetPaused(channels[firestartsound], false);
10797 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10799 if(!player[0].dead&&targetlevel!=whichlevel){
10800 startbonustotal=bonustotal;
10802 if(!player[0].dead)Loadlevel(targetlevel);
10803 if(player[0].dead)Loadlevel(whichlevel);
10805 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10806 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10807 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10808 OPENAL_SetVolume(channels[fireendsound], 256);
10809 OPENAL_SetPaused(channels[fireendsound], false);
10810 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10814 if(loading==2&&targetlevel==whichlevel){
10822 float gLoc[3]={0,0,0};
10823 float vel[3]={0,0,0};
10824 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10825 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10826 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10827 OPENAL_SetVolume(channels[firestartsound], 256);
10828 OPENAL_SetPaused(channels[firestartsound], false);
10829 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10831 for(i=0;i<255;i++){
10845 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
10846 Loadlevel(mapname);
10848 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10849 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10850 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10851 OPENAL_SetVolume(channels[fireendsound], 256);
10852 OPENAL_SetPaused(channels[fireendsound], false);
10853 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10857 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
10858 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
10860 if(whichlevel!=-2&&!loading&&!player[0].dead){
10864 if(player[0].dead)loading=1;
10870 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
10871 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
10875 else if(mainmenu==0&&winfreeze){
10876 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
10878 else stealthloading=0;
10880 if(!stealthloading){
10881 float gLoc[3]={0,0,0};
10882 float vel[3]={0,0,0};
10883 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10884 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10885 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10886 OPENAL_SetVolume(channels[firestartsound], 256);
10887 OPENAL_SetPaused(channels[firestartsound], false);
10888 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10899 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
10900 //campaignnumlevels=0;
10901 //accountcampaignchoicesmade[accountactive]=0;
10902 ipstream.ignore(256,':');
10903 ipstream >> campaignnumlevels;
10904 for(i=0;i<campaignnumlevels;i++){
10905 ipstream.ignore(256,':');
10906 ipstream.ignore(256,':');
10907 ipstream.ignore(256,' ');
10908 ipstream >> campaignmapname[i];
10909 ipstream.ignore(256,':');
10910 ipstream >> campaigndescription[i];
10911 for(j=0;j<256;j++){
10912 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
10914 ipstream.ignore(256,':');
10915 ipstream >> campaignchoosenext[i];
10916 ipstream.ignore(256,':');
10917 ipstream >> campaignnumnext[i];
10918 if(campaignnumnext[i])
10919 for(j=0;j<campaignnumnext[i];j++){
10920 ipstream.ignore(256,':');
10921 ipstream >> campaignnextlevel[i][j];
10922 campaignnextlevel[i][j]-=1;
10924 ipstream.ignore(256,':');
10925 ipstream >> campaignlocationx[i];
10926 ipstream.ignore(256,':');
10927 ipstream >> campaignlocationy[i];
10931 for(i=0;i<campaignnumlevels;i++){
10933 levelhighlight[i]=0;
10937 for(i=0;i<campaignnumlevels;i++){
10939 levelhighlight[i]=0;
10944 if(accountcampaignchoicesmade[accountactive])
10945 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
10946 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
10947 levelvisible[levelorder[i+1]]=1;
10949 int whichlevelstart;
10950 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
10951 if(whichlevelstart<0){
10952 campaignchoicenum=1;
10953 campaignchoicewhich[0]=0;
10957 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
10958 if(campaignchoicenum)
10959 for(i=0;i<campaignchoicenum;i++){
10960 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
10961 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
10962 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
10969 //if(firstload)TickOnceAfter();
10970 if(!firstload)LoadStuff();
10972 for(i=0;i<255;i++){
10987 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10988 //accountcampaignchoicesmade[accountactive]++;
10991 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
10995 Loadlevel(mapname);
10999 OPENAL_SetPaused(channels[stream_music3], true);
11004 if(loading==3)loading=0;
11008 oldmusictype=musictype;
11014 facing=DoRotation(facing,-rotation2,0,0);
11015 facing=DoRotation(facing,0,0-rotation,0);
11016 viewerfacing=facing;
11020 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;
11021 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;
11023 if(player[0].skeleton.free){
11024 for(i=0;i<player[0].skeleton.num_joints;i++){
11025 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11026 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11030 if(player[0].skeleton.free!=2&&!autocam){
11032 if(findLengthfast(&player[0].velocity)>400){
11033 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11035 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11036 coltarget=target-cameraloc;
11037 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11039 Normalise(&coltarget);
11040 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11041 else cameraloc=cameraloc+coltarget*multiplier*8;
11043 if(editorenabled)cameraloc=target;
11044 cameradist+=multiplier*5;
11045 if(cameradist>2.3)cameradist=2.3;
11046 viewer=cameraloc-facing*cameradist;
11048 coltarget=cameraloc;
11049 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11050 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11051 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11052 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11054 coltarget=cameraloc;
11055 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11057 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11058 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11059 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11061 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11065 cameradist=findDistance(&viewer,&target);
11066 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11067 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11069 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11070 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11073 if(player[0].skeleton.free!=2&&autocam){
11075 if(findLengthfast(&player[0].velocity)>400){
11076 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11078 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11079 cameradist+=multiplier*5;
11080 if(cameradist>3.3)cameradist=3.3;
11081 coltarget=target-cameraloc;
11082 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11083 else if(findLengthfast(&coltarget)>1)
11085 Normalise(&coltarget);
11086 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11087 else cameraloc=cameraloc+coltarget*multiplier*8;
11089 if(editorenabled)cameraloc=target;
11092 coltarget=cameraloc;
11093 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11094 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11095 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11096 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11098 coltarget=cameraloc;
11099 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11101 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11102 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11103 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11105 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11109 cameradist=findDistance(&viewer,&target);
11110 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11111 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11113 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11114 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11117 if(camerashake>.8)camerashake=.8;
11118 //if(woozy>10)woozy=10;
11119 //woozy+=multiplier;
11121 if(player[0].dead)camerashake=0;
11122 if(player[0].dead)woozy=0;
11123 camerashake-=multiplier*2;
11124 blackout-=multiplier*2;
11125 //if(player[0].isCrouch())woozy-=multiplier*8;
11126 if(camerashake<0)camerashake=0;
11127 if(blackout<0)blackout=0;
11128 //if(woozy<0)woozy=0;
11130 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11131 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11132 viewer.z+=(float)(Random()%100)*.0005*camerashake;