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 int newnetmessages;
80 extern char netmessages[256];
81 extern bool keyboardfrozen;
82 extern int netdatanew;
83 extern bool loadingstuff;
84 extern char mapname[256];
85 extern XYZ windvector;
86 extern bool buttons[3];
87 extern bool debugmode;
90 extern int oldmainmenu;
91 extern bool visibleloading;
92 extern int loadscreencolor;
93 extern float flashamount,flashr,flashg,flashb;
94 extern int flashdelay;
95 extern XYZ envsound[30];
96 extern float envsoundvol[30];
97 extern int numenvsounds;
98 extern float envsoundlife[30];
99 extern float usermousesensitivity;
100 extern bool ismotionblur;
102 extern bool trilinear;
103 extern bool damageeffects;
104 extern bool showpoints;
105 extern bool texttoggle;
106 extern bool alwaysblur;
107 extern float gamespeed;
110 extern bool immediate;
111 extern bool velocityblur;
114 extern float bonusvalue;
115 extern float bonustotal;
116 extern float bonustime;
117 extern float startbonustotal;
118 extern float tintr,tintg,tintb;
119 extern float bonusnum[100];
120 extern bool skyboxtexture;
121 extern float skyboxr;
122 extern float skyboxg;
123 extern float skyboxb;
124 extern float skyboxlightr;
125 extern float skyboxlightg;
126 extern float skyboxlightb;
127 extern float fadestart;
128 extern float slomospeed;
129 extern float slomofreq;
130 extern int tutoriallevel;
131 extern float smoketex;
132 extern float tutorialstagetime;
133 extern int tutorialstage;
134 extern float tutorialmaxtime;
135 extern float tutorialsuccess;
136 extern bool againbonus;
137 extern bool reversaltrain;
138 extern bool canattack;
139 extern bool cananger;
140 extern float damagedealt;
141 extern float damagetaken;
143 extern int editoractive;
144 extern int editorpathtype;
145 extern bool oldbuttons[3];
147 extern float hostiletime;
149 extern bool gamestarted;
151 extern int numhotspots;
152 extern int winhotspot;
153 extern int windialogue;
154 extern int killhotspot;
155 extern XYZ hotspot[40];
156 extern int hotspottype[40];
157 extern float hotspotsize[40];
158 extern char hotspottext[40][256];
159 extern int currenthotspot;
161 extern int kBitsPerPixel;
164 extern int numaccounts;
165 extern int accountactive;
166 extern int accountdifficulty[10];
167 extern int accountprogress[10];
168 extern float accountpoints[10];
169 extern float accounthighscore[10][50];
170 extern float accountfasttime[10][50];
171 extern bool accountunlocked[10][60];
172 extern char accountname[10][256];
174 extern bool stillloading;
175 extern bool winfreeze;
178 extern int numflipfail;
180 extern int numstaffattack;
181 extern int numswordattack;
182 extern int numknifeattack;
183 extern int numunarmedattack;
184 extern int numescaped;
185 extern int numflipped;
186 extern int numwallflipped;
187 extern int numthrowkill;
188 extern int numafterkill;
189 extern int numreversals;
190 extern int numattacks;
191 extern int maxalarmed;
192 extern int numresponded;
194 extern int numdialogues;
195 extern int numdialogueboxes[max_dialogues];
196 extern int dialoguetype[max_dialogues];
197 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
198 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
199 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
200 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
201 extern char dialoguename[max_dialogues][max_dialoguelength][64];
202 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
203 extern XYZ participantlocation[max_dialogues][10];
204 extern int participantfocus[max_dialogues][max_dialoguelength];
205 extern int participantaction[max_dialogues][max_dialoguelength];
206 extern float participantrotation[max_dialogues][10];
207 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
208 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
209 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
210 extern int indialogue;
211 extern int whichdialogue;
212 extern int directing;
213 extern float dialoguetime;
214 extern int dialoguegonethrough[20];
216 extern bool campaign;
218 extern float oldgamespeed;
220 extern float accountcampaignhighscore[10];
221 extern float accountcampaignfasttime[10];
222 extern float accountcampaignscore[10];
223 extern float accountcampaigntime[10];
225 extern int accountcampaignchoicesmade[10];
226 extern int accountcampaignchoices[10][5000];
227 /********************> Tick() <*****/
228 extern OPENAL_STREAM * strm[20];
229 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
230 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
232 extern void ScreenShot(const char * fname);
233 void Screenshot (void)
236 time_t t = time(NULL);
237 struct tm *tme = localtime(&t);
238 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);
241 mkdir("Screenshots");
243 mkdir("Screenshots", S_IRWXU);
246 ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
249 GraphicsExportComponent QT_exporter;
250 OSErr MAC_error_code;
251 CGrafPtr MAC_currentPort;
252 GDHandle MAC_currentDevice;
253 unsigned char* MAC_pixels;
254 Rect MAC_picture_rectangle;
255 GWorldPtr MAC_offscreen_graphics_port;
257 static int numscreenshots=0;
260 static char buf[256];
261 if(numscreenshots==0){
292 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
293 while(!FSpGetFInfo (&MAC_file, fndrInfo)){
294 FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
295 if(!FSpGetFInfo (&MAC_file, fndrInfo)){
316 GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow();
317 //assert(MAC_gWorld != NULL);
319 // Allocate memory for loading image
320 MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
321 if (MAC_pixels == NULL) {
322 //UTIL_Error("Could not create Texture data.");
327 ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
329 // Make a picture Rectangle
330 MAC_picture_rectangle.left = 0;
331 MAC_picture_rectangle.right = screenwidth;
332 MAC_picture_rectangle.top = 0;
333 MAC_picture_rectangle.bottom = screenheight;
335 // Create new offscreen GWorld
336 MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
337 if (MAC_error_code) {
338 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
340 //UTIL_Error("Could not create offscreen GWorld. ");
345 // Copy OpenGL Context to new GWorld
346 glReadBuffer(GL_FRONT);
347 glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
350 for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
351 unsigned char temp = MAC_pixels[byte+0];
352 MAC_pixels[byte+0] = MAC_pixels[byte+3];
353 MAC_pixels[byte+3] = MAC_pixels[byte+2];
354 MAC_pixels[byte+2] = MAC_pixels[byte+1];
355 MAC_pixels[byte+1] = temp;
358 // Flip the image :( This could probably be optimized
363 for (int horz = 0; horz < screenwidth; ++horz)
364 for (vert = 0; vert < screenheight / 2; ++vert) {
365 src_index = (screenwidth * vert + horz) * 4;
366 dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
368 temp=MAC_pixels[src_index+0];
369 MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
370 MAC_pixels[dst_index+0]=temp;
372 temp=MAC_pixels[src_index+1];
373 MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
374 MAC_pixels[dst_index+1]=temp;
376 temp=MAC_pixels[src_index+2];
377 MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
378 MAC_pixels[dst_index+2]=temp;
380 temp=MAC_pixels[src_index+3];
381 MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
382 MAC_pixels[dst_index+3]=temp;
388 MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
389 if (MAC_error_code) {
390 //UTIL_Warning("Unable to export screenshot.");
391 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
392 ::DisposeGWorld(MAC_offscreen_graphics_port);
397 MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
398 if (MAC_error_code) {
399 ::CloseComponent(QT_exporter);
400 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
401 ::DisposeGWorld(MAC_offscreen_graphics_port);
403 //UTIL_Warning("Unable to export screenshot.");
407 MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
408 if (MAC_error_code) {
409 ::CloseComponent(QT_exporter);
410 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
411 ::DisposeGWorld(MAC_offscreen_graphics_port);
413 //UTIL_Warning("Unable to export screenshot.");
417 MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
418 if (MAC_error_code) {
419 ::CloseComponent(QT_exporter);
420 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
421 ::DisposeGWorld(MAC_offscreen_graphics_port);
423 //UTIL_Warning("Unable to export screenshot.");
427 ::CloseComponent(QT_exporter);
428 ::SetGWorld(MAC_currentPort, MAC_currentDevice);
429 ::DisposeGWorld(MAC_offscreen_graphics_port);
436 void Game::SetUpLighting(){
437 if(environment==snowyenvironment){
443 light.ambient[2]=.44;
445 if(environment==desertenvironment){
450 light.ambient[1]=.35;
454 if(environment==grassyenvironment){
460 light.ambient[2]=.44;
471 average=(skyboxlightr+skyboxlightg+skyboxlightb)/3;
472 light.color[0]*=(skyboxlightr+average)/2;
473 light.color[1]*=(skyboxlightg+average)/2;
474 light.color[2]*=(skyboxlightb+average)/2;
475 light.ambient[0]=light.ambient[0]*(skyboxlightr+average)/2*1;
476 light.ambient[1]=light.ambient[1]*(skyboxlightg+average)/2*1;
477 light.ambient[2]=light.ambient[2]*(skyboxlightb+average)/2*1;
481 light.ambient[2]=0; */
484 int Game::findPathDist(int start,int end){
485 int i,j,k,smallestcount,count,connected;
486 int last,last2,last3,last4;
496 while(last!=end&&count<30){
498 for(j=0;j<numpathpoints;j++){
499 if(j!=last&&j!=last2&&j!=last3&&j!=last4)
502 if(numpathpointconnect[j])
503 for(k=0;k<numpathpointconnect[j];k++){
504 if(pathpointconnect[j][k]==last)connected=1;
507 if(numpathpointconnect[last])
508 for(k=0;k<numpathpointconnect[last];k++){
509 if(pathpointconnect[last][k]==j)connected=1;
512 if(closest==-1||Random()%2==0){
523 if(count<smallestcount)smallestcount=count;
525 return smallestcount;
528 int Game::checkcollide(XYZ startpoint,XYZ endpoint){
529 static XYZ colpoint,colviewer,coltarget;
530 static float minx,minz,maxx,maxz,miny,maxy;
539 if(minx>endpoint.x)minx=endpoint.x;
541 if(miny>endpoint.y)miny=endpoint.y;
543 if(minz>endpoint.z)minz=endpoint.z;
546 if(maxx<endpoint.x)maxx=endpoint.x;
548 if(maxy<endpoint.y)maxy=endpoint.y;
550 if(maxz<endpoint.z)maxz=endpoint.z;
559 for(i=0;i<objects.numobjects;i++){
560 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){
561 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
562 colviewer=startpoint;
564 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)return i;
569 //if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
574 int Game::checkcollide(XYZ startpoint,XYZ endpoint,int what){
575 static XYZ colpoint,colviewer,coltarget;
576 static float minx,minz,maxx,maxz,miny,maxy;
585 if(minx>endpoint.x)minx=endpoint.x;
587 if(miny>endpoint.y)miny=endpoint.y;
589 if(minz>endpoint.z)minz=endpoint.z;
592 if(maxx<endpoint.x)maxx=endpoint.x;
594 if(maxy<endpoint.y)maxy=endpoint.y;
596 if(maxz<endpoint.z)maxz=endpoint.z;
606 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){
607 if(objects.type[what]!=treeleavestype&&objects.type[what]!=bushtype&&objects.type[what]!=firetype){
608 colviewer=startpoint;
610 if(objects.model[what].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[what],&objects.rotation[what])!=-1)return i;
615 if(what==1000)if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)return 1000;
620 void Game::Setenvironment(int which)
624 LOG(" Setting environment...");
629 OPENAL_SetPaused(channels[music1snow], true);
630 OPENAL_SetPaused(channels[music1grass], true);
631 OPENAL_SetPaused(channels[music1desert], true);
632 OPENAL_SetPaused(channels[wind], true);
633 OPENAL_SetPaused(channels[desertambient], true);
635 OPENAL_SetPaused(channels[stream_music1snow], true);
636 OPENAL_SetPaused(channels[stream_music1grass], true);
637 OPENAL_SetPaused(channels[stream_music1desert], true);
638 OPENAL_SetPaused(channels[stream_wind], true);
639 OPENAL_SetPaused(channels[stream_desertambient], true);
642 if(environment==snowyenvironment){
646 //PlaySoundEx( wind, samp[wind], NULL, true);
647 PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
648 OPENAL_SetPaused(channels[stream_wind], false);
649 OPENAL_SetVolume(channels[stream_wind], 256);
652 LoadTexture(":Data:Textures:snowtree.png",&objects.treetextureptr,0,1);
653 LoadTexture(":Data:Textures:bushsnow.png",&objects.bushtextureptr,0,1);
654 LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
655 LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
657 OPENAL_Sample_Free(samp[footstepsound]);
658 OPENAL_Sample_Free(samp[footstepsound2]);
659 OPENAL_Sample_Free(samp[footstepsound3]);
660 OPENAL_Sample_Free(samp[footstepsound4]);
661 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow1.ogg", OPENAL_HW3D, 0, 0);
662 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow2.ogg", OPENAL_HW3D, 0, 0);
663 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone1.ogg", OPENAL_HW3D, 0, 0);
664 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone2.ogg", OPENAL_HW3D, 0, 0);
665 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
666 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
667 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
668 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
670 LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
672 LoadTexture(":Data:Textures:rock.jpg",&terraintexture2,1,0);
674 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
679 temptexdetail=texdetail;
680 if(texdetail>1)texdetail=4;
681 skybox.load( ":Data:Textures:Skybox(snow):Front.jpg",
682 ":Data:Textures:Skybox(snow):Left.jpg",
683 ":Data:Textures:Skybox(snow):Back.jpg",
684 ":Data:Textures:Skybox(snow):Right.jpg",
685 ":Data:Textures:Skybox(snow):Up.jpg",
686 ":Data:Textures:Skybox(snow):Down.jpg",
687 ":Data:Textures:Skybox(snow):Cloud.jpg",
688 ":Data:Textures:Skybox(snow):Reflect.jpg");
693 texdetail=temptexdetail;
695 if(environment==desertenvironment){
698 LoadTexture(":Data:Textures:deserttree.png",&objects.treetextureptr,0,1);
699 LoadTexture(":Data:Textures:bushdesert.png",&objects.bushtextureptr,0,1);
700 LoadTexture(":Data:Textures:boulderdesert.jpg",&objects.rocktextureptr,1,0);
701 LoadTexture(":Data:Textures:desertbox.jpg",&objects.boxtextureptr,1,0);
705 //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
706 PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
707 OPENAL_SetPaused(channels[stream_desertambient], false);
708 OPENAL_SetVolume(channels[stream_desertambient], 256);
711 OPENAL_Sample_Free(samp[footstepsound]);
712 OPENAL_Sample_Free(samp[footstepsound2]);
713 OPENAL_Sample_Free(samp[footstepsound3]);
714 OPENAL_Sample_Free(samp[footstepsound4]);
715 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow1.ogg", OPENAL_HW3D, 0, 0);
716 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow2.ogg", OPENAL_HW3D, 0, 0);
717 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow1.ogg", OPENAL_HW3D, 0, 0);
718 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepsnow2.ogg", OPENAL_HW3D, 0, 0);
719 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
720 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
721 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
722 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
724 LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
726 LoadTexture(":Data:Textures:sandslope.jpg",&terraintexture2,1,0);
728 //LoadTexture(":Data:Textures:detailgrain.png",&terraintexture3,1);
732 temptexdetail=texdetail;
733 if(texdetail>1)texdetail=4;
734 skybox.load( ":Data:Textures:Skybox(sand):Front.jpg",
735 ":Data:Textures:Skybox(sand):Left.jpg",
736 ":Data:Textures:Skybox(sand):Back.jpg",
737 ":Data:Textures:Skybox(sand):Right.jpg",
738 ":Data:Textures:Skybox(sand):Up.jpg",
739 ":Data:Textures:Skybox(sand):Down.jpg",
740 ":Data:Textures:Skybox(sand):Cloud.jpg",
741 ":Data:Textures:Skybox(sand):Reflect.jpg");
746 texdetail=temptexdetail;
748 if(environment==grassyenvironment){
751 LoadTexture(":Data:Textures:tree.png",&objects.treetextureptr,0,1);
752 LoadTexture(":Data:Textures:bush.png",&objects.bushtextureptr,0,1);
753 LoadTexture(":Data:Textures:boulder.jpg",&objects.rocktextureptr,1,0);
754 LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
757 PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
758 OPENAL_SetPaused(channels[stream_wind], false);
759 OPENAL_SetVolume(channels[stream_wind], 100);
762 OPENAL_Sample_Free(samp[footstepsound]);
763 OPENAL_Sample_Free(samp[footstepsound2]);
764 OPENAL_Sample_Free(samp[footstepsound3]);
765 OPENAL_Sample_Free(samp[footstepsound4]);
766 samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepgrass1.ogg", OPENAL_HW3D, 0, 0);
767 samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepgrass2.ogg", OPENAL_HW3D, 0, 0);
768 samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone1.ogg", OPENAL_HW3D, 0, 0);
769 samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ":Data:Sounds:footstepstone2.ogg", OPENAL_HW3D, 0, 0);
770 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
771 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
772 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
773 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
775 LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
777 LoadTexture(":Data:Textures:mossrock.jpg",&terraintexture2,1,0);
779 //LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
783 temptexdetail=texdetail;
784 if(texdetail>1)texdetail=4;
785 skybox.load( ":Data:Textures:Skybox(grass):Front.jpg",
786 ":Data:Textures:Skybox(grass):Left.jpg",
787 ":Data:Textures:Skybox(grass):Back.jpg",
788 ":Data:Textures:Skybox(grass):Right.jpg",
789 ":Data:Textures:Skybox(grass):Up.jpg",
790 ":Data:Textures:Skybox(grass):Down.jpg",
791 ":Data:Textures:Skybox(grass):Cloud.jpg",
792 ":Data:Textures:Skybox(grass):Reflect.jpg");
796 texdetail=temptexdetail;
798 temptexdetail=texdetail;
800 terrain.load(":Data:Textures:heightmap.png");
802 texdetail=temptexdetail;
806 void Game::Loadlevel(int which){
809 if(which==0)Loadlevel((char *)":Data:Maps:map1");
810 else if(which==1)Loadlevel((char *)":Data:Maps:map2");
811 else if(which==2)Loadlevel((char *)":Data:Maps:map3");
812 else if(which==3)Loadlevel((char *)":Data:Maps:map4");
813 else if(which==4)Loadlevel((char *)":Data:Maps:map5");
814 else if(which==5)Loadlevel((char *)":Data:Maps:map6");
815 else if(which==6)Loadlevel((char *)":Data:Maps:map7");
816 else if(which==7)Loadlevel((char *)":Data:Maps:map8");
817 else if(which==8)Loadlevel((char *)":Data:Maps:map9");
818 else if(which==9)Loadlevel((char *)":Data:Maps:map10");
819 else if(which==10)Loadlevel((char *)":Data:Maps:map11");
820 else if(which==11)Loadlevel((char *)":Data:Maps:map12");
821 else if(which==12)Loadlevel((char *)":Data:Maps:map13");
822 else if(which==13)Loadlevel((char *)":Data:Maps:map14");
823 else if(which==14)Loadlevel((char *)":Data:Maps:map15");
824 else if(which==15)Loadlevel((char *)":Data:Maps:map16");
825 else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
826 else Loadlevel((char *)":Data:Maps:mapsave");
831 /*char * Game::MD5_string (unsigned char *string){
835 strcpy(temp2,(const char *)string);
836 strcat((char *)temp2,(const char *)"Lugaru");
837 sprintf (temp, "%d",strlen((char *)temp2));
838 strcat((char *)temp2,temp);
841 unsigned int len = strlen ( (char *)temp2);
843 context.update ((unsigned char *)temp2, len);
846 return context.hex_digest();
851 void Game::Loadlevel(char *name){
858 float headprop,legprop,armprop,bodyprop;
862 LOG(std::string("Loading level...") + name);
864 if(!gameon)visibleloading=1;
866 if(stealthloading)visibleloading=0;
868 if(!stillloading)loadtime=0;
873 if(tutoriallevel!=-1)tutoriallevel=0;
874 else tutoriallevel=1;
876 if(tutoriallevel==1)tutorialstage=0;
877 if(tutorialstage==0){
885 OPENAL_SetPaused(channels[whooshsound], true);
886 OPENAL_SetPaused(channels[stream_firesound], true);
890 tfile=fopen( name, "rb" );
893 OPENAL_SetPaused(channels[stream_firesound], true);
904 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
910 dialoguegonethrough[i]=0;
919 if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
921 if(difficulty!=2)minimap=1;
958 bonustotal=startbonustotal;
964 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
965 OPENAL_SetVolume(channels[consolesuccesssound], 256);
966 OPENAL_SetPaused(channels[consolesuccesssound], false);
974 sprites.numsprites=0;
975 for(i=0;i<objects.numobjects;i++)
977 objects.model[i].numdecals=0;
980 j=objects.numobjects;
983 objects.DeleteObject(0);
984 if(visibleloading){loadscreencolor=4; LoadingScreen();}
987 for(i=0;i<subdivision;i++)
989 for(j=0;j<subdivision;j++)
991 terrain.patchobjectnum[i][j]=0;
994 if(visibleloading){loadscreencolor=4; LoadingScreen();}
997 weapons.numweapons=0;
999 funpackf(tfile, "Bi", &mapvers);
1000 if(mapvers>=15)funpackf(tfile, "Bi", &indemo);
1002 if(mapvers>=5)funpackf(tfile, "Bi", &maptype);
1003 else maptype=mapkilleveryone;
1004 if(mapvers>=6)funpackf(tfile, "Bi", &hostile);
1006 if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
1012 if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
1020 if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
1023 skyboxlightr=skyboxr;
1024 skyboxlightg=skyboxg;
1025 skyboxlightb=skyboxb;
1027 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);
1028 if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons);
1029 player[0].originalcoords=player[0].coords;
1030 if(player[0].num_weapons>0&&player[0].num_weapons<5)
1032 for(j=0;j<player[0].num_weapons;j++)
1034 player[0].weaponids[j]=weapons.numweapons;
1035 funpackf(tfile, "Bi", &weapons.type[weapons.numweapons]);
1036 weapons.owner[weapons.numweapons]=0;
1037 weapons.numweapons++;
1041 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1043 funpackf(tfile, "Bf Bf Bf", &player[0].armorhead, &player[0].armorhigh, &player[0].armorlow);
1044 funpackf(tfile, "Bf Bf Bf", &player[0].protectionhead, &player[0].protectionhigh, &player[0].protectionlow);
1045 funpackf(tfile, "Bf Bf Bf", &player[0].metalhead, &player[0].metalhigh, &player[0].metallow);
1046 funpackf(tfile, "Bf Bf", &player[0].power, &player[0].speedmult);
1048 funpackf(tfile, "Bi", &player[0].numclothes);
1052 funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature);
1056 player[0].whichskin=0;
1057 player[0].creature=rabbittype;
1060 for(i=0;i<max_dialogues;i++)
1062 for(j=0;j<max_dialoguelength;j++)
1066 dialoguetext[i][j][k]='\0';
1070 dialoguename[i][j][k]='\0';
1075 player[0].lastattack=-1;
1076 player[0].lastattack2=-1;
1077 player[0].lastattack3=-1;
1081 funpackf(tfile, "Bi", &numdialogues);
1084 for(k=0;k<numdialogues;k++)
1086 funpackf(tfile, "Bi", &numdialogueboxes[k]);
1087 funpackf(tfile, "Bi", &dialoguetype[k]);
1090 funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z);
1091 funpackf(tfile, "Bf", &participantrotation[k][l]);
1093 if(numdialogueboxes)
1095 for(l=0;l<numdialogueboxes[k];l++)
1097 funpackf(tfile, "Bi", &dialogueboxlocation[k][l]);
1098 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][0]);
1099 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][1]);
1100 funpackf(tfile, "Bf", &dialogueboxcolor[k][l][2]);
1101 funpackf(tfile, "Bi", &dialogueboxsound[k][l]);
1105 funpackf(tfile, "Bi",&templength);
1106 if(templength>128||templength<=0)templength=128;
1107 for(m=0;m<templength;m++){
1108 funpackf(tfile, "Bb", &dialoguetext[k][l][m]);
1109 if(dialoguetext[k][l][m]=='\0')break;
1112 funpackf(tfile, "Bi",&templength);
1113 if(templength>64||templength<=0)templength=64;
1114 for(m=0;m<templength;m++){
1115 funpackf(tfile, "Bb", &dialoguename[k][l][m]);
1116 if(dialoguename[k][l][m]=='\0'){
1120 funpackf(tfile, "Bf Bf Bf", &dialoguecamera[k][l].x, &dialoguecamera[k][l].y, &dialoguecamera[k][l].z);
1121 funpackf(tfile, "Bi", &participantfocus[k][l]);
1122 funpackf(tfile, "Bi", &participantaction[k][l]);
1125 funpackf(tfile, "Bf Bf Bf", &participantfacing[k][l][m].x, &participantfacing[k][l][m].y, &participantfacing[k][l][m].z);
1127 funpackf(tfile, "Bf Bf",&dialoguecamerarotation[k][l],&dialoguecamerarotation2[k][l]);
1133 else numdialogues=0;
1135 if(player[0].numclothes)
1137 for(k=0;k<player[0].numclothes;k++)
1139 funpackf(tfile, "Bi", &templength);
1140 for(l=0;l<templength;l++)
1141 funpackf(tfile, "Bb", &player[0].clothes[k][l]);
1142 player[0].clothes[k][templength]='\0';
1143 funpackf(tfile, "Bf Bf Bf", &player[0].clothestintr[k], &player[0].clothestintg[k], &player[0].clothestintb[k]);
1147 funpackf(tfile, "Bi", &environment);
1149 funpackf(tfile, "Bi", &objects.numobjects);
1150 if(objects.numobjects)
1152 for(i=0;i<objects.numobjects;i++)
1154 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]);
1155 if(objects.type[i]==treeleavestype)objects.scale[i]=objects.scale[i-1];
1161 funpackf(tfile, "Bi", &numhotspots);
1164 for(i=0;i<numhotspots;i++)
1166 funpackf(tfile, "Bi Bf Bf Bf Bf", &hotspottype[i],&hotspotsize[i],&hotspot[i].x,&hotspot[i].y,&hotspot[i].z);
1167 funpackf(tfile, "Bi", &templength);
1169 for(l=0;l<templength;l++)
1170 funpackf(tfile, "Bb", &hotspottext[i][l]);
1171 hotspottext[i][templength]='\0';
1172 if(hotspottype[i]==-111)indemo=1;
1178 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1183 for(i=0;i<objects.numobjects;i++)
1185 objects.center+=objects.position[i];
1187 objects.center/=objects.numobjects;
1190 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1192 float maxdistance=0;
1195 for(i=0;i<objects.numobjects;i++)
1197 tempdist=findDistancefast(&objects.center,&objects.position[i]);
1198 if(tempdist>maxdistance)
1201 maxdistance=tempdist;
1204 objects.radius=fast_sqrt(maxdistance);
1207 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1208 //mapcenter=objects.center;
1209 //mapradius=objects.radius;
1211 funpackf(tfile, "Bi", &numplayers);
1212 int howmanyremoved=0;
1213 bool removeanother=0;
1214 if(numplayers>1&&numplayers<maxplayers)
1216 for(i=1;i<numplayers;i++)
1218 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1221 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);
1222 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive);
1223 else player[i-howmanyremoved].howactive=typeactive;
1224 if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale);
1225 else player[i-howmanyremoved].scale=-1;
1226 if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile);
1227 else player[i-howmanyremoved].immobile=0;
1228 if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation);
1229 else player[i-howmanyremoved].rotation=0;
1230 player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation;
1231 if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){
1237 if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5)
1239 for(j=0;j<player[i-howmanyremoved].num_weapons;j++)
1241 player[i-howmanyremoved].weaponids[j]=weapons.numweapons;
1242 funpackf(tfile, "Bi", &weapons.type[player[i-howmanyremoved].weaponids[j]]);
1243 weapons.owner[player[i-howmanyremoved].weaponids[j]]=i;
1244 weapons.numweapons++;
1247 funpackf(tfile, "Bi", &player[i-howmanyremoved].numwaypoints);
1248 //player[i-howmanyremoved].numwaypoints=10;
1249 for(j=0;j<player[i-howmanyremoved].numwaypoints;j++)
1251 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].x);
1252 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].y);
1253 funpackf(tfile, "Bf", &player[i-howmanyremoved].waypoints[j].z);
1254 if(mapvers>=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]);
1255 else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking;
1258 funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint);
1259 if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0;
1261 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow);
1262 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow);
1263 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow);
1264 funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult);
1266 if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop);
1274 if(player[i-howmanyremoved].creature==wolftype)
1276 player[i-howmanyremoved].proportionhead=1.1*headprop;
1277 player[i-howmanyremoved].proportionbody=1.1*bodyprop;
1278 player[i-howmanyremoved].proportionarms=1.1*armprop;
1279 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1282 if(player[i-howmanyremoved].creature==rabbittype)
1284 player[i-howmanyremoved].proportionhead=1.2*headprop;
1285 player[i-howmanyremoved].proportionbody=1.05*bodyprop;
1286 player[i-howmanyremoved].proportionarms=1.00*armprop;
1287 player[i-howmanyremoved].proportionlegs=1.1*legprop;
1288 player[i-howmanyremoved].proportionlegs.y=1.05*legprop;
1291 funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes);
1292 if(player[i-howmanyremoved].numclothes)
1294 for(k=0;k<player[i-howmanyremoved].numclothes;k++)
1297 funpackf(tfile, "Bi", &templength);
1298 for(l=0;l<templength;l++)
1299 funpackf(tfile, "Bb", &player[i-howmanyremoved].clothes[k][l]);
1300 player[i-howmanyremoved].clothes[k][templength]='\0';
1301 funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].clothestintr[k], &player[i-howmanyremoved].clothestintg[k], &player[i-howmanyremoved].clothestintb[k]);
1307 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1309 numplayers-=howmanyremoved;
1310 funpackf(tfile, "Bi", &numpathpoints);
1311 if(numpathpoints>30||numpathpoints<0)
1315 for(j=0;j<numpathpoints;j++)
1317 funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x,&pathpoint[j].y,&pathpoint[j].z,&numpathpointconnect[j]);
1318 for(k=0;k<numpathpointconnect[j];k++){
1319 funpackf(tfile, "Bi", &pathpointconnect[j][k]);
1323 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1325 funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x,&mapcenter.y,&mapcenter.z,&mapradius);
1328 if(environment!=oldenvironment)Setenvironment(environment);
1329 oldenvironment=environment;
1333 j=objects.numobjects;
1334 objects.numobjects=0;
1337 //if(objects.type[i]!=spiketype)
1338 objects.MakeObject(objects.type[i],objects.position[i],objects.rotation[i],objects.rotation2[i],objects.scale[i]);
1339 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1342 //if(skyboxtexture){
1343 terrain.DoShadows();
1344 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1345 objects.DoShadows();
1346 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1348 else terrain.DoLighting();
1354 oldlevel=whichlevel;
1357 if(numplayers>maxplayers-1)numplayers=maxplayers-1;
1358 for(i=0;i<numplayers;i++)
1360 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1364 if(i==0||player[i].scale<0)player[i].scale=.2;
1365 player[i].skeleton.free=0;
1366 player[i].skeleton.id=i;
1367 //if(Random()%2==0)player[i].creature=wolftype;
1368 //else player[i].creature=rabbittype;
1369 if(i==0&&mapvers<9)player[i].creature=rabbittype;
1370 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);
1373 if(player[i].creature!=wolftype){
1374 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);
1375 LoadTexture(":Data:Textures:Belt.png",&player[i].skeleton.drawmodelclothes.textureptr,1,1);
1377 if(player[i].creature==wolftype){
1378 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);
1384 texsize=512*512*3/texdetail/texdetail;
1385 //if(!player[i].loaded)player[i].skeleton.skinText = new GLubyte[texsize];
1386 //player[i].skeleton.skinText.resize(texsize);
1388 if(player[i].creature==rabbittype)
1390 if(player[i].whichskin==0){
1391 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1393 else if(player[i].whichskin==1){
1394 LoadTextureSave(":Data:Textures:Fur.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1396 else if(player[i].whichskin==2){
1397 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1399 else if(player[i].whichskin==3){
1400 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1402 else if(player[i].whichskin==4){
1403 LoadTextureSave(":Data:Textures:Otter.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1405 else if(player[i].whichskin==5){
1406 LoadTextureSave(":Data:Textures:Opal.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1408 else if(player[i].whichskin==6){
1409 LoadTextureSave(":Data:Textures:Sable.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1411 else if(player[i].whichskin==7){
1412 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1414 else if(player[i].whichskin==8){
1415 LoadTextureSave(":Data:Textures:BW2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1417 else if(player[i].whichskin==9){
1418 LoadTextureSave(":Data:Textures:WB2.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1421 if(player[i].creature==wolftype)
1423 //k=abs(Random()%3);
1424 if(player[i].whichskin==0){
1425 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1427 else if(player[i].whichskin==1){
1428 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1430 else if(player[i].whichskin==2){
1431 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[i].skeleton.drawmodel.textureptr,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1435 if(player[i].numclothes)
1437 for(j=0;j<player[i].numclothes;j++)
1439 tintr=player[i].clothestintr[j];
1440 tintg=player[i].clothestintg[j];
1441 tintb=player[i].clothestintb[j];
1442 AddClothes((char *)player[i].clothes[j],0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
1444 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
1447 player[i].currentanimation=bounceidleanim;
1448 player[i].targetanimation=bounceidleanim;
1449 player[i].currentframe=0;
1450 player[i].targetframe=1;
1452 player[i].speed=1+(float)(Random()%100)/1000;
1453 if(difficulty==0)player[i].speed-=.2;
1454 if(difficulty==1)player[i].speed-=.1;
1456 player[i].velocity=0;
1457 player[i].oldcoords=player[i].coords;
1458 player[i].realoldcoords=player[i].coords;
1461 player[i].skeleton.id=i;
1462 player[i].updatedelay=0;
1463 player[i].normalsupdatedelay=0;
1465 player[i].aitype=passivetype;
1466 player[i].aitarget=0;
1467 player[i].madskills=0;
1471 player[i].proportionhead=1.2;
1472 player[i].proportionbody=1.05;
1473 player[i].proportionarms=1.00;
1474 player[i].proportionlegs=1.1;
1475 player[i].proportionlegs.y=1.05;
1477 player[i].headless=0;
1478 player[i].currentoffset=0;
1479 player[i].targetoffset=0;
1480 /*player[i].armorhead=1;
1481 player[i].armorhigh=1;
1482 player[i].armorlow=1;
1483 player[i].protectionhead=1;
1484 player[i].protectionhigh=1;
1485 player[i].protectionlow=1;
1486 player[i].metalhead=1;
1487 player[i].metalhigh=1;
1488 player[i].metallow=1;
1490 player[i].speedmult=1;*/
1492 player[i].damagetolerance=200;
1494 if(player[i].creature==wolftype)
1496 /*player[i].proportionhead=1.1;
1497 player[i].proportionbody=1.1;
1498 player[i].proportionarms=1.1;
1499 player[i].proportionlegs=1.1;
1500 player[i].proportionlegs.y=1.1;*/
1501 if(i==0||player[i].scale<0)player[i].scale=.23;
1503 player[i].damagetolerance=300;
1506 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1509 player[i].proportionhead.z=0;
1510 player[i].proportionbody.z=0;
1511 player[i].proportionarms.z=0;
1512 player[i].proportionlegs.z=0;
1515 player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
1517 player[i].headmorphness=0;
1518 player[i].targetheadmorphness=1;
1519 player[i].headmorphstart=0;
1520 player[i].headmorphend=0;
1522 player[i].pausetime=0;
1525 player[i].jumppower=5;
1527 player[i].permanentdamage=0;
1528 player[i].superpermanentdamage=0;
1530 player[i].forwardkeydown=0;
1531 player[i].leftkeydown=0;
1532 player[i].backkeydown=0;
1533 player[i].rightkeydown=0;
1534 player[i].jumpkeydown=0;
1535 player[i].crouchkeydown=0;
1536 player[i].throwkeydown=0;
1538 player[i].collided=-10;
1540 player[i].bloodloss=0;
1541 player[i].weaponactive=-1;
1542 player[i].weaponstuck=-1;
1543 player[i].bleeding=0;
1544 player[i].deathbleeding=0;
1545 player[i].stunned=0;
1546 player[i].hasvictim=0;
1547 player[i].wentforweapon=0;
1550 player[0].aitype=playercontrolled;
1551 player[0].weaponactive=-1;
1555 //player[0].speedmult=1/.9;
1556 player[0].power=1/.9;
1561 //player[0].speedmult=1/.8;
1562 player[0].power=1/.8;
1565 //player[0].weaponstuck=1;
1567 if(difficulty==1)player[0].damagetolerance=250;
1568 if(difficulty==0)player[0].damagetolerance=300;
1569 if(difficulty==0)player[0].armorhead*=1.5;
1570 if(difficulty==0)player[0].armorhigh*=1.5;
1571 if(difficulty==0)player[0].armorlow*=1.5;
1572 cameraloc=player[0].coords;
1574 rotation=player[0].rotation;
1576 hawkcoords=player[0].coords;
1579 if(visibleloading){loadscreencolor=4; LoadingScreen();}
1580 //weapons.numweapons=numplayers;
1581 for(i=0;i<weapons.numweapons;i++)
1583 weapons.bloody[i]=0;
1584 weapons.blooddrip[i]=0;
1585 weapons.blooddripdelay[i]=0;
1586 weapons.onfire[i]=0;
1587 weapons.flamedelay[i]=0;
1588 weapons.damage[i]=0;
1589 //weapons.type[i]=sword;
1590 if(weapons.type[i]==sword){
1591 weapons.mass[i]=1.5;
1592 weapons.tipmass[i]=1;
1593 weapons.length[i]=.8;
1595 if(weapons.type[i]==staff){
1597 weapons.tipmass[i]=1;
1598 weapons.length[i]=1.5;
1600 if(weapons.type[i]==knife){
1602 weapons.tipmass[i]=1.2;
1603 weapons.length[i]=.25;
1605 weapons.position[i]=-1000;
1606 weapons.tippoint[i]=-1000;
1609 /* for(i=0;i<32;i++){
1611 OPENAL_StopSound(i);
1614 LOG("Starting background music...");
1616 OPENAL_StopSound(OPENAL_ALL);
1617 if(environment==snowyenvironment)
1621 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1622 OPENAL_SetPaused(channels[stream_wind], false);
1623 OPENAL_SetVolume(channels[stream_wind], 256);
1626 else if(environment==desertenvironment)
1630 //PlaySoundEx(desertambient,
1631 // samp[desertambient], NULL, true);
1632 PlayStreamEx(stream_desertambient,
1633 strm[stream_desertambient], NULL, true);
1634 OPENAL_SetPaused(channels[stream_desertambient], false);
1635 OPENAL_SetVolume(channels[stream_desertambient], 256);
1638 else if(environment==grassyenvironment)
1642 //PlaySoundEx(wind, samp[wind], NULL, true);
1643 PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
1644 OPENAL_SetPaused(channels[stream_wind], false);
1645 OPENAL_SetVolume(channels[stream_wind], 100);
1648 oldmusicvolume[0]=0;
1649 oldmusicvolume[1]=0;
1650 oldmusicvolume[2]=0;
1651 oldmusicvolume[3]=0;
1654 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1655 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1656 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1657 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1658 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1659 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1660 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1661 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1676 static int i,k,j,l,m;
1677 static XYZ facing,flatfacing,absflatfacing;
1678 static XYZ rotatetarget;
1680 static float oldtargetrotation;
1681 static int target, numgood;
1682 static XYZ tempcoords1,tempcoords2;
1685 static XYZ lowpoint,lowpointtarget,lowpoint2,lowpointtarget2,lowpoint3,lowpointtarget3,lowpoint4,lowpointtarget4,lowpoint5,lowpointtarget5,lowpoint6,lowpointtarget6,lowpoint7,lowpointtarget7,colpoint,colpoint2;
1686 static int whichhit;
1687 static bool donesomething;
1688 static bool oldjumpkeydown;
1692 float headprop,bodyprop,armprop,legprop;
1696 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1697 OPENAL_SetVolume(channels[consolesuccesssound], 256);
1698 OPENAL_SetPaused(channels[consolesuccesssound], false);
1702 consoletext[k][j]=consoletext[k-1][j];
1704 consolechars[k]=consolechars[k-1];
1708 displaytext[k][j]=displaytext[k-1][j];
1710 displaychars[k]=displaychars[k-1];
1711 displaytime[k]=displaytime[k-1];
1714 consoletext[1][j]=' ';
1715 displaytext[1][j]=' ';
1717 sprintf (consoletext[1], netmessages);
1718 sprintf (displaytext[1], netmessages);
1719 consolechars[1]=255;
1720 displaychars[1]=255;
1725 displaytime[i]+=multiplier;
1728 static unsigned char theKeyMap[16];
1729 GetKeys( theKeyMap );
1734 static bool mainmenutogglekeydown;
1736 if(mainmenu&&endgame==1)mainmenu=10;
1737 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
1739 displaytext[0][j]=' ';
1744 mainmenutogglekeydown=1;
1746 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)){
1748 if(mainmenu==1||mainmenu==2||mainmenu==0){
1749 if(mainmenu==0&&!winfreeze)mainmenu=2;
1750 else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
1751 else if(mainmenu==0&&winfreeze){
1752 /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
1754 else stealthloading=0;
1756 if(!stealthloading){
1757 float gLoc[3]={0,0,0};
1758 float vel[3]={0,0,0};
1759 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1760 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1761 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1762 OPENAL_SetVolume(channels[firestartsound], 256);
1763 OPENAL_SetPaused(channels[firestartsound], false);
1764 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1775 for(i=0;i<campaignnumlevels;i++){
1777 levelhighlight[i]=0;
1782 if(accountcampaignchoicesmade[accountactive])
1783 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
1784 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
1785 levelvisible[levelorder[i+1]]=1;
1787 int whichlevelstart;
1788 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
1789 if(whichlevelstart<0){
1790 campaignchoicenum=1;
1791 campaignchoicewhich[0]=0;
1795 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
1796 if(campaignchoicenum)
1797 for(i=0;i<campaignchoicenum;i++){
1798 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
1799 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1800 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
1807 if(firstload)TickOnceAfter();
1808 if(!firstload)LoadStuff();
1825 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
1826 //accountcampaignchoicesmade[accountactive]++;
1829 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
1837 OPENAL_SetPaused(channels[music3], true);
1841 else if(mainmenu==1||mainmenu==2)mainmenu=0;
1842 if(mainmenu&&musictoggle){
1843 if(mainmenu==1||mainmenu==2||mainmenu==100){
1844 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
1845 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
1846 OPENAL_SetPaused(channels[stream_music3], false);
1847 OPENAL_SetVolume(channels[stream_music3], 256);
1848 OPENAL_SetPaused(channels[music1], true);
1852 OPENAL_SetPaused(channels[stream_music3], true);
1853 OPENAL_SetPaused(channels[music1], false);
1857 float gLoc[3]={0,0,0};
1858 float vel[3]={0,0,0};
1859 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1860 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1861 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1862 OPENAL_SetVolume(channels[fireendsound], 256);
1863 OPENAL_SetPaused(channels[fireendsound], false);
1864 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1872 if(newdetail>2)newdetail=detail;
1873 if(newdetail<0)newdetail=detail;
1874 if(newscreenwidth<0)newscreenwidth=screenwidth;
1875 if(newscreenheight<0)newscreenheight=screenheight;
1877 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1878 opstream << "Screenwidth:\n";
1879 opstream << newscreenwidth;
1880 opstream << "\nScreenheight:\n";
1881 opstream << newscreenheight;
1882 opstream << "\nMouse sensitivity:\n";
1883 opstream << usermousesensitivity;
1884 opstream << "\nBlur(0,1):\n";
1885 opstream << ismotionblur;
1886 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1887 opstream << newdetail;
1888 opstream << "\nFloating jump:\n";
1889 opstream << floatjump;
1890 opstream << "\nMouse jump:\n";
1891 opstream << mousejump;
1892 opstream << "\nAmbient sound:\n";
1893 opstream << ambientsound;
1894 opstream << "\nBlood (0,1,2):\n";
1895 opstream << bloodtoggle;
1896 opstream << "\nAuto slomo:\n";
1897 opstream << autoslomo;
1898 opstream << "\nFoliage:\n";
1899 opstream << foliage;
1900 opstream << "\nMusic:\n";
1901 opstream << musictoggle;
1902 opstream << "\nTrilinear:\n";
1903 opstream << trilinear;
1904 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1906 opstream << "\nInvert mouse:\n";
1907 opstream << invertmouse;
1908 opstream << "\nGamespeed:\n";
1909 if(oldgamespeed==0)oldgamespeed=1;
1910 opstream << oldgamespeed;
1911 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1912 opstream << difficulty;
1913 opstream << "\nDamage effects(blackout, doublevision):\n";
1914 opstream << damageeffects;
1915 opstream << "\nText:\n";
1916 opstream << texttoggle;
1917 opstream << "\nDebug:\n";
1918 opstream << debugmode;
1919 opstream << "\nVBL Sync:\n";
1920 opstream << vblsync;
1921 opstream << "\nShow Points:\n";
1922 opstream << showpoints;
1923 opstream << "\nAlways Blur:\n";
1924 opstream << alwaysblur;
1925 opstream << "\nImmediate mode (turn on on G5):\n";
1926 opstream << immediate;
1927 opstream << "\nVelocity blur:\n";
1928 opstream << velocityblur;
1929 opstream << "\nVolume:\n";
1931 opstream << "\nForward key:\n";
1932 opstream << KeyToChar(forwardkey);
1933 opstream << "\nBack key:\n";
1934 opstream << KeyToChar(backkey);
1935 opstream << "\nLeft key:\n";
1936 opstream << KeyToChar(leftkey);
1937 opstream << "\nRight key:\n";
1938 opstream << KeyToChar(rightkey);
1939 opstream << "\nJump key:\n";
1940 opstream << KeyToChar(jumpkey);
1941 opstream << "\nCrouch key:\n";
1942 opstream << KeyToChar(crouchkey);
1943 opstream << "\nDraw key:\n";
1944 opstream << KeyToChar(drawkey);
1945 opstream << "\nThrow key:\n";
1946 opstream << KeyToChar(throwkey);
1947 opstream << "\nAttack key:\n";
1948 opstream << KeyToChar(attackkey);
1949 opstream << "\nChat key:\n";
1950 opstream << KeyToChar(chatkey);
1953 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
1954 float gLoc[3]={0,0,0};
1955 float vel[3]={0,0,0};
1956 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1957 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1958 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1959 OPENAL_SetVolume(channels[fireendsound], 256);
1960 OPENAL_SetPaused(channels[fireendsound], false);
1961 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1969 if(mainmenu==3&&gameon)mainmenu=2;
1970 if(mainmenu==3&&!gameon)mainmenu=1;
1971 if(mainmenu==5&&gameon)mainmenu=2;
1972 if(mainmenu==5&&!gameon)mainmenu=1;
1973 if(mainmenu==4)mainmenu=3;
1974 if(mainmenu==6)mainmenu=5;
1975 if(mainmenu==7)mainmenu=1;
1976 if(mainmenu==9)mainmenu=5;
1977 if(mainmenu==11)mainmenu=5;
1978 if(mainmenu==13)mainmenu=12;
1979 if(mainmenu==10)mainmenu=5;
1985 mainmenutogglekeydown=1;
1987 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1988 mainmenutogglekeydown=0;
1992 /*static bool minimaptogglekeydown;
1993 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
1995 minimaptogglekeydown=1;
1997 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
1998 minimaptogglekeydown=0;
2002 static bool minimaptogglekeydown;
2003 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
2004 if(tutorialstage!=51)
2005 tutorialstagetime=tutorialmaxtime;
2006 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
2007 OPENAL_SetVolume(channels[consolefailsound], 128);
2008 OPENAL_SetPaused(channels[consolefailsound], false);
2009 minimaptogglekeydown=1;
2011 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
2012 minimaptogglekeydown=0;
2017 if(mainmenu==1||mainmenu==2){
2018 if(Button()&&!oldbutton&&selected==1){
2020 float gLoc[3]={0,0,0};
2021 float vel[3]={0,0,0};
2022 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2023 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2024 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2025 OPENAL_SetVolume(channels[firestartsound], 256);
2026 OPENAL_SetPaused(channels[firestartsound], false);
2027 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2036 if(accountactive!=-1)mainmenu=5;
2043 if(firstload)TickOnceAfter();
2044 if(!firstload)LoadStuff();
2050 OPENAL_SetPaused(channels[music3], true); */
2056 OPENAL_SetPaused(channels[stream_music3], true);
2057 OPENAL_SetPaused(channels[music1], false);
2061 if(Button()&&!oldbutton&&selected==2){
2062 float gLoc[3]={0,0,0};
2063 float vel[3]={0,0,0};
2064 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2065 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2066 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2067 OPENAL_SetVolume(channels[firestartsound], 256);
2068 OPENAL_SetPaused(channels[firestartsound], false);
2069 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2081 if(newdetail>2)newdetail=detail;
2082 if(newdetail<0)newdetail=detail;
2083 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2084 if(newscreenwidth<0)newscreenwidth=screenwidth;
2085 if(newscreenheight>3000)newscreenheight=screenheight;
2086 if(newscreenheight<0)newscreenheight=screenheight;
2089 if(Button()&&!oldbutton&&selected==3){
2090 float gLoc[3]={0,0,0};
2091 float vel[3]={0,0,0};
2092 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2093 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2094 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2095 OPENAL_SetVolume(channels[fireendsound], 256);
2096 OPENAL_SetPaused(channels[fireendsound], false);
2097 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2108 OPENAL_SetPaused(channels[stream_music3], true);
2116 if(Button())oldbutton=1;
2121 if(Button()&&!oldbutton&&selected!=-1){
2122 float gLoc[3]={0,0,0};
2123 float vel[3]={0,0,0};
2124 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2125 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2126 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2127 OPENAL_SetVolume(channels[firestartsound], 256);
2128 OPENAL_SetPaused(channels[firestartsound], false);
2129 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2131 if(Button()&&!oldbutton&&selected==0){
2133 extern SDL_Rect **resolutions;
2134 bool isCustomResolution = true;
2136 for (int i = 0; (!found) && (resolutions[i]); i++)
2138 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2139 isCustomResolution = false;
2141 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2144 if (resolutions[i] != NULL)
2146 newscreenwidth = (int) resolutions[i]->w;
2147 newscreenheight = (int) resolutions[i]->h;
2149 else if (isCustomResolution)
2151 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2153 newscreenwidth = (int) resolutions[0]->w;
2154 newscreenheight = (int) resolutions[0]->h;
2158 newscreenwidth = screenwidth;
2159 newscreenheight = screenheight;
2164 newscreenwidth = (int) resolutions[0]->w;
2165 newscreenheight = (int) resolutions[0]->h;
2173 newscreenwidth = (int) resolutions[0]->w;
2174 newscreenheight = (int) resolutions[0]->h;
2179 if(Button()&&!oldbutton&&selected==1){
2181 if(newdetail>2)newdetail=0;
2183 if(Button()&&!oldbutton&&selected==2){
2185 if(bloodtoggle>2)bloodtoggle=0;
2187 if(Button()&&!oldbutton&&selected==3){
2189 if(difficulty>2)difficulty=0;
2191 if(Button()&&!oldbutton&&selected==4){
2192 ismotionblur=1-ismotionblur;
2194 if(Button()&&!oldbutton&&selected==5){
2197 if(Button()&&!oldbutton&&selected==6){
2198 musictoggle=1-musictoggle;
2201 OPENAL_SetPaused(channels[music1], true);
2202 OPENAL_SetPaused(channels[stream_music2], true);
2203 OPENAL_SetPaused(channels[stream_music3], true);
2206 oldmusicvolume[i]=0;
2212 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2213 OPENAL_SetPaused(channels[stream_music3], false);
2214 OPENAL_SetVolume(channels[stream_music3], 256);
2217 if(Button()&&!oldbutton&&selected==9){
2218 invertmouse=1-invertmouse;
2220 if(Button()&&!oldbutton&&selected==10){
2221 usermousesensitivity+=.2;
2222 if(usermousesensitivity>2)usermousesensitivity=.2;
2224 if(Button()&&!oldbutton&&selected==11){
2226 if(volume>1.0001f)volume=0;
2227 OPENAL_SetSFXMasterVolume((int)(volume*255));
2229 if(Button()&&!oldbutton&&selected==7){
2230 /*float gLoc[3]={0,0,0};
2231 float vel[3]={0,0,0};
2232 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2233 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2234 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2235 OPENAL_SetVolume(channels[firestartsound], 256);
2236 OPENAL_SetPaused(channels[firestartsound], false);
2237 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2250 if(Button()&&!oldbutton&&selected==8){
2251 float gLoc[3]={0,0,0};
2252 float vel[3]={0,0,0};
2253 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2254 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2255 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2256 OPENAL_SetVolume(channels[fireendsound], 256);
2257 OPENAL_SetPaused(channels[fireendsound], false);
2258 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2266 if(newdetail>2)newdetail=detail;
2267 if(newdetail<0)newdetail=detail;
2268 if(newscreenwidth<0)newscreenwidth=screenwidth;
2269 if(newscreenheight<0)newscreenheight=screenheight;
2272 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2273 opstream << "Screenwidth:\n";
2274 opstream << newscreenwidth;
2275 opstream << "\nScreenheight:\n";
2276 opstream << newscreenheight;
2277 opstream << "\nMouse sensitivity:\n";
2278 opstream << usermousesensitivity;
2279 opstream << "\nBlur(0,1):\n";
2280 opstream << ismotionblur;
2281 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2282 opstream << newdetail;
2283 opstream << "\nFloating jump:\n";
2284 opstream << floatjump;
2285 opstream << "\nMouse jump:\n";
2286 opstream << mousejump;
2287 opstream << "\nAmbient sound:\n";
2288 opstream << ambientsound;
2289 opstream << "\nBlood (0,1,2):\n";
2290 opstream << bloodtoggle;
2291 opstream << "\nAuto slomo:\n";
2292 opstream << autoslomo;
2293 opstream << "\nFoliage:\n";
2294 opstream << foliage;
2295 opstream << "\nMusic:\n";
2296 opstream << musictoggle;
2297 opstream << "\nTrilinear:\n";
2298 opstream << trilinear;
2299 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2301 opstream << "\nInvert mouse:\n";
2302 opstream << invertmouse;
2303 opstream << "\nGamespeed:\n";
2304 if(oldgamespeed==0)oldgamespeed=1;
2305 opstream << oldgamespeed;
2306 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2307 opstream << difficulty;
2308 opstream << "\nDamage effects(blackout, doublevision):\n";
2309 opstream << damageeffects;
2310 opstream << "\nText:\n";
2311 opstream << texttoggle;
2312 opstream << "\nDebug:\n";
2313 opstream << debugmode;
2314 opstream << "\nVBL Sync:\n";
2315 opstream << vblsync;
2316 opstream << "\nShow Points:\n";
2317 opstream << showpoints;
2318 opstream << "\nAlways Blur:\n";
2319 opstream << alwaysblur;
2320 opstream << "\nImmediate mode (turn on on G5):\n";
2321 opstream << immediate;
2322 opstream << "\nVelocity blur:\n";
2323 opstream << velocityblur;
2324 opstream << "\nVolume:\n";
2326 opstream << "\nForward key:\n";
2327 opstream << KeyToChar(forwardkey);
2328 opstream << "\nBack key:\n";
2329 opstream << KeyToChar(backkey);
2330 opstream << "\nLeft key:\n";
2331 opstream << KeyToChar(leftkey);
2332 opstream << "\nRight key:\n";
2333 opstream << KeyToChar(rightkey);
2334 opstream << "\nJump key:\n";
2335 opstream << KeyToChar(jumpkey);
2336 opstream << "\nCrouch key:\n";
2337 opstream << KeyToChar(crouchkey);
2338 opstream << "\nDraw key:\n";
2339 opstream << KeyToChar(drawkey);
2340 opstream << "\nThrow key:\n";
2341 opstream << KeyToChar(throwkey);
2342 opstream << "\nAttack key:\n";
2343 opstream << KeyToChar(attackkey);
2344 opstream << "\nChat key:\n";
2345 opstream << KeyToChar(chatkey);
2348 if(mainmenu==3&&gameon)mainmenu=2;
2349 if(mainmenu==3&&!gameon)mainmenu=1;
2351 if(Button())oldbutton=1;
2355 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2356 float gLoc[3]={0,0,0};
2357 float vel[3]={0,0,0};
2358 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2359 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2360 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2361 OPENAL_SetVolume(channels[firestartsound], 256);
2362 OPENAL_SetPaused(channels[firestartsound], false);
2363 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2365 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2373 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2375 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2376 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2377 float gLoc[3]={0,0,0};
2378 float vel[3]={0,0,0};
2379 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2380 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2381 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2382 OPENAL_SetVolume(channels[fireendsound], 256);
2383 OPENAL_SetPaused(channels[fireendsound], false);
2384 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2388 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2389 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2393 if(keyselect==0)forwardkey=keynum;
2394 if(keyselect==1)backkey=keynum;
2395 if(keyselect==2)leftkey=keynum;
2396 if(keyselect==3)rightkey=keynum;
2397 if(keyselect==4)crouchkey=keynum;
2398 if(keyselect==5)jumpkey=keynum;
2399 if(keyselect==6)drawkey=keynum;
2400 if(keyselect==7)throwkey=keynum;
2401 if(keyselect==8)attackkey=keynum;
2406 if(Button()&&!oldbutton&&selected==9){
2407 float gLoc[3]={0,0,0};
2408 float vel[3]={0,0,0};
2409 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2410 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2411 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2412 OPENAL_SetVolume(channels[fireendsound], 256);
2413 OPENAL_SetPaused(channels[fireendsound], false);
2414 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2424 if(newdetail>2)newdetail=detail;
2425 if(newdetail<0)newdetail=detail;
2426 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2427 if(newscreenwidth<0)newscreenwidth=screenwidth;
2428 if(newscreenheight>3000)newscreenheight=screenheight;
2429 if(newscreenheight<0)newscreenheight=screenheight;
2436 accountcampaignchoicesmade[accountactive]=0;
2437 accountcampaignscore[accountactive]=0;
2438 accountcampaigntime[accountactive]=0;
2442 if(Button()&&!oldbutton&&selected==1){
2443 float gLoc[3]={0,0,0};
2444 float vel[3]={0,0,0};
2445 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2446 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2447 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2448 OPENAL_SetVolume(channels[firestartsound], 256);
2449 OPENAL_SetPaused(channels[firestartsound], false);
2450 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2463 if(firstload)TickOnceAfter();
2464 if(!firstload)LoadStuff();
2471 OPENAL_SetPaused(channels[stream_music3], true);
2473 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2474 float gLoc[3]={0,0,0};
2475 float vel[3]={0,0,0};
2476 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2477 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2478 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2479 OPENAL_SetVolume(channels[firestartsound], 256);
2480 OPENAL_SetPaused(channels[firestartsound], false);
2481 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2494 if(firstload)TickOnceAfter();
2495 if(!firstload)LoadStuff();
2511 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2512 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2516 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2521 OPENAL_SetPaused(channels[stream_music3], true);
2523 if(Button()&&!oldbutton&&selected==4){
2524 float gLoc[3]={0,0,0};
2525 float vel[3]={0,0,0};
2526 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2527 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2528 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2529 OPENAL_SetVolume(channels[fireendsound], 256);
2530 OPENAL_SetPaused(channels[fireendsound], false);
2531 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2539 if(mainmenu==5&&gameon)mainmenu=2;
2540 if(mainmenu==5&&!gameon)mainmenu=1;
2542 if(Button()&&!oldbutton&&selected==5){
2543 float gLoc[3]={0,0,0};
2544 float vel[3]={0,0,0};
2545 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2546 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2547 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2548 OPENAL_SetVolume(channels[fireendsound], 256);
2549 OPENAL_SetPaused(channels[fireendsound], false);
2550 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2560 if(Button()&&!oldbutton&&selected==3){
2561 float gLoc[3]={0,0,0};
2562 float vel[3]={0,0,0};
2563 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2564 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2565 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2566 OPENAL_SetVolume(channels[firestartsound], 256);
2567 OPENAL_SetPaused(channels[firestartsound], false);
2568 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2578 if(Button()&&!oldbutton&&selected==2){
2579 float gLoc[3]={0,0,0};
2580 float vel[3]={0,0,0};
2581 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2582 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2583 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2584 OPENAL_SetVolume(channels[firestartsound], 256);
2585 OPENAL_SetPaused(channels[firestartsound], false);
2586 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2596 if(Button())oldbutton=1;
2600 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2601 float gLoc[3]={0,0,0};
2602 float vel[3]={0,0,0};
2603 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2604 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2605 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2606 OPENAL_SetVolume(channels[firestartsound], 256);
2607 OPENAL_SetPaused(channels[firestartsound], false);
2608 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2620 targetlevel=selected;
2621 if(firstload)TickOnceAfter();
2622 if(!firstload)LoadStuff();
2624 Loadlevel(selected);
2630 OPENAL_SetPaused(channels[stream_music3], true);
2632 if(Button()&&!oldbutton&&selected==numchallengelevels){
2633 float gLoc[3]={0,0,0};
2634 float vel[3]={0,0,0};
2635 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2636 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2637 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2638 OPENAL_SetVolume(channels[fireendsound], 256);
2639 OPENAL_SetPaused(channels[fireendsound], false);
2640 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2650 if(Button())oldbutton=1;
2654 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2655 float gLoc[3]={0,0,0};
2656 float vel[3]={0,0,0};
2657 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2658 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2659 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2660 OPENAL_SetVolume(channels[firestartsound], 256);
2661 OPENAL_SetPaused(channels[firestartsound], false);
2662 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2674 targetlevel=selected;
2675 if(firstload)TickOnceAfter();
2676 if(!firstload)LoadStuff();
2678 Loadlevel(selected);
2684 OPENAL_SetPaused(channels[stream_music3], true);
2686 if(Button()&&!oldbutton&&selected==numchallengelevels){
2687 float gLoc[3]={0,0,0};
2688 float vel[3]={0,0,0};
2689 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2690 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2691 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2692 OPENAL_SetVolume(channels[fireendsound], 256);
2693 OPENAL_SetPaused(channels[fireendsound], false);
2694 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2704 if(Button())oldbutton=1;
2709 if(Button()&&!oldbutton&&selected==3){
2710 float gLoc[3]={0,0,0};
2711 float vel[3]={0,0,0};
2712 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2713 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2714 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2715 OPENAL_SetVolume(channels[fireendsound], 256);
2716 OPENAL_SetPaused(channels[fireendsound], false);
2717 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2727 if(Button())oldbutton=1;
2732 if(Button()&&!oldbutton&&selected!=-1){
2733 float gLoc[3]={0,0,0};
2734 float vel[3]={0,0,0};
2735 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2736 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2737 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2738 OPENAL_SetVolume(channels[firestartsound], 256);
2739 OPENAL_SetPaused(channels[firestartsound], false);
2740 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2742 if(Button()&&!oldbutton&&selected==1){
2743 float gLoc[3]={0,0,0};
2744 float vel[3]={0,0,0};
2745 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2746 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2747 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2748 OPENAL_SetVolume(channels[fireendsound], 256);
2749 OPENAL_SetPaused(channels[fireendsound], false);
2750 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2758 for(i=accountactive;i<numaccounts-1;i++){
2759 accountdifficulty[i]=accountdifficulty[i+1];
2760 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2761 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2762 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2764 accountpoints[i]=accountpoints[i+1];
2766 accounthighscore[i][j]=accounthighscore[i+1][j];
2767 accountfasttime[i][j]=accountfasttime[i+1][j];
2770 accountunlocked[i][j]=accountunlocked[i+1][j];
2773 accountname[i][j]=accountname[i+1][j];
2775 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2776 accountprogress[i]=accountprogress[i+1];
2777 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2778 accountcampaignscore[i]=accountcampaignscore[i+1];
2779 accountcampaigntime[i]=accountcampaigntime[i+1];
2788 if(Button()&&!oldbutton&&selected==2){
2789 float gLoc[3]={0,0,0};
2790 float vel[3]={0,0,0};
2791 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2792 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2793 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2794 OPENAL_SetVolume(channels[fireendsound], 256);
2795 OPENAL_SetPaused(channels[fireendsound], false);
2796 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2806 if(Button())oldbutton=1;
2810 if(Button()&&!oldbutton&&selected!=-1){
2811 float gLoc[3]={0,0,0};
2812 float vel[3]={0,0,0};
2813 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2814 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2815 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2816 OPENAL_SetVolume(channels[firestartsound], 256);
2817 OPENAL_SetPaused(channels[firestartsound], false);
2818 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2820 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2823 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2824 accountactive=selected-1;
2832 if(Button()&&!oldbutton&&selected==numaccounts+1){
2833 float gLoc[3]={0,0,0};
2834 float vel[3]={0,0,0};
2835 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2836 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2837 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2838 OPENAL_SetVolume(channels[fireendsound], 256);
2839 OPENAL_SetPaused(channels[fireendsound], false);
2840 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2851 displaytext[0][j]=' ';
2857 if(Button())oldbutton=1;
2861 if(Button()&&!oldbutton&&selected!=-1){
2862 float gLoc[3]={0,0,0};
2863 float vel[3]={0,0,0};
2864 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2865 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2866 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2867 OPENAL_SetVolume(channels[firestartsound], 256);
2868 OPENAL_SetPaused(channels[firestartsound], false);
2869 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2871 if(selected==0)accountdifficulty[accountactive]=0;
2872 if(selected==1)accountdifficulty[accountactive]=1;
2873 if(selected==2)accountdifficulty[accountactive]=2;
2884 if(Button())oldbutton=1;
2889 if(Button())oldbutton=1;
2892 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
2895 if(newdetail>2)newdetail=detail;
2896 if(newdetail<0)newdetail=detail;
2897 if(newscreenwidth<0)newscreenwidth=screenwidth;
2898 if(newscreenheight<0)newscreenheight=screenheight;
2900 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2901 opstream << "Screenwidth:\n";
2902 opstream << newscreenwidth;
2903 opstream << "\nScreenheight:\n";
2904 opstream << newscreenheight;
2905 opstream << "\nMouse sensitivity:\n";
2906 opstream << usermousesensitivity;
2907 opstream << "\nBlur(0,1):\n";
2908 opstream << ismotionblur;
2909 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2910 opstream << newdetail;
2911 opstream << "\nFloating jump:\n";
2912 opstream << floatjump;
2913 opstream << "\nMouse jump:\n";
2914 opstream << mousejump;
2915 opstream << "\nAmbient sound:\n";
2916 opstream << ambientsound;
2917 opstream << "\nBlood (0,1,2):\n";
2918 opstream << bloodtoggle;
2919 opstream << "\nAuto slomo:\n";
2920 opstream << autoslomo;
2921 opstream << "\nFoliage:\n";
2922 opstream << foliage;
2923 opstream << "\nMusic:\n";
2924 opstream << musictoggle;
2925 opstream << "\nTrilinear:\n";
2926 opstream << trilinear;
2927 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2929 opstream << "\nInvert mouse:\n";
2930 opstream << invertmouse;
2931 opstream << "\nGamespeed:\n";
2932 if(oldgamespeed==0)oldgamespeed=1;
2933 opstream << oldgamespeed;
2934 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2935 opstream << difficulty;
2936 opstream << "\nDamage effects(blackout, doublevision):\n";
2937 opstream << damageeffects;
2938 opstream << "\nText:\n";
2939 opstream << texttoggle;
2940 opstream << "\nDebug:\n";
2941 opstream << debugmode;
2942 opstream << "\nVBL Sync:\n";
2943 opstream << vblsync;
2944 opstream << "\nShow Points:\n";
2945 opstream << showpoints;
2946 opstream << "\nAlways Blur:\n";
2947 opstream << alwaysblur;
2948 opstream << "\nImmediate mode (turn on on G5):\n";
2949 opstream << immediate;
2950 opstream << "\nVelocity blur:\n";
2951 opstream << velocityblur;
2952 opstream << "\nVolume:\n";
2954 opstream << "\nForward key:\n";
2955 opstream << KeyToChar(forwardkey);
2956 opstream << "\nBack key:\n";
2957 opstream << KeyToChar(backkey);
2958 opstream << "\nLeft key:\n";
2959 opstream << KeyToChar(leftkey);
2960 opstream << "\nRight key:\n";
2961 opstream << KeyToChar(rightkey);
2962 opstream << "\nJump key:\n";
2963 opstream << KeyToChar(jumpkey);
2964 opstream << "\nCrouch key:\n";
2965 opstream << KeyToChar(crouchkey);
2966 opstream << "\nDraw key:\n";
2967 opstream << KeyToChar(drawkey);
2968 opstream << "\nThrow key:\n";
2969 opstream << KeyToChar(throwkey);
2970 opstream << "\nAttack key:\n";
2971 opstream << KeyToChar(attackkey);
2972 opstream << "\nChat key:\n";
2973 opstream << KeyToChar(chatkey);
2978 if(mainmenu==1||mainmenu==2){
2979 if(loaddistrib>4)transition+=multiplier/8;
2987 OPENAL_SetFrequency(channels[stream_music3], 22050);
2991 if(IsKeyDown(theKeyMap, i)){
2992 togglekeydelay[i]+=multiplier;
2993 if(togglekeydelay[i]>.4){
2995 togglekeydelay[i]=.36;
2998 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
2999 for(j=255;j>=displayselected+1;j--){
3000 displaytext[0][j]=displaytext[0][j-1];
3002 displaytext[0][displayselected]=KeyToSingleChar(i);
3003 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3007 if(i==MAC_DELETE_KEY&&displayselected!=0){
3008 for(j=displayselected-1;j<255;j++){
3009 displaytext[0][j]=displaytext[0][j+1];
3011 displaytext[0][255]=' ';
3015 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3018 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3021 if(i==MAC_RETURN_KEY&&entername){
3022 if(displaychars[0]){
3024 strcpy(accountname[numaccounts-1],displaytext[0]);
3025 accountactive=numaccounts-1;
3026 accountdifficulty[accountactive]=1;
3027 accountprogress[accountactive]=0;
3028 accountpoints[accountactive]=0;
3029 accountcampaigntime[accountactive]=0;
3030 accountcampaignscore[accountactive]=0;
3031 accountcampaignfasttime[accountactive]=0;
3032 accountcampaignhighscore[accountactive]=0;
3034 accounthighscore[accountactive][j]=0;
3035 accountfasttime[accountactive][j]=0;
3038 accountunlocked[accountactive][j]=0;
3040 accountcampaignchoicesmade[accountactive]=0;
3043 displaytext[0][j]=' ';
3057 float gLoc[3]={0,0,0};
3058 float vel[3]={0,0,0};
3059 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3060 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3061 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3062 OPENAL_SetVolume(channels[firestartsound], 256);
3063 OPENAL_SetPaused(channels[firestartsound], false);
3064 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3067 displaytext[0][j]=' ';
3075 if(i==MAC_RETURN_KEY&&mainmenu==13){
3076 if(displaychars[0]){
3077 sprintf (registrationname, "%s", displaytext[0]);
3078 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3088 float gLoc[3]={0,0,0};
3089 float vel[3]={0,0,0};
3090 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3091 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3092 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3093 OPENAL_SetVolume(channels[firestartsound], 256);
3094 OPENAL_SetPaused(channels[firestartsound], false);
3095 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3098 displaytext[0][j]=' ';
3109 togglekeydelay[i]=0;
3113 displayblinkdelay-=multiplier;
3114 if(displayblinkdelay<=0){
3115 displayblinkdelay=.3;
3116 displayblink=1-displayblink;
3122 if(hostile==1)hostiletime+=multiplier;
3124 if(!winfreeze)leveltime+=multiplier;
3125 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3132 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3134 chattogglekeydown=1;
3135 togglekey[chatkey]=1;
3136 togglekeydelay[chatkey]=-20;
3139 if(!IsKeyDown(theKeyMap, chatkey)){
3140 chattogglekeydown=0;
3145 if(IsKeyDown(theKeyMap, i)){
3146 togglekeydelay[i]+=multiplier;
3147 if(togglekeydelay[i]>.4){
3149 togglekeydelay[i]=.36;
3152 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3153 for(j=255;j>=displayselected+1;j--){
3154 displaytext[0][j]=displaytext[0][j-1];
3156 displaytext[0][displayselected]=KeyToSingleChar(i);
3157 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3161 if(i==MAC_DELETE_KEY&&displayselected!=0){
3162 for(j=displayselected-1;j<255;j++){
3163 displaytext[0][j]=displaytext[0][j+1];
3165 displaytext[0][255]=' ';
3169 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3172 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3175 if(i==MAC_RETURN_KEY){
3176 if(displaychars[0]){
3177 /*for(j=0;j<displaychars[0];j++){
3178 talkname[j]=displaytext[0][j];
3180 talkname[displaychars[0]]='\0';
3181 sprintf (chatname, "%s: %s",playerName,talkname);
3182 //NetworkSendInformation(chatname);
3185 displaytext[0][j]=' ';
3197 togglekeydelay[i]=0;
3201 displayblinkdelay-=multiplier;
3202 if(displayblinkdelay<=0){
3203 displayblinkdelay=.3;
3204 displayblink=1-displayblink;
3208 if(chatting)keyboardfrozen=1;
3210 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3213 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3215 freezetogglekeydown=1;
3218 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3219 freezetogglekeydown=0;
3222 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3224 if(!console)freeze=0;
3226 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3228 consoletogglekeydown=1;
3231 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3232 consoletogglekeydown=0;
3235 if(console)freeze=1;
3237 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3239 if(IsKeyDown(theKeyMap, i)){
3240 togglekeydelay[i]+=multiplier;
3241 if(togglekeydelay[i]>.4){
3243 togglekeydelay[i]=.36;
3246 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3247 for(j=255;j>=consoleselected+1;j--){
3248 consoletext[0][j]=consoletext[0][j-1];
3250 consoletext[0][consoleselected]=KeyToSingleChar(i);
3251 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3255 else if(i==MAC_ENTER_KEY){
3256 for(j=255;j>=consoleselected+1;j--){
3257 consoletext[0][j]=consoletext[0][j-1];
3259 consoletext[0][consoleselected]='\n';
3263 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3264 for(j=consoleselected-1;j<255;j++){
3265 consoletext[0][j]=consoletext[0][j+1];
3267 consoletext[0][255]=' ';
3271 if(i==MAC_ARROW_UP_KEY){
3272 if(archiveselected<14)archiveselected++;
3274 consolechars[0]=consolechars[archiveselected];
3275 consoletext[0][j]=consoletext[archiveselected][j];
3276 consoleselected=consolechars[0];
3279 if(i==MAC_ARROW_DOWN_KEY){
3280 if(archiveselected>0)archiveselected--;
3282 consolechars[0]=consolechars[archiveselected];
3283 consoletext[0][j]=consoletext[archiveselected][j];
3284 consoleselected=consolechars[0];
3287 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3290 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3293 if(i==MAC_RETURN_KEY){
3296 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3297 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3298 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3299 OPENAL_SetPaused(channels[consolesuccesssound], false);
3303 /*if(Compare(consoletext[0],"send ",0,4)){
3304 for(j=5;j<consolechars[0];j++){
3305 talkname[j-5]=consoletext[0][j];
3307 talkname[consolechars[0]-5]='\0';
3308 sprintf (chatname, "%s: %s",playerName,talkname);
3309 //NetworkSendInformation(chatname);
3312 if(Compare(consoletext[0],"name ",0,4)){
3314 numchars=consolechars[0]-5;
3315 if(numchars>32)numchars=32;
3316 for(j=5;j<numchars+5;j++){
3317 talkname[j-5]=consoletext[0][j];
3319 talkname[numchars]='\0';
3320 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3321 //NetworkSendInformation(chatname);
3322 sprintf (playerName, "%s",talkname);
3323 //NetworkSendName(playerName);
3326 if(Compare(consoletext[0],"map ",0,3)){
3338 for(j=4;j<consolechars[0];j++){
3339 mapname[j-4+11]=consoletext[0][j];
3341 mapname[consolechars[0]-4+11]='\0';
3347 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3349 unsigned char playerNameStr[32];
3350 char theIPAddress[256];
3352 NMUInt32 port = 25710;
3354 strcpy(playerName, "Client");
3355 GameC2PStr( playerName, playerNameStr );
3357 for(j=0;j<consolechars[0]-8;j++){
3358 theIPAddress[j]=consoletext[0][j+8];
3360 theIPAddress[consolechars[0]-8]='\0';
3362 sprintf( thePort, "%li", port );
3363 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3366 if(consolechars[0]>0){
3369 consoletext[k][j]=consoletext[k-1][j];
3371 consolechars[k]=consolechars[k-1];
3374 consoletext[0][j]=' ';
3376 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3377 else sprintf (consoletext[0], "Could not open connection");
3379 consolechars[0]=255;
3386 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3387 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3388 OPENAL_SetPaused(channels[consolesuccesssound], false);
3390 if(consolechars[0]>0){
3393 consoletext[k][j]=consoletext[k-1][j];
3395 consolechars[k]=consolechars[k-1];
3398 consoletext[0][j]=' ';
3400 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3402 consolechars[0]=255;
3408 if(Compare(consoletext[0],"host ",0,4)){
3409 unsigned char gameNameStr[32], playerNameStr[32];
3410 char gameName[32];//, playerName[32];
3418 strcpy(gameName, "Host's game");
3419 strcpy(playerName, "Host");
3420 GameC2PStr( gameName, gameNameStr );
3421 GameC2PStr( playerName, playerNameStr );
3423 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3426 if(consolechars[0]>0){
3429 consoletext[k][j]=consoletext[k-1][j];
3431 consolechars[k]=consolechars[k-1];
3434 consoletext[0][j]=' ';
3436 sprintf (consoletext[0], "Error #%d!!!",v);
3438 consolechars[0]=255;
3445 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3446 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3447 OPENAL_SetPaused(channels[consolesuccesssound], false);
3449 if(consolechars[0]>0){
3452 consoletext[k][j]=consoletext[k-1][j];
3454 consolechars[k]=consolechars[k-1];
3457 consoletext[0][j]=' ';
3459 sprintf (consoletext[0], "Game hosted");
3461 consolechars[0]=255;
3467 if(Compare(consoletext[0],"save ",0,4)){
3479 for(j=5;j<consolechars[0];j++){
3480 mapname[j-5+11]=consoletext[0][j];
3482 mapname[consolechars[0]-5+11]='\0';
3484 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3485 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3486 OPENAL_SetPaused(channels[consolesuccesssound], false);
3493 tfile=fopen( mapname, "wb" );
3494 fpackf(tfile, "Bi", mapvers);
3495 //fpackf(tfile, "Bi", indemo);
3496 fpackf(tfile, "Bi", maptype);
3497 fpackf(tfile, "Bi", hostile);
3498 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3499 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3500 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3501 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);
3502 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3503 for(j=0;j<player[0].num_weapons;j++){
3504 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3507 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3508 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3509 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3510 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3512 fpackf(tfile, "Bi", player[0].numclothes);
3514 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3516 fpackf(tfile, "Bi", numdialogues);
3518 for(k=0;k<numdialogues;k++){
3519 fpackf(tfile, "Bi", numdialogueboxes[k]);
3520 fpackf(tfile, "Bi", dialoguetype[k]);
3522 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3523 fpackf(tfile, "Bf", participantrotation[k][l]);
3525 if(numdialogueboxes)
3526 for(l=0;l<numdialogueboxes[k];l++){
3527 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3528 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3529 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3530 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3531 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3533 templength=strlen(dialoguetext[k][l]);
3534 fpackf(tfile, "Bi",(templength));
3535 for(m=0;m<templength;m++){
3536 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3537 if(dialoguetext[k][l][m]=='\0')break;
3540 templength=strlen(dialoguename[k][l]);
3541 fpackf(tfile, "Bi",templength);
3542 for(m=0;m<templength;m++){
3543 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3544 if(dialoguename[k][l][m]=='\0')break;
3547 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3548 fpackf(tfile, "Bi", participantfocus[k][l]);
3549 fpackf(tfile, "Bi", participantaction[k][l]);
3552 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3554 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3558 if(player[0].numclothes)
3559 for(k=0;k<player[0].numclothes;k++){
3560 templength=strlen(player[0].clothes[k]);
3561 fpackf(tfile, "Bi", templength);
3562 for(l=0;l<templength;l++)
3563 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3564 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3567 fpackf(tfile, "Bi", environment);
3569 fpackf(tfile, "Bi", objects.numobjects);
3571 if(objects.numobjects)
3572 for(k=0;k<objects.numobjects;k++){
3573 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]);
3576 fpackf(tfile, "Bi", numhotspots);
3578 for(i=0;i<numhotspots;i++){
3579 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3580 templength=strlen(hotspottext[i]);
3581 fpackf(tfile, "Bi",templength);
3582 for(l=0;l<templength;l++)
3583 fpackf(tfile, "Bb", hotspottext[i][l]);
3586 fpackf(tfile, "Bi", numplayers);
3587 if(numplayers>1&&numplayers<maxplayers)
3588 for(j=1;j<numplayers;j++){
3589 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);
3590 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3591 for(k=0;k<player[j].num_weapons;k++){
3592 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3594 if(player[j].numwaypoints<30){
3595 fpackf(tfile, "Bi", player[j].numwaypoints);
3596 for(k=0;k<player[j].numwaypoints;k++){
3597 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3598 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3599 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3600 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3602 fpackf(tfile, "Bi", player[j].waypoint);
3605 player[j].numwaypoints=0;
3606 player[j].waypoint=0;
3607 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3610 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3611 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3612 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3613 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3615 if(player[j].creature==wolftype){
3616 headprop=player[j].proportionhead.x/1.1;
3617 bodyprop=player[j].proportionbody.x/1.1;
3618 armprop=player[j].proportionarms.x/1.1;
3619 legprop=player[j].proportionlegs.x/1.1;
3622 if(player[j].creature==rabbittype){
3623 headprop=player[j].proportionhead.x/1.2;
3624 bodyprop=player[j].proportionbody.x/1.05;
3625 armprop=player[j].proportionarms.x/1.00;
3626 legprop=player[j].proportionlegs.x/1.1;
3629 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3633 fpackf(tfile, "Bi", player[j].numclothes);
3634 if(player[j].numclothes)
3635 for(k=0;k<player[j].numclothes;k++){
3637 templength=strlen(player[j].clothes[k]);
3638 fpackf(tfile, "Bi", templength);
3639 for(l=0;l<templength;l++)
3640 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3641 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3645 fpackf(tfile, "Bi", numpathpoints);
3647 for(j=0;j<numpathpoints;j++){
3648 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3649 for(k=0;k<numpathpointconnect[j];k++){
3650 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3654 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3662 tfile=fopen( mapname, "wb" );
3663 fwrite( &mapvers, 1, sizeof(int), tfile );
3664 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3665 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3666 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3667 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3668 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3669 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3670 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3671 for(j=0;j<player[0].num_weapons;j++){
3672 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3675 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3676 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3677 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3678 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3679 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3680 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3681 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3682 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3683 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3684 fwrite( &player[0].power, 1, sizeof(int), tfile );
3685 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3687 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3688 if(player[0].numclothes)
3689 for(k=0;k<player[0].numclothes;k++){
3691 templength=strlen(player[0].clothes[k]);
3692 fwrite( &templength,1,sizeof(int),tfile);
3693 for(l=0;l<templength;l++)
3694 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3695 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3696 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3697 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3700 fwrite( &environment, 1, sizeof(int), tfile );
3702 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3704 for(k=0;k<objects.numobjects;k++){
3705 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3706 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
3707 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
3708 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
3709 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
3710 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
3711 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
3714 fwrite( &numplayers, 1, sizeof(int), tfile );
3715 if(numplayers>1&&numplayers<maxplayers)
3716 for(j=1;j<numplayers;j++){
3717 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
3718 fwrite( &player[j].creature, 1, sizeof(int), tfile );
3719 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
3720 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
3721 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
3722 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3723 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3724 for(k=0;k<player[j].num_weapons;k++){
3725 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3727 if(player[j].numwaypoints<30){
3728 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3729 for(k=0;k<player[j].numwaypoints;k++){
3730 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
3731 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
3732 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
3734 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3735 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3738 player[j].numwaypoints=0;
3739 player[j].waypoint=0;
3740 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3741 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3742 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3744 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
3745 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
3746 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
3747 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
3748 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
3749 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
3750 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
3751 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
3752 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
3753 fwrite( &player[j].power, 1, sizeof(int), tfile );
3754 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
3756 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
3757 if(player[j].numclothes)
3758 for(k=0;k<player[j].numclothes;k++){
3760 templength=strlen(player[j].clothes[k]);
3761 fwrite( &templength,1,sizeof(int),tfile);
3762 for(l=0;l<templength;l++)
3763 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
3764 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
3765 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
3766 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
3769 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3771 for(j=0;j<numpathpoints;j++){
3772 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
3773 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
3774 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
3775 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3776 for(k=0;k<numpathpointconnect[j];k++){
3777 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3781 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
3782 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
3783 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
3785 fwrite( &mapradius, 1, sizeof(float), tfile );
3791 if(Compare(consoletext[0],"save ",0,4)){
3803 for(j=5;j<consolechars[0];j++){
3804 mapname[j-5+11]=consoletext[0][j];
3806 mapname[consolechars[0]-5+11]='\0';
3808 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3809 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3810 OPENAL_SetPaused(channels[consolesuccesssound], false);
3813 tfile=fopen( mapname, "wb" );
3814 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
3815 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3816 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3817 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3818 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3819 for(j=0;j<player[0].num_weapons;j++){
3820 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3822 fwrite( &environment, 1, sizeof(int), tfile );
3824 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3825 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
3826 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
3827 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
3828 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
3830 fwrite( &numplayers, 1, sizeof(int), tfile );
3831 if(numplayers>1&&numplayers<maxplayers)
3832 for(j=1;j<numplayers;j++){
3833 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
3834 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
3835 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3836 for(k=0;k<player[j].num_weapons;k++){
3837 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
3839 if(player[j].numwaypoints<30){
3840 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3841 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
3842 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3843 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
3846 player[j].numwaypoints=0;
3847 player[j].waypoint=0;
3848 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
3849 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3850 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
3853 fwrite( &numpathpoints, 1, sizeof(int), tfile );
3855 for(j=0;j<numpathpoints;j++){
3856 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
3857 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
3858 for(k=0;k<numpathpointconnect[j];k++){
3859 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
3865 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
3866 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
3869 /*if(Compare(consoletext[0],"Pants ",0,5)){
3870 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
3871 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
3875 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
3876 for(j=6;j<consolechars[0];j++){
3877 mapname[j-6]=consoletext[0][j];
3880 tintr=atof(mapname);
3885 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
3886 for(j=6;j<consolechars[0];j++){
3887 mapname[j-6]=consoletext[0][j];
3890 player[0].speedmult=atof(mapname);
3895 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
3896 for(j=9;j<consolechars[0];j++){
3897 mapname[j-9]=consoletext[0][j];
3900 player[0].power=atof(mapname);
3905 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
3906 for(j=13;j<consolechars[0];j++){
3907 mapname[j-13]=consoletext[0][j];
3910 viewdistance=atof(mapname)*100;
3915 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
3916 for(j=10;j<consolechars[0];j++){
3917 mapname[j-10]=consoletext[0][j];
3920 fadestart=atof(mapname);
3925 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
3926 for(j=6;j<consolechars[0];j++){
3927 mapname[j-6]=consoletext[0][j];
3930 player[0].power=atof(mapname);
3935 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
3936 for(j=6;j<consolechars[0];j++){
3937 mapname[j-6]=consoletext[0][j];
3940 slomospeed=atof(mapname);
3947 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
3948 for(j=8;j<consolechars[0];j++){
3949 mapname[j-8]=consoletext[0][j];
3952 slomofreq=atoi(mapname);
3957 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
3958 for(j=5;j<consolechars[0];j++){
3959 mapname[j-5]=consoletext[0][j];
3962 player[0].scale=atof(mapname)*.2;
3967 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
3969 float closestdist=-1;
3972 for(i=1;i<numplayers;i++){
3973 distance=findDistancefast(&player[i].coords,&player[0].coords);
3974 if(closestdist==-1||distance<closestdist){
3975 closestdist=distance;
3980 for(j=9;j<consolechars[0];j++){
3981 mapname[j-9]=consoletext[0][j];
3984 player[closest].scale=atof(mapname)*.2;
3989 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
3994 float closestdist=-1;
3997 for(i=1;i<numplayers;i++){
3998 distance=findDistancefast(&player[i].coords,&player[0].coords);
3999 if(closestdist==-1||distance<closestdist){
4000 closestdist=distance;
4008 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4009 mapname[j-startpoint]=consoletext[0][j];
4011 if(consoletext[0][j]=='\0')alldone=1;
4013 mapname[j-startpoint]='\0';
4015 headprop=atof(mapname);
4019 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4020 mapname[j-startpoint]=consoletext[0][j];
4022 if(consoletext[0][j]=='\0')alldone=1;
4024 mapname[j-startpoint]='\0';
4026 bodyprop=atof(mapname);
4030 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4031 mapname[j-startpoint]=consoletext[0][j];
4033 if(consoletext[0][j]=='\0')alldone=1;
4035 mapname[j-startpoint]='\0';
4037 armprop=atof(mapname);
4041 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4042 mapname[j-startpoint]=consoletext[0][j];
4044 if(consoletext[0][j]=='\0')alldone=1;
4046 mapname[j-startpoint]='\0';
4048 legprop=atof(mapname);
4050 if(player[closest].creature==wolftype){
4051 player[closest].proportionhead=1.1*headprop;
4052 player[closest].proportionbody=1.1*bodyprop;
4053 player[closest].proportionarms=1.1*armprop;
4054 player[closest].proportionlegs=1.1*legprop;
4057 if(player[closest].creature==rabbittype){
4058 player[closest].proportionhead=1.2*headprop;
4059 player[closest].proportionbody=1.05*bodyprop;
4060 player[closest].proportionarms=1.00*armprop;
4061 player[closest].proportionlegs=1.1*legprop;
4062 player[closest].proportionlegs.y=1.05*legprop;
4069 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4070 for(i=1;i<numplayers;i++){
4071 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4077 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4078 for(j=9;j<consolechars[0];j++){
4079 mapname[j-9]=consoletext[0][j];
4082 tutoriallevel=atoi(mapname);
4088 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4089 for(j=6;j<consolechars[0];j++){
4090 mapname[j-6]=consoletext[0][j];
4093 tintg=atof(mapname);
4098 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4099 for(j=6;j<consolechars[0];j++){
4100 mapname[j-6]=consoletext[0][j];
4103 tintb=atof(mapname);
4108 if(Compare(consoletext[0],"hostile ",0,7)){
4109 for(j=8;j<consolechars[0];j++){
4110 mapname[j-8]=consoletext[0][j];
4113 hostile=atoi(mapname);
4119 if(Compare(consoletext[0],"type active ",0,11)){
4120 editoractive=typeactive;
4125 if(Compare(consoletext[0],"indemo ",0,6)){
4127 hotspot[numhotspots]=player[0].coords;
4128 hotspotsize[numhotspots]=0;
4129 hotspottype[numhotspots]=-111;
4131 strcpy(hotspottext[numhotspots],"mapname");
4137 if(Compare(consoletext[0],"notindemo ",0,9)){
4144 if(Compare(consoletext[0],"type sitting ",0,12)){
4145 editoractive=typesitting;
4150 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4151 editoractive=typesittingwall;
4156 if(Compare(consoletext[0],"type sleeping ",0,13)){
4157 editoractive=typesleeping;
4161 if(Compare(consoletext[0],"type dead1 ",0,10)){
4162 editoractive=typedead1;
4166 if(Compare(consoletext[0],"type dead2 ",0,10)){
4167 editoractive=typedead2;
4171 if(Compare(consoletext[0],"type dead3 ",0,10)){
4172 editoractive=typedead3;
4175 if(Compare(consoletext[0],"type dead4 ",0,10)){
4176 editoractive=typedead4;
4181 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4182 editorpathtype=wpkeepwalking;
4187 if(Compare(consoletext[0],"path pause ",0,10)){
4188 editorpathtype=wppause;
4193 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4194 maptype=mapkilleveryone;
4199 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4200 maptype=mapgosomewhere;
4205 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4206 maptype=mapkillsomeone;
4212 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4213 maptype=mapkillmost;
4219 if(Compare(consoletext[0],"hs ",0,2)){
4223 hotspot[numhotspots]=player[0].coords;
4228 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4229 mapname[j-startpoint]=consoletext[0][j];
4231 if(consoletext[0][j]=='\0')alldone=1;
4233 mapname[j-startpoint]='\0';
4235 hotspotsize[numhotspots]=atof(mapname);
4239 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4240 mapname[j-startpoint]=consoletext[0][j];
4242 if(consoletext[0][j]=='\0')alldone=1;
4244 mapname[j-startpoint]='\0';
4246 hotspottype[numhotspots]=atoi(mapname);
4250 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4251 mapname[j-startpoint]=consoletext[0][j];
4253 if(consoletext[0][j]=='\0')alldone=1;
4255 mapname[j-startpoint]='\n';
4256 mapname[j-startpoint+1]='\0';
4258 strcpy(hotspottext[numhotspots],mapname);
4265 if(Compare(consoletext[0],"dialogue ",0,8)){
4272 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4273 mapname[j-startpoint]=consoletext[0][j];
4275 if(consoletext[0][j]=='\0')alldone=1;
4277 mapname[j-startpoint]='\0';
4280 dialoguetype[numdialogues]=atoi(mapname);
4298 for(j=startpoint;j<consolechars[0];j++){
4299 mapname[j-startpoint+16]=consoletext[0][j];
4301 mapname[consolechars[0]-startpoint+16]='.';
4302 mapname[consolechars[0]-startpoint+17]='t';
4303 mapname[consolechars[0]-startpoint+18]='x';
4304 mapname[consolechars[0]-startpoint+19]='t';
4305 mapname[consolechars[0]-startpoint+20]='\0';
4307 for(j=0;j<max_dialoguelength;j++){
4309 dialoguetext[numdialogues][j][k]='\0';
4312 dialoguename[numdialogues][j][k]='\0';
4316 ifstream ipstream(ConvertFileName(mapname));
4317 ipstream.ignore(256,':');
4318 ipstream >> numdialogueboxes[numdialogues];
4319 for(i=0;i<numdialogueboxes[numdialogues];i++){
4320 ipstream.ignore(256,':');
4321 ipstream.ignore(256,':');
4322 ipstream.ignore(256,' ');
4323 ipstream >> dialogueboxlocation[numdialogues][i];
4324 ipstream.ignore(256,':');
4325 ipstream >> dialogueboxcolor[numdialogues][i][0];
4326 ipstream >> dialogueboxcolor[numdialogues][i][1];
4327 ipstream >> dialogueboxcolor[numdialogues][i][2];
4328 ipstream.ignore(256,':');
4329 ipstream.getline(dialoguename[numdialogues][i],64);
4330 ipstream.ignore(256,':');
4331 ipstream.ignore(256,' ');
4332 ipstream.getline(dialoguetext[numdialogues][i],128);
4334 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4336 ipstream.ignore(256,':');
4337 ipstream >> dialogueboxsound[numdialogues][i];
4340 for(i=0;i<numdialogueboxes[numdialogues];i++){
4341 for(j=0;j<numplayers;j++){
4342 participantfacing[numdialogues][i][j]=player[j].facing;
4349 whichdialogue=numdialogues;
4357 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4365 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4366 mapname[j-startpoint]=consoletext[0][j];
4368 if(consoletext[0][j]=='\0')alldone=1;
4370 mapname[j-startpoint]='\0';
4373 whichdi=atoi(mapname);
4391 for(j=startpoint;j<consolechars[0];j++){
4392 mapname[j-startpoint+16]=consoletext[0][j];
4394 mapname[consolechars[0]-startpoint+16]='.';
4395 mapname[consolechars[0]-startpoint+17]='t';
4396 mapname[consolechars[0]-startpoint+18]='x';
4397 mapname[consolechars[0]-startpoint+19]='t';
4398 mapname[consolechars[0]-startpoint+20]='\0';
4400 for(j=0;j<max_dialoguelength;j++){
4402 dialoguetext[whichdi][j][k]='\0';
4405 dialoguename[whichdi][j][k]='\0';
4409 ifstream ipstream(ConvertFileName(mapname));
4410 ipstream.ignore(256,':');
4411 ipstream >> numdialogueboxes[whichdi];
4412 for(i=0;i<numdialogueboxes[whichdi];i++){
4413 ipstream.ignore(256,':');
4414 ipstream.ignore(256,':');
4415 ipstream.ignore(256,' ');
4416 ipstream >> dialogueboxlocation[whichdi][i];
4417 ipstream.ignore(256,':');
4418 ipstream >> dialogueboxcolor[whichdi][i][0];
4419 ipstream >> dialogueboxcolor[whichdi][i][1];
4420 ipstream >> dialogueboxcolor[whichdi][i][2];
4421 ipstream.ignore(256,':');
4422 ipstream.getline(dialoguename[whichdi][i],64);
4423 ipstream.ignore(256,':');
4424 ipstream.ignore(256,' ');
4425 ipstream.getline(dialoguetext[whichdi][i],128);
4427 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4429 ipstream.ignore(256,':');
4430 ipstream >> dialogueboxsound[whichdi][i];
4438 if(Compare(consoletext[0],"fixtype ",0,7)){
4446 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4447 mapname[j-startpoint]=consoletext[0][j];
4449 if(consoletext[0][j]=='\0')alldone=1;
4451 mapname[j-startpoint]='\0';
4452 dialoguetype[0]=atoi(mapname);
4460 if(Compare(consoletext[0],"fixrotation ",0,11)){
4461 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4466 if(Compare(consoletext[0],"ddialogue ",0,9)){
4468 if(numdialogues<0)numdialogues=0;
4473 if(Compare(consoletext[0],"immobile ",0,8)){
4474 player[0].immobile=1;
4478 if(Compare(consoletext[0],"mobile ",0,6)){
4479 player[0].immobile=0;
4483 if(Compare(consoletext[0],"play ",0,4)){
4490 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4491 mapname[j-startpoint]=consoletext[0][j];
4493 if(consoletext[0][j]=='\0')alldone=1;
4495 mapname[j-startpoint]='\0';
4498 whichdialogue=atoi(mapname);
4500 if(numdialogues>whichdialogue){
4501 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4502 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4503 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4504 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4505 player[participantfocus[whichdialogue][i]].velocity=0;
4506 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4507 player[participantfocus[whichdialogue][i]].targetframe=0;
4515 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4519 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4520 temppos=temppos-viewer;
4521 Normalise(&temppos);
4531 whichsoundplay=rabbitchitter;
4532 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4533 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4534 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4535 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4536 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4537 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4538 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4539 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4540 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4541 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4542 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4543 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4544 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4545 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4546 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4547 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4548 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4549 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4550 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4551 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4552 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4553 OPENAL_SetVolume(channels[whichsoundplay], 256);
4554 OPENAL_SetPaused(channels[whichsoundplay], false);
4562 if(Compare(consoletext[0],"dhs ",0,3)){
4564 if(numhotspots<0)numhotspots=0;
4569 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4576 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4577 mapname[j-startpoint]=consoletext[0][j];
4579 if(consoletext[0][j]=='\0')alldone=1;
4581 mapname[j-startpoint]='\0';
4583 headprop=atof(mapname);
4587 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4588 mapname[j-startpoint]=consoletext[0][j];
4590 if(consoletext[0][j]=='\0')alldone=1;
4592 mapname[j-startpoint]='\0';
4594 bodyprop=atof(mapname);
4598 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4599 mapname[j-startpoint]=consoletext[0][j];
4601 if(consoletext[0][j]=='\0')alldone=1;
4603 mapname[j-startpoint]='\0';
4605 armprop=atof(mapname);
4609 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4610 mapname[j-startpoint]=consoletext[0][j];
4612 if(consoletext[0][j]=='\0')alldone=1;
4614 mapname[j-startpoint]='\0';
4616 legprop=atof(mapname);
4618 if(player[0].creature==wolftype){
4619 player[0].proportionhead=1.1*headprop;
4620 player[0].proportionbody=1.1*bodyprop;
4621 player[0].proportionarms=1.1*armprop;
4622 player[0].proportionlegs=1.1*legprop;
4625 if(player[0].creature==rabbittype){
4626 player[0].proportionhead=1.2*headprop;
4627 player[0].proportionbody=1.05*bodyprop;
4628 player[0].proportionarms=1.00*armprop;
4629 player[0].proportionlegs=1.1*legprop;
4630 player[0].proportionlegs.y=1.05*legprop;
4636 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4637 for(i=0;i<numplayers;i++){
4638 if(i>0)player[i].immobile=1;
4644 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4645 player[0].armorhead=1;
4646 player[0].armorhigh=1;
4647 player[0].armorlow=1;
4648 player[0].protectionhead=1;
4649 player[0].protectionhigh=1;
4650 player[0].protectionlow=1;
4651 player[0].metalhead=1;
4652 player[0].metalhigh=1;
4653 player[0].metallow=1;
4655 player[0].speedmult=1;
4658 if(player[0].creature==wolftype){
4659 player[0].proportionhead=1.1;
4660 player[0].proportionbody=1.1;
4661 player[0].proportionarms=1.1;
4662 player[0].proportionlegs=1.1;
4665 if(player[0].creature==rabbittype){
4666 player[0].proportionhead=1.2;
4667 player[0].proportionbody=1.05;
4668 player[0].proportionarms=1.00;
4669 player[0].proportionlegs=1.1;
4670 player[0].proportionlegs.y=1.05;
4673 player[0].numclothes=0;
4674 if(player[0].whichskin==0){
4675 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4677 else if(player[0].whichskin==1){
4678 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4680 else if(player[0].whichskin==2){
4681 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4683 else if(player[0].whichskin==3){
4684 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4686 else if(player[0].whichskin==4){
4687 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4689 else if(player[0].whichskin==5){
4690 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4692 else if(player[0].whichskin==6){
4693 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4695 else if(player[0].whichskin==7){
4696 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4698 else if(player[0].whichskin==8){
4699 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4701 else if(player[0].whichskin==9){
4702 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4705 editoractive=typeactive;
4706 player[0].immobile=0;
4713 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
4719 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4720 mapname[j-startpoint]=consoletext[0][j];
4722 if(consoletext[0][j]=='\0')alldone=1;
4724 mapname[j-startpoint]='\0';
4726 tintr=atof(mapname);
4730 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4731 mapname[j-startpoint]=consoletext[0][j];
4733 if(consoletext[0][j]=='\0')alldone=1;
4735 mapname[j-startpoint]='\0';
4737 tintg=atof(mapname);
4741 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4742 mapname[j-startpoint]=consoletext[0][j];
4744 if(consoletext[0][j]=='\0')alldone=1;
4746 mapname[j-startpoint]='\0';
4748 tintb=atof(mapname);
4753 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
4759 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4760 mapname[j-startpoint]=consoletext[0][j];
4762 if(consoletext[0][j]=='\0')alldone=1;
4764 mapname[j-startpoint]='\0';
4766 skyboxr=atof(mapname);
4770 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4771 mapname[j-startpoint]=consoletext[0][j];
4773 if(consoletext[0][j]=='\0')alldone=1;
4775 mapname[j-startpoint]='\0';
4777 skyboxg=atof(mapname);
4781 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4782 mapname[j-startpoint]=consoletext[0][j];
4784 if(consoletext[0][j]=='\0')alldone=1;
4786 mapname[j-startpoint]='\0';
4788 skyboxb=atof(mapname);
4790 skyboxlightr=skyboxr;
4791 skyboxlightg=skyboxg;
4792 skyboxlightb=skyboxb;
4796 //if(skyboxtexture){
4797 terrain.DoShadows();
4798 objects.DoShadows();
4800 else terrain.DoLighting();
4805 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
4811 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4812 mapname[j-startpoint]=consoletext[0][j];
4814 if(consoletext[0][j]=='\0')alldone=1;
4816 mapname[j-startpoint]='\0';
4818 skyboxlightr=atof(mapname);
4822 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4823 mapname[j-startpoint]=consoletext[0][j];
4825 if(consoletext[0][j]=='\0')alldone=1;
4827 mapname[j-startpoint]='\0';
4829 skyboxlightg=atof(mapname);
4833 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4834 mapname[j-startpoint]=consoletext[0][j];
4836 if(consoletext[0][j]=='\0')alldone=1;
4838 mapname[j-startpoint]='\0';
4840 skyboxlightb=atof(mapname);
4844 //if(skyboxtexture){
4845 terrain.DoShadows();
4846 objects.DoShadows();
4848 else terrain.DoLighting();
4853 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
4854 skyboxtexture=1-skyboxtexture;
4857 //if(skyboxtexture){
4858 terrain.DoShadows();
4859 objects.DoShadows();
4861 else terrain.DoLighting();
4866 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
4872 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4873 mapname[j-startpoint]=consoletext[0][j];
4875 if(consoletext[0][j]=='\0')alldone=1;
4877 mapname[j-startpoint]='\0';
4879 player[0].protectionhead=atof(mapname);
4883 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4884 mapname[j-startpoint]=consoletext[0][j];
4886 if(consoletext[0][j]=='\0')alldone=1;
4888 mapname[j-startpoint]='\0';
4890 player[0].protectionhigh=atof(mapname);
4894 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4895 mapname[j-startpoint]=consoletext[0][j];
4897 if(consoletext[0][j]=='\0')alldone=1;
4899 mapname[j-startpoint]='\0';
4901 player[0].protectionlow=atof(mapname);
4906 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
4912 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4913 mapname[j-startpoint]=consoletext[0][j];
4915 if(consoletext[0][j]=='\0')alldone=1;
4917 mapname[j-startpoint]='\0';
4919 player[0].armorhead=atof(mapname);
4923 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4924 mapname[j-startpoint]=consoletext[0][j];
4926 if(consoletext[0][j]=='\0')alldone=1;
4928 mapname[j-startpoint]='\0';
4930 player[0].armorhigh=atof(mapname);
4934 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4935 mapname[j-startpoint]=consoletext[0][j];
4937 if(consoletext[0][j]=='\0')alldone=1;
4939 mapname[j-startpoint]='\0';
4941 player[0].armorlow=atof(mapname);
4946 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
4947 for(i=0;i<numplayers;i++){
4948 player[i].protectionhead=1.0;
4949 player[i].protectionhigh=1.0;
4950 player[i].protectionlow=1.0;
4951 player[i].armorhead=1.0;
4952 player[i].armorhigh=1.0;
4953 player[i].armorlow=1.0;
4959 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
4961 float closestdist=-1;
4964 for(i=1;i<numplayers;i++){
4965 distance=findDistancefast(&player[i].coords,&player[0].coords);
4966 if(closestdist==-1||distance<closestdist){
4967 closestdist=distance;
4977 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4978 mapname[j-startpoint]=consoletext[0][j];
4980 if(consoletext[0][j]=='\0')alldone=1;
4982 mapname[j-startpoint]='\0';
4984 player[closest].protectionhead=atof(mapname);
4988 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4989 mapname[j-startpoint]=consoletext[0][j];
4991 if(consoletext[0][j]=='\0')alldone=1;
4993 mapname[j-startpoint]='\0';
4995 player[closest].protectionhigh=atof(mapname);
4999 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5000 mapname[j-startpoint]=consoletext[0][j];
5002 if(consoletext[0][j]=='\0')alldone=1;
5004 mapname[j-startpoint]='\0';
5006 player[closest].protectionlow=atof(mapname);
5011 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5013 float closestdist=-1;
5016 for(i=1;i<numplayers;i++){
5017 distance=findDistancefast(&player[i].coords,&player[0].coords);
5018 if(closestdist==-1||distance<closestdist){
5019 closestdist=distance;
5028 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5029 mapname[j-startpoint]=consoletext[0][j];
5031 if(consoletext[0][j]=='\0')alldone=1;
5033 mapname[j-startpoint]='\0';
5035 player[closest].armorhead=atof(mapname);
5039 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5040 mapname[j-startpoint]=consoletext[0][j];
5042 if(consoletext[0][j]=='\0')alldone=1;
5044 mapname[j-startpoint]='\0';
5046 player[closest].armorhigh=atof(mapname);
5050 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5051 mapname[j-startpoint]=consoletext[0][j];
5053 if(consoletext[0][j]=='\0')alldone=1;
5055 mapname[j-startpoint]='\0';
5057 player[closest].armorlow=atof(mapname);
5063 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5069 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5070 mapname[j-startpoint]=consoletext[0][j];
5072 if(consoletext[0][j]=='\0')alldone=1;
5074 mapname[j-startpoint]='\0';
5076 player[0].metalhead=atof(mapname);
5080 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5081 mapname[j-startpoint]=consoletext[0][j];
5083 if(consoletext[0][j]=='\0')alldone=1;
5085 mapname[j-startpoint]='\0';
5087 player[0].metalhigh=atof(mapname);
5091 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5092 mapname[j-startpoint]=consoletext[0][j];
5094 if(consoletext[0][j]=='\0')alldone=1;
5097 mapname[j-startpoint]='\0';
5099 player[0].metallow=atof(mapname);
5104 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5106 float closestdist=-1;
5109 for(i=1;i<numplayers;i++){
5110 distance=findDistancefast(&player[i].coords,&player[0].coords);
5111 if(closestdist==-1||distance<closestdist){
5112 closestdist=distance;
5116 player[closest].numclothes=0;
5117 if(player[closest].whichskin==0){
5118 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5120 else if(player[closest].whichskin==1){
5121 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5123 else if(player[closest].whichskin==2){
5124 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5126 else if(player[closest].whichskin==3){
5127 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5129 else if(player[closest].whichskin==4){
5130 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5132 else if(player[closest].whichskin==5){
5133 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5135 else if(player[closest].whichskin==6){
5136 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5138 else if(player[closest].whichskin==7){
5139 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5141 else if(player[closest].whichskin==8){
5142 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5144 else if(player[closest].whichskin==9){
5145 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5151 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5154 player[closest].numclothes=0;
5155 if(player[closest].whichskin==0){
5156 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5158 else if(player[closest].whichskin==1){
5159 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5161 else if(player[closest].whichskin==2){
5162 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5164 else if(player[closest].whichskin==3){
5165 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5167 else if(player[closest].whichskin==4){
5168 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5170 else if(player[closest].whichskin==5){
5171 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5173 else if(player[closest].whichskin==6){
5174 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5176 else if(player[closest].whichskin==7){
5177 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5179 else if(player[closest].whichskin==8){
5180 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5182 else if(player[closest].whichskin==9){
5183 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5189 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5205 for(j=8;j<consolechars[0];j++){
5206 mapname[j-8+15]=consoletext[0][j];
5208 mapname[consolechars[0]-8+15]='.';
5209 mapname[consolechars[0]-8+16]='p';
5210 mapname[consolechars[0]-8+17]='n';
5211 mapname[consolechars[0]-8+18]='g';
5212 mapname[consolechars[0]-8+19]='\0';
5214 //:Data:Textures:Pants.png
5216 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5217 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5218 strcpy(player[0].clothes[player[0].numclothes],mapname);
5219 player[0].clothestintr[player[0].numclothes]=tintr;
5220 player[0].clothestintg[player[0].numclothes]=tintg;
5221 player[0].clothestintb[player[0].numclothes]=tintb;
5222 player[0].numclothes++;
5228 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5229 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5234 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5235 cellophane=1-cellophane;
5238 for(i=0;i<numplayers;i++){
5239 player[i].proportionhead.z=0;
5240 player[i].proportionbody.z=0;
5241 player[i].proportionarms.z=0;
5242 player[i].proportionlegs.z=0;
5247 for(i=0;i<numplayers;i++){
5248 player[i].proportionhead.z=player[i].proportionhead.x;
5249 player[i].proportionbody.z=player[i].proportionbody.x;
5250 player[i].proportionarms.z=player[i].proportionarms.x;
5251 player[i].proportionlegs.z=player[i].proportionlegs.x;
5258 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5274 for(j=12;j<consolechars[0];j++){
5275 mapname[j-12+15]=consoletext[0][j];
5277 mapname[consolechars[0]-12+15]='.';
5278 mapname[consolechars[0]-12+16]='p';
5279 mapname[consolechars[0]-12+17]='n';
5280 mapname[consolechars[0]-12+18]='g';
5281 mapname[consolechars[0]-12+19]='\0';
5283 //:Data:Textures:Pants.png
5285 float closestdist=-1;
5288 for(i=1;i<numplayers;i++){
5289 distance=findDistancefast(&player[i].coords,&player[0].coords);
5290 if(closestdist==-1||distance<closestdist){
5291 closestdist=distance;
5296 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5297 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5298 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5299 player[closest].clothestintr[player[closest].numclothes]=tintr;
5300 player[closest].clothestintg[player[closest].numclothes]=tintg;
5301 player[closest].clothestintb[player[closest].numclothes]=tintb;
5302 player[closest].numclothes++;
5308 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5309 player[0].skeleton.id=0;
5310 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);
5311 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5312 player[0].creature=rabbittype;
5315 player[0].proportionhead=1.2;
5316 player[0].proportionbody=1.05;
5317 player[0].proportionarms=1.00;
5318 player[0].proportionlegs=1.1;
5319 player[0].proportionlegs.y=1.05;
5320 player[0].headless=0;
5322 player[0].damagetolerance=200;
5326 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5327 player[0].skeleton.id=0;
5328 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);
5329 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5330 player[0].creature=wolftype;
5332 player[0].proportionhead=1.1;
5333 player[0].proportionbody=1.1;
5334 player[0].proportionarms=1.1;
5335 player[0].proportionlegs=1.1;
5336 player[0].proportionlegs.y=1.1;
5337 player[0].scale=.23;
5339 player[0].damagetolerance=300;
5343 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5344 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5347 if(Compare(consoletext[0],"rambo ",0,5)){
5348 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5351 if(Compare(consoletext[0],"david ",0,5)){
5352 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5355 if(Compare(consoletext[0],"wolf ",0,4)){
5356 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5359 if(Compare(consoletext[0],"darkwolf ",0,8)){
5360 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5363 if(Compare(consoletext[0],"snowwolf ",0,8)){
5364 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5367 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5368 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5371 if(Compare(consoletext[0],"white ",0,5)){
5372 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5375 if(Compare(consoletext[0],"brown ",0,5)){
5376 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5379 if(Compare(consoletext[0],"black ",0,5)){
5380 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5383 if(consolechars[0]>0){
5386 consoletext[k][j]=consoletext[k-1][j];
5388 consolechars[k]=consolechars[k-1];
5391 consoletext[0][j]=' ';
5397 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5398 OPENAL_SetVolume(channels[consolefailsound], 256);
5399 OPENAL_SetPaused(channels[consolefailsound], false);
5408 togglekeydelay[i]=0;
5412 consoleblinkdelay-=multiplier;
5413 if(consoleblinkdelay<=0){
5414 consoleblinkdelay=.3;
5415 consoleblink=1-consoleblink;
5419 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5422 if(newdetail>2)newdetail=detail;
5423 if(newdetail<0)newdetail=detail;
5424 if(newscreenwidth<0)newscreenwidth=screenwidth;
5425 if(newscreenheight<0)newscreenheight=screenheight;
5427 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5428 opstream << "Screenwidth:\n";
5429 opstream << newscreenwidth;
5430 opstream << "\nScreenheight:\n";
5431 opstream << newscreenheight;
5432 opstream << "\nMouse sensitivity:\n";
5433 opstream << usermousesensitivity;
5434 opstream << "\nBlur(0,1):\n";
5435 opstream << ismotionblur;
5436 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5437 opstream << newdetail;
5438 opstream << "\nFloating jump:\n";
5439 opstream << floatjump;
5440 opstream << "\nMouse jump:\n";
5441 opstream << mousejump;
5442 opstream << "\nAmbient sound:\n";
5443 opstream << ambientsound;
5444 opstream << "\nBlood (0,1,2):\n";
5445 opstream << bloodtoggle;
5446 opstream << "\nAuto slomo:\n";
5447 opstream << autoslomo;
5448 opstream << "\nFoliage:\n";
5449 opstream << foliage;
5450 opstream << "\nMusic:\n";
5451 opstream << musictoggle;
5452 opstream << "\nTrilinear:\n";
5453 opstream << trilinear;
5454 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5456 opstream << "\nInvert mouse:\n";
5457 opstream << invertmouse;
5458 opstream << "\nGamespeed:\n";
5459 if(oldgamespeed==0)oldgamespeed=1;
5460 opstream << oldgamespeed;
5461 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5462 opstream << difficulty;
5463 opstream << "\nDamage effects(blackout, doublevision):\n";
5464 opstream << damageeffects;
5465 opstream << "\nText:\n";
5466 opstream << texttoggle;
5467 opstream << "\nDebug:\n";
5468 opstream << debugmode;
5469 opstream << "\nVBL Sync:\n";
5470 opstream << vblsync;
5471 opstream << "\nShow Points:\n";
5472 opstream << showpoints;
5473 opstream << "\nAlways Blur:\n";
5474 opstream << alwaysblur;
5475 opstream << "\nImmediate mode (turn on on G5):\n";
5476 opstream << immediate;
5477 opstream << "\nVelocity blur:\n";
5478 opstream << velocityblur;
5479 opstream << "\nVolume:\n";
5481 opstream << "\nForward key:\n";
5482 opstream << KeyToChar(forwardkey);
5483 opstream << "\nBack key:\n";
5484 opstream << KeyToChar(backkey);
5485 opstream << "\nLeft key:\n";
5486 opstream << KeyToChar(leftkey);
5487 opstream << "\nRight key:\n";
5488 opstream << KeyToChar(rightkey);
5489 opstream << "\nJump key:\n";
5490 opstream << KeyToChar(jumpkey);
5491 opstream << "\nCrouch key:\n";
5492 opstream << KeyToChar(crouchkey);
5493 opstream << "\nDraw key:\n";
5494 opstream << KeyToChar(drawkey);
5495 opstream << "\nThrow key:\n";
5496 opstream << KeyToChar(throwkey);
5497 opstream << "\nAttack key:\n";
5498 opstream << KeyToChar(attackkey);
5499 opstream << "\nChat key:\n";
5500 opstream << KeyToChar(chatkey);
5505 static int oldwinfreeze;
5506 if(winfreeze&&!oldwinfreeze){
5507 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
5508 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5509 OPENAL_SetVolume(channels[consolesuccesssound], 256);
5510 OPENAL_SetPaused(channels[consolesuccesssound], false);
5512 if(winfreeze==0)oldwinfreeze=winfreeze;
5513 else oldwinfreeze++;
5515 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5516 if(winfreeze)winfreeze=0;
5519 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5525 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5528 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5530 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5532 static bool oldbuttondialogue;
5534 if(indialogue!=-1)talkdelay=1;
5535 talkdelay-=multiplier;
5538 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5539 for(i=0;i<numdialogues;i++){
5540 int realdialoguetype;
5542 if(dialoguetype[i]>49){
5543 realdialoguetype=dialoguetype[i]-50;
5546 else if(dialoguetype[i]>39){
5547 realdialoguetype=dialoguetype[i]-40;
5550 else if(dialoguetype[i]>29){
5551 realdialoguetype=dialoguetype[i]-30;
5554 else if(dialoguetype[i]>19){
5555 realdialoguetype=dialoguetype[i]-20;
5558 else if(dialoguetype[i]>9){
5559 realdialoguetype=dialoguetype[i]-10;
5563 realdialoguetype=dialoguetype[i];
5566 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5567 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5569 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5570 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5571 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5572 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5573 player[participantfocus[whichdialogue][j]].velocity=0;
5574 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5575 player[participantfocus[whichdialogue][j]].targetframe=0;
5580 dialoguegonethrough[i]++;
5581 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5582 static float gLoc[3];
5583 static float vel[3];
5585 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5586 temppos=temppos-viewer;
5587 Normalise(&temppos);
5592 gLoc[2]=temppos.z;vel[0]=0;
5596 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5597 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5598 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5599 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5600 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5601 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5602 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5603 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5604 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5605 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5606 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5607 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5608 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5609 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5610 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5611 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5612 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5613 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5614 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5615 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5616 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5617 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5618 OPENAL_SetVolume(channels[whichsoundplay], 256);
5619 OPENAL_SetPaused(channels[whichsoundplay], false);
5621 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5626 windvar+=multiplier;
5627 smoketex+=multiplier;
5628 tutorialstagetime+=multiplier;
5630 static float hotspotvisual[40];
5634 for(i=0;i<numhotspots;i++)
5635 hotspotvisual[i]-=multiplier/320;
5637 for(i=0;i<numhotspots;i++){
5638 //if(hotspottype[i]<=10)
5639 while(hotspotvisual[i]<0){
5641 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5642 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5643 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5644 hotspotsprite+=hotspot[i];
5645 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5646 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5650 for(i=0;i<numhotspots;i++){
5651 if(hotspottype[i]<=10&&hotspottype[i]>0){
5652 hotspot[i]=player[hotspottype[i]].coords;
5658 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5661 if(tutorialstage<=1){
5666 if(tutorialstage==1){
5669 if(tutorialstage==2){
5672 if(tutorialstage==3){
5673 tutorialmaxtime=600;
5675 if(tutorialstage==4){
5676 tutorialmaxtime=1000;
5678 if(tutorialstage==5){
5679 tutorialmaxtime=600;
5681 if(tutorialstage==6){
5682 tutorialmaxtime=600;
5684 if(tutorialstage==7){
5685 tutorialmaxtime=600;
5687 if(tutorialstage==8){
5688 tutorialmaxtime=600;
5690 if(tutorialstage==9){
5691 tutorialmaxtime=600;
5693 if(tutorialstage==10){
5696 if(tutorialstage==11){
5697 tutorialmaxtime=1000;
5699 if(tutorialstage==12){
5700 tutorialmaxtime=1000;
5702 if(tutorialstage==13){
5705 if(tutorialstage==14){
5717 player[1].coords=(temp+temp2)/2;
5721 gLoc[0]=player[1].coords.x;
5722 gLoc[1]=player[1].coords.y;
5723 gLoc[2]=player[1].coords.z;
5727 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
5728 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
5729 OPENAL_SetVolume(channels[fireendsound], 256);
5730 OPENAL_SetPaused(channels[fireendsound], false);
5732 for(i=0;i<player[1].skeleton.num_joints;i++){
5734 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
5735 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
5736 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;
5737 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
5738 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5743 if(tutorialstage==15){
5744 tutorialmaxtime=500;
5746 if(tutorialstage==16){
5747 tutorialmaxtime=500;
5749 if(tutorialstage==17){
5750 tutorialmaxtime=500;
5752 if(tutorialstage==18){
5753 tutorialmaxtime=500;
5755 if(tutorialstage==19){
5757 //tutorialmaxtime=500;
5759 if(tutorialstage==20){
5760 tutorialmaxtime=500;
5762 if(tutorialstage==21){
5763 tutorialmaxtime=500;
5770 if(tutorialstage==22){
5771 tutorialmaxtime=500;
5773 if(tutorialstage==23){
5774 tutorialmaxtime=500;
5776 if(tutorialstage==24){
5777 tutorialmaxtime=500;
5779 if(tutorialstage==25){
5780 tutorialmaxtime=500;
5782 if(tutorialstage==26){
5785 if(tutorialstage==27){
5789 player[1].aitype=attacktypecutoff;
5791 if(tutorialstage==28){
5792 tutorialmaxtime=400;
5794 if(tutorialstage==29){
5795 tutorialmaxtime=400;
5796 player[0].escapednum=0;
5798 if(tutorialstage==30){
5802 player[1].aitype=passivetype;
5804 if(tutorialstage==31){
5807 if(tutorialstage==32){
5810 if(tutorialstage==33){
5811 tutorialmaxtime=400;
5814 player[1].aitype=attacktypecutoff;
5816 if(tutorialstage==34){
5817 tutorialmaxtime=400;
5819 if(tutorialstage==35){
5820 tutorialmaxtime=400;
5822 if(tutorialstage==36){
5826 player[1].aitype=passivetype;
5828 if(tutorialstage==37){
5834 player[1].aitype=attacktypecutoff;
5836 if(tutorialstage==38){
5840 player[1].aitype=passivetype;
5842 if(tutorialstage==39){
5853 weapons.owner[weapons.numweapons]=-1;
5854 weapons.type[weapons.numweapons]=knife;
5855 weapons.damage[weapons.numweapons]=0;
5856 weapons.mass[weapons.numweapons]=1;
5857 weapons.tipmass[weapons.numweapons]=1.2;
5858 weapons.length[weapons.numweapons]=.25;
5859 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5860 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5862 weapons.velocity[weapons.numweapons]=0.1;
5863 weapons.tipvelocity[weapons.numweapons]=0.1;
5864 weapons.missed[weapons.numweapons]=1;
5865 weapons.hitsomething[weapons.numweapons]=0;
5866 weapons.freetime[weapons.numweapons]=0;
5867 weapons.firstfree[weapons.numweapons]=1;
5868 weapons.physics[weapons.numweapons]=1;
5870 weapons.numweapons++;
5872 if(tutorialstage==40){
5873 tutorialmaxtime=300;
5875 if(tutorialstage==41){
5876 tutorialmaxtime=300;
5878 if(tutorialstage==42){
5881 if(tutorialstage==43){
5882 tutorialmaxtime=300;
5884 if(tutorialstage==44){
5886 player[0].weaponactive=-1;
5887 player[0].num_weapons=0;
5888 player[1].weaponactive=0;
5889 player[1].num_weapons=1;
5890 player[1].weaponids[0]=0;
5894 player[1].aitype=attacktypecutoff;
5896 tutorialmaxtime=300;
5898 if(tutorialstage==45){
5900 player[0].weaponactive=-1;
5901 player[0].num_weapons=0;
5902 player[1].weaponactive=0;
5903 player[1].num_weapons=1;
5904 player[1].weaponids[0]=0;
5906 tutorialmaxtime=300;
5908 if(tutorialstage==46){
5910 player[0].weaponactive=-1;
5911 player[0].num_weapons=0;
5912 player[1].weaponactive=0;
5913 player[1].num_weapons=1;
5914 player[1].weaponids[0]=0;
5916 weapons.type[0]=sword;
5918 tutorialmaxtime=300;
5921 if(tutorialstage==47){
5933 weapons.owner[weapons.numweapons]=-1;
5934 weapons.type[weapons.numweapons]=sword;
5935 weapons.damage[weapons.numweapons]=0;
5936 weapons.mass[weapons.numweapons]=1;
5937 weapons.tipmass[weapons.numweapons]=1.2;
5938 weapons.length[weapons.numweapons]=.25;
5939 weapons.position[weapons.numweapons]=(temp+temp2)/2;
5940 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
5942 weapons.velocity[weapons.numweapons]=0.1;
5943 weapons.tipvelocity[weapons.numweapons]=0.1;
5944 weapons.missed[weapons.numweapons]=1;
5945 weapons.hitsomething[weapons.numweapons]=0;
5946 weapons.freetime[weapons.numweapons]=0;
5947 weapons.firstfree[weapons.numweapons]=1;
5948 weapons.physics[weapons.numweapons]=1;
5952 player[0].weaponactive=0;
5953 player[0].num_weapons=1;
5954 player[0].weaponids[0]=1;
5955 player[1].weaponactive=0;
5956 player[1].num_weapons=1;
5957 player[1].weaponids[0]=0;
5959 weapons.numweapons++;
5961 if(tutorialstage==48){
5964 player[1].aitype=passivetype;
5970 player[0].weaponactive=0;
5971 player[0].num_weapons=1;
5972 player[0].weaponids[0]=1;
5973 player[1].weaponactive=0;
5974 player[1].num_weapons=1;
5975 player[1].weaponids[0]=0;
5977 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
5978 else weapons.type[0]=staff;
5980 weapons.numweapons++;
5982 if(tutorialstage==49){
5985 player[1].aitype=passivetype;
5987 tutorialmaxtime=200;
5989 weapons.position[1]=1000;
5990 weapons.tippoint[1]=1000;
5992 weapons.numweapons=1;
5994 player[1].weaponactive=-1;
5995 player[1].num_weapons=0;
5996 player[0].weaponactive=0;
5997 player[0].num_weapons=1;
5998 player[0].weaponids[0]=0;
6000 weapons.type[0]=knife;
6002 weapons.numweapons++;
6004 if(tutorialstage==50){
6010 gLoc[0]=player[1].coords.x;
6011 gLoc[1]=player[1].coords.y;
6012 gLoc[2]=player[1].coords.z;
6016 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6017 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6018 OPENAL_SetVolume(channels[fireendsound], 256);
6019 OPENAL_SetPaused(channels[fireendsound], false);
6021 for(i=0;i<player[1].skeleton.num_joints;i++){
6023 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6024 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6025 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;
6026 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6027 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6031 player[1].num_weapons=0;
6032 player[1].weaponstuck=-1;
6033 player[1].weaponactive=-1;
6035 weapons.numweapons=0;
6037 weapons.owner[0]=-1;
6038 weapons.velocity[0]=0.1;
6039 weapons.tipvelocity[0]=-0.1;
6040 weapons.missed[0]=1;
6041 weapons.hitsomething[0]=0;
6042 weapons.freetime[0]=0;
6043 weapons.firstfree[0]=1;
6044 weapons.physics[0]=1;
6046 if(tutorialstage==51){
6047 tutorialmaxtime=80000;
6049 if(tutorialstage<=51)tutorialstagetime=0;
6053 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6054 if(tutorialstage==3){
6055 if(deltah||deltav)tutorialsuccess+=multiplier;
6057 if(tutorialstage==4){
6058 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6060 if(tutorialstage==5){
6061 if(player[0].jumpkeydown)tutorialsuccess=1;
6063 if(tutorialstage==6){
6064 if(player[0].isCrouch())tutorialsuccess=1;
6066 if(tutorialstage==7){
6067 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6069 if(tutorialstage==8){
6070 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6072 if(tutorialstage==9){
6073 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6075 if(tutorialstage==11){
6076 if(player[0].isWallJump())tutorialsuccess=1;
6078 if(tutorialstage==12){
6079 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6081 if(tutorialstage==15){
6082 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6084 if(tutorialstage==16){
6085 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6087 if(tutorialstage==17){
6088 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6090 if(tutorialstage==18){
6091 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6093 if(tutorialstage==19){
6094 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6096 if(tutorialstage==20){
6097 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6099 if(tutorialstage==21){
6100 if(bonus==cannon)tutorialsuccess=1;
6102 if(tutorialstage==22){
6103 if(bonus==spinecrusher)tutorialsuccess=1;
6105 if(tutorialstage==23){
6106 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6108 if(tutorialstage==24){
6109 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6111 if(tutorialstage==25){
6112 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6114 if(tutorialstage==28){
6115 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6117 if(tutorialstage==29){
6118 if(player[0].escapednum==2){
6122 player[1].aitype=passivetype;
6125 if(tutorialstage==33){
6126 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6128 if(tutorialstage==34){
6129 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6131 if(tutorialstage==35){
6132 if(animation[player[0].targetanimation].attack==reversal){
6136 player[1].aitype=passivetype;
6139 if(tutorialstage==40){
6140 if(player[0].num_weapons>0)tutorialsuccess=1;
6142 if(tutorialstage==41){
6143 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6145 if(tutorialstage==43){
6146 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6148 if(tutorialstage==44){
6149 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6151 if(tutorialstage==45){
6152 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6154 if(tutorialstage==46){
6155 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6157 if(tutorialstage==49){
6158 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6160 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6163 if(tutorialstagetime==tutorialmaxtime-3){
6164 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6165 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6166 OPENAL_SetPaused(channels[consolesuccesssound], false);
6169 if(tutorialsuccess>=1){
6170 if(tutorialstage==34||tutorialstage==35)
6171 tutorialstagetime=tutorialmaxtime-1;
6176 if(tutorialstage<14||tutorialstage>=50){
6177 player[1].coords.y=300;
6178 player[1].velocity=0;
6182 if(tutoriallevel!=1){
6183 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6184 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6185 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6186 OPENAL_SetPaused(channels[consolesuccesssound], false);
6191 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6192 OPENAL_SetVolume(channels[fireendsound], 256);
6193 OPENAL_SetPaused(channels[fireendsound], false);
6196 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6197 else bonusnum[bonus]+=0.15;
6198 if(tutoriallevel)bonusvalue=0;
6199 bonusvalue/=bonusnum[bonus];
6200 bonustotal+=bonusvalue;
6202 bonustime+=multiplier;
6204 if(environment==snowyenvironment){
6205 precipdelay-=multiplier;
6206 while(precipdelay<0){
6208 if(!detail)precipdelay+=.04;
6209 XYZ footvel,footpoint;
6212 footpoint=viewer+viewerfacing*6;
6213 footpoint.y+=((float)abs(Random()%1200))/100-6;
6214 footpoint.x+=((float)abs(Random()%1200))/100-6;
6215 footpoint.z+=((float)abs(Random()%1200))/100-6;
6216 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6219 for(k=0;k<numplayers;k++){
6220 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6221 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6223 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){
6224 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6225 else if(player[k].rotation>player[k].targetrotation){
6226 player[k].rotation-=multiplier*player[k].turnspeed;
6228 else if(player[k].rotation<player[k].targetrotation){
6229 player[k].rotation+=multiplier*player[k].turnspeed;
6234 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))){
6235 player[k].turnspeed*=2;
6236 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6237 else if(player[k].rotation>player[k].targetrotation){
6238 player[k].rotation-=multiplier*player[k].turnspeed;
6240 else if(player[k].rotation<player[k].targetrotation){
6241 player[k].rotation+=multiplier*player[k].turnspeed;
6243 player[k].turnspeed/=2;
6246 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6247 player[k].turnspeed*=4;
6248 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6249 else if(player[k].rotation>player[k].targetrotation){
6250 player[k].rotation-=multiplier*player[k].turnspeed;
6252 else if(player[k].rotation<player[k].targetrotation){
6253 player[k].rotation+=multiplier*player[k].turnspeed;
6255 player[k].turnspeed/=4;
6258 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6259 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6261 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6262 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6265 if(player[k].collide<-.3)player[k].collide=-.3;
6266 if(player[k].collide>1)player[k].collide=1;
6267 player[k].collide-=multiplier*30;
6269 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6270 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6272 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6273 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6274 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6275 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6276 lowpoint=player[k].coords;
6277 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6278 else lowpoint.y+=1.3;
6279 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){
6280 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6282 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6283 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6285 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6286 flatfacing=lowpoint-player[k].coords;
6287 player[k].coords=lowpoint;
6288 player[k].coords.y-=1.3;
6289 player[k].collide=1;
6291 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6292 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6293 tempcoords1=lowpoint;
6294 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6295 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6297 player[k].targetanimation=walljumpleftanim;
6298 player[k].targetframe=0;
6301 gLoc[0]=player[k].coords.x;
6302 gLoc[1]=player[k].coords.y;
6303 gLoc[2]=player[k].coords.z;
6307 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6308 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6309 OPENAL_SetVolume(channels[movewhooshsound], 256);
6310 OPENAL_SetPaused(channels[movewhooshsound], false);
6311 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6313 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6314 player[k].rotation=-asin(0-lowpointtarget.x);
6315 player[k].rotation*=360/6.28;
6316 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6317 player[k].targetrotation=player[k].rotation;
6318 player[k].lowrotation=player[k].rotation;
6319 if(k==0)numwallflipped++;
6323 lowpoint=tempcoords1;
6324 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6325 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6326 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6328 player[k].targetanimation=walljumprightanim;
6329 player[k].targetframe=0;
6332 gLoc[0]=player[k].coords.x;
6333 gLoc[1]=player[k].coords.y;
6334 gLoc[2]=player[k].coords.z;
6338 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6339 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6340 OPENAL_SetVolume(channels[movewhooshsound], 256);
6341 OPENAL_SetPaused(channels[movewhooshsound], false);
6342 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6344 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6345 player[k].rotation=-asin(0-lowpointtarget.x);
6346 player[k].rotation*=360/6.28;
6347 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6348 player[k].targetrotation=player[k].rotation;
6349 player[k].lowrotation=player[k].rotation;
6350 if(k==0)numwallflipped++;
6354 lowpoint=tempcoords1;
6355 lowpointtarget=lowpoint+player[k].facing*2;
6356 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6357 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6359 player[k].targetanimation=walljumpbackanim;
6360 player[k].targetframe=0;
6363 gLoc[0]=player[k].coords.x;
6364 gLoc[1]=player[k].coords.y;
6365 gLoc[2]=player[k].coords.z;
6369 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6370 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6371 OPENAL_SetVolume(channels[movewhooshsound], 256);
6372 OPENAL_SetPaused(channels[movewhooshsound], false);
6373 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6375 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6376 player[k].rotation=-asin(0-lowpointtarget.x);
6377 player[k].rotation*=360/6.28;
6378 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6379 player[k].targetrotation=player[k].rotation;
6380 player[k].lowrotation=player[k].rotation;
6381 if(k==0)numwallflipped++;
6385 lowpoint=tempcoords1;
6386 lowpointtarget=lowpoint-player[k].facing*2;
6387 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6388 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6390 player[k].targetanimation=walljumpfrontanim;
6391 player[k].targetframe=0;
6394 gLoc[0]=player[k].coords.x;
6395 gLoc[1]=player[k].coords.y;
6396 gLoc[2]=player[k].coords.z;
6400 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6401 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6402 OPENAL_SetVolume(channels[movewhooshsound], 256);
6403 OPENAL_SetPaused(channels[movewhooshsound], false);
6404 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6406 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6407 player[k].rotation=-asin(0-lowpointtarget.x);
6408 player[k].rotation*=360/6.28;
6409 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6410 player[k].rotation+=180;
6411 player[k].targetrotation=player[k].rotation;
6412 player[k].lowrotation=player[k].rotation;
6413 if(k==0)numwallflipped++;
6421 else if(objects.type[i]==rocktype){
6422 lowpoint2=player[k].coords;
6423 lowpoint=player[k].coords;
6425 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6426 player[k].coords=colpoint;
6427 player[k].collide=1;
6430 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6431 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6433 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6435 player[k].targetframe=0;
6436 player[k].onterrain=1;
6438 if(player[k].id==0){
6439 OPENAL_SetPaused(channels[whooshsound], true);
6440 OPENAL_SetVolume(channels[whooshsound], 0);
6443 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6444 if(player[k].isFlip())player[k].jumppower=-4;
6445 player[k].targetanimation=player[k].getLanding();
6448 gLoc[0]=player[k].coords.x;
6449 gLoc[1]=player[k].coords.y;
6450 gLoc[2]=player[k].coords.z;
6451 vel[0]=player[k].velocity.x;
6452 vel[1]=player[k].velocity.y;
6453 vel[2]=player[k].velocity.z;
6454 PlaySoundEx( landsound, samp[landsound], NULL, true);
6455 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6456 OPENAL_SetVolume(channels[landsound], 128);
6457 OPENAL_SetPaused(channels[landsound], false);
6459 envsound[numenvsounds]=player[k].coords;
6460 envsoundvol[numenvsounds]=16;
6461 envsoundlife[numenvsounds]=.4;
6470 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6471 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6472 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6473 lowpoint=player[k].coords;
6475 if(objects.type[i]!=rocktype)
6476 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6477 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6478 player[k].coords=lowpoint;
6479 player[k].coords.y-=1.35;
6480 player[k].collide=1;
6482 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)){
6483 lowpoint=player[k].coords;
6484 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6485 lowpoint=player[k].coords;
6489 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6490 lowpointtarget=lowpoint+facing*1.4;
6491 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6493 lowpoint=player[k].coords;
6495 lowpointtarget=lowpoint+facing*1.4;
6497 lowpointtarget2=lowpointtarget;
6499 lowpointtarget3=lowpointtarget;
6501 lowpointtarget4=lowpointtarget;
6503 lowpointtarget5=lowpointtarget;
6505 lowpointtarget6=lowpointtarget;
6507 lowpointtarget7=lowpoint;
6509 lowpointtarget2.x+=.1;
6511 lowpointtarget3.z+=.1;
6513 lowpointtarget4.x-=.1;
6515 lowpointtarget5.z-=.1;
6517 lowpointtarget6.y+=45/13;
6518 lowpointtarget6+=facing*.6;
6519 lowpointtarget7.y+=90/13;
6520 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6521 if(objects.friction[i]>.5)
6524 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6525 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6526 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6527 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)
6529 lowpoint=player[k].coords;
6530 lowpoint.y+=(float)j/13;
6531 lowpointtarget=lowpoint+facing*1.4;
6532 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6536 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6539 if(j<=25&&player[k].targetanimation==jumpdownanim){
6542 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6543 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6544 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)*/){
6545 lowpoint=player[k].coords;
6546 lowpoint.y+=(float)j/13;
6547 lowpointtarget=lowpoint+facing*1.3;
6548 flatfacing=player[k].coords;
6549 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6550 player[k].coords.y=lowpointtarget.y-.07;
6551 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6553 if(j>10||!player[k].isRun()){
6554 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6555 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6559 gLoc[0]=player[k].coords.x;
6560 gLoc[1]=player[k].coords.y;
6561 gLoc[2]=player[k].coords.z;
6562 vel[0]=player[k].velocity.x;
6563 vel[1]=player[k].velocity.y;
6564 vel[2]=player[k].velocity.z;
6565 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6566 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6567 OPENAL_SetVolume(channels[jumpsound], 128);
6568 OPENAL_SetPaused(channels[jumpsound], false);
6570 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6571 player[k].rotation=-asin(0-lowpointtarget.x);
6572 player[k].rotation*=360/6.28;
6573 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6574 player[k].targetrotation=player[k].rotation;
6575 player[k].lowrotation=player[k].rotation;
6577 //player[k].velocity=lowpointtarget*.03;
6578 player[k].velocity=0;
6580 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6581 //player[k].currentanimation=climbanim;
6582 player[k].targetanimation=climbanim;
6583 player[k].jumppower=0;
6584 player[k].jumpclimb=1;
6586 player[k].transspeed=6;
6589 //player[k].currentframe=1;
6590 player[k].targetframe=1;
6592 //player[k].currentframe=0;
6593 player[k].targetframe=0;
6594 //player[k].currentanimation=hanganim;
6595 player[k].targetanimation=hanganim;
6596 player[k].jumppower=0;
6610 if(player[k].collide<=0){
6611 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()){
6612 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)){
6613 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6614 player[k].targetanimation=jumpdownanim;
6615 player[k].targetframe=0;
6620 gLoc[0]=player[k].coords.x;
6621 gLoc[1]=player[k].coords.y;
6622 gLoc[2]=player[k].coords.z;
6623 vel[0]=player[k].velocity.x;
6624 vel[1]=player[k].velocity.y;
6625 vel[2]=player[k].velocity.z;
6627 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6628 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6629 OPENAL_SetVolume(channels[whooshsound], 128);
6630 OPENAL_SetPaused(channels[whooshsound], false);
6633 player[k].velocity.y+=gravity;
6638 player[k].realoldcoords=player[k].coords;
6641 static XYZ oldviewer;
6644 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6645 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6646 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6647 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6648 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6649 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6650 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6651 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6655 player[0].forwardkeydown=0;
6656 player[0].leftkeydown=0;
6657 player[0].backkeydown=0;
6658 player[0].rightkeydown=0;
6659 player[0].jumpkeydown=0;
6660 player[0].crouchkeydown=0;
6661 player[0].drawkeydown=0;
6662 player[0].throwkeydown=0;
6665 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6668 static bool endkeydown;
6675 facing=DoRotation(facing,-rotation2,0,0);
6676 facing=DoRotation(facing,0,0-rotation,0);
6681 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6683 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6684 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6685 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6686 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6687 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6688 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6689 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)
6690 ||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)
6691 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6693 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6694 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6695 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6696 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6697 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6698 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6699 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6700 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6701 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6702 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
6703 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
6705 participantfocus[whichdialogue][indialogue]=whichend;
6706 participantlocation[whichdialogue][whichend]=player[whichend].coords;
6707 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
6710 participantfocus[whichdialogue][indialogue]=-1;
6712 if(player[participantfocus[whichdialogue][indialogue]].dead){
6717 dialoguecamera[whichdialogue][indialogue]=viewer;
6718 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
6719 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
6721 if(indialogue<numdialogueboxes[whichdialogue]){
6722 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6723 static float gLoc[3];
6724 static float vel[3];
6726 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6727 temppos=temppos-viewer;
6728 Normalise(&temppos);
6733 gLoc[2]=temppos.z;vel[0]=0;
6737 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6738 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6739 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6740 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6741 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6742 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6743 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6744 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6745 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6746 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6747 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6748 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6749 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6750 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6751 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6752 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6753 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6754 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6755 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6756 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6757 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6758 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6759 OPENAL_SetVolume(channels[whichsoundplay], 256);
6760 OPENAL_SetPaused(channels[whichsoundplay], false);
6764 for(j=0;j<numplayers;j++){
6765 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
6770 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)
6771 ||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)
6774 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
6775 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
6776 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
6777 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
6778 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
6779 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
6780 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
6781 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
6782 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
6783 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
6784 participantfacing[whichdialogue][indialogue][whichend]=facing;
6786 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)
6787 &&!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)
6788 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6791 if(indialogue>=numdialogueboxes[whichdialogue]){
6798 OPENAL_SetPaused(channels[whooshsound], true);
6799 viewer=dialoguecamera[whichdialogue][indialogue];
6800 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
6801 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
6803 rotation=dialoguecamerarotation[whichdialogue][indialogue];
6804 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
6805 if(dialoguetime>0.5)
6806 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)
6807 ||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)
6808 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
6811 if(indialogue<numdialogueboxes[whichdialogue]){
6812 if(dialogueboxsound[whichdialogue][indialogue]!=0){
6813 static float gLoc[3];
6814 static float vel[3];
6816 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
6817 temppos=temppos-viewer;
6818 Normalise(&temppos);
6823 gLoc[2]=temppos.z;vel[0]=0;
6827 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
6828 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
6829 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
6830 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
6831 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
6832 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
6833 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
6834 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
6835 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
6836 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
6837 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
6838 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
6839 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
6840 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
6841 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
6842 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
6843 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
6844 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
6845 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
6846 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
6847 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
6848 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
6849 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
6850 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
6851 OPENAL_SetVolume(channels[whichsoundplay], 256);
6852 OPENAL_SetPaused(channels[whichsoundplay], false);
6854 if(dialogueboxsound[whichdialogue][indialogue]==-5){
6855 hotspot[numhotspots]=player[0].coords;
6856 hotspotsize[numhotspots]=10;
6857 hotspottype[numhotspots]=-1;
6861 if(dialogueboxsound[whichdialogue][indialogue]==-6){
6865 if(player[participantfocus[whichdialogue][indialogue]].dead){
6873 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)
6874 &&!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)
6875 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
6878 if(indialogue>=numdialogueboxes[whichdialogue]){
6882 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
6885 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
6888 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
6890 for(i=1;i<numplayers;i++){
6891 player[i].aitype = attacktypecutoff;
6898 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
6899 else oldbuttondialogue=1;
6901 static float keyrefreshdelay=0,bigrefreshdelay=0;
6905 /*keyrefreshdelay-=multiplier;
6906 bigrefreshdelay-=multiplier;
6908 if(keyrefreshdelay<=0){
6909 static int concat[4];
6911 concat[0]=player[0].forwardkeydown;
6912 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
6913 concat[0]=concat[0]*2+player[0].rightkeydown;
6914 concat[0]=concat[0]*2+player[0].leftkeydown;
6915 concat[0]=concat[0]*2+player[0].backkeydown;
6916 concat[0]=concat[0]*2+player[0].jumpkeydown;
6917 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
6918 concat[0]=concat[0]*2+player[0].crouchkeydown;
6920 concat[1]=player[0].crouchtogglekeydown;
6921 concat[1]=concat[1]*2+player[0].drawkeydown;
6922 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
6923 concat[1]=concat[1]*2+player[0].throwkeydown;
6924 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
6925 concat[1]=concat[1]*2+player[0].attackkeydown;
6927 //concat[2]=(char)((int)(rotation/2)%180);
6929 //concat[3]=(char)((int)(rotation2/2)%180);
6931 chatname[0]=concat[0]-128;
6932 chatname[1]=concat[1]-128;
6933 //chatname[2]=concat[2]-128;
6934 //chatname[3]=concat[3]-128;
6936 memcpy(chatname+temppoint,&rotation,sizeof(float));
6937 temppoint+=sizeof(float);
6938 memcpy(chatname+temppoint,&rotation2,sizeof(float));
6939 temppoint+=sizeof(float);
6941 chatname[temppoint]='\0';
6943 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
6944 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
6945 //keyrefreshdelay=.01;
6946 keyrefreshdelay=.03;
6949 if(bigrefreshdelay<=0){
6952 memcpy(chatname+temppoint,&i,sizeof(int));
6953 temppoint+=sizeof(int);
6954 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
6955 temppoint+=sizeof(float);
6956 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
6957 temppoint+=sizeof(float);
6958 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
6959 temppoint+=sizeof(float);
6960 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
6961 temppoint+=sizeof(float);
6962 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
6963 temppoint+=sizeof(float);
6964 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
6965 temppoint+=sizeof(int);
6966 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
6967 temppoint+=sizeof(int);
6968 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
6969 temppoint+=sizeof(float);
6970 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
6971 temppoint+=sizeof(float);
6972 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
6973 temppoint+=sizeof(float);
6974 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
6975 temppoint+=sizeof(int);
6976 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
6977 temppoint+=sizeof(int);
6978 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
6979 temppoint+=sizeof(float);
6980 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
6981 temppoint+=sizeof(float);
6982 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
6983 temppoint+=sizeof(float);
6984 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
6985 temppoint+=sizeof(int);
6986 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
6987 temppoint+=sizeof(int);
6988 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
6989 temppoint+=sizeof(int);
6990 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
6991 temppoint+=sizeof(int);
6992 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
6993 temppoint+=sizeof(int);
6994 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
6995 temppoint+=sizeof(int);
6996 chatname[temppoint]='\0';
6998 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);
6999 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7000 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7002 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);
7004 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7005 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7007 //bigrefreshdelay=.02;
7012 if(!player[0].jumpkeydown){
7013 player[0].jumptogglekeydown=0;
7015 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7018 dialoguetime+=multiplier;
7019 skybox.cloudmove+=multiplier;
7020 hawkrotation+=multiplier*25;
7022 realhawkcoords.x=25;
7023 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7024 hawkcalldelay-=multiplier/2;
7026 if(hawkcalldelay<=0)
7028 static float gLoc[3];
7029 static float vel[3];
7030 gLoc[0]=realhawkcoords.x;
7031 gLoc[1]=realhawkcoords.y;
7032 gLoc[2]=realhawkcoords.z;
7036 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
7037 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
7038 OPENAL_SetVolume(channels[hawksound], 128);
7039 OPENAL_SetPaused(channels[hawksound], false);
7041 hawkcalldelay=16+abs(Random()%8);
7043 static float temptexdetail;
7046 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7047 player[0].damagetolerance=200000;
7050 player[0].permanentdamage=0;
7051 player[0].superpermanentdamage=0;
7054 whichchar = abs(Random()%7);
7055 registrationname[whichchar]+=1;
7059 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7061 if(environment>2)environment=0;
7062 Setenvironment(environment);
7068 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7072 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7073 cameramode=1-cameramode;
7074 cameratogglekeydown=1;
7077 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7078 cameratogglekeydown=0;
7081 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7082 if(player[0].num_weapons>0){
7083 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7084 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7085 else weapons.type[player[0].weaponids[0]]=sword;
7086 if(weapons.type[player[0].weaponids[0]]==sword){
7087 weapons.mass[player[0].weaponids[0]]=1.5;
7088 weapons.tipmass[player[0].weaponids[0]]=1;
7089 weapons.length[player[0].weaponids[0]]=.8;
7091 if(weapons.type[player[0].weaponids[0]]==staff){
7092 weapons.mass[player[0].weaponids[0]]=2;
7093 weapons.tipmass[player[0].weaponids[0]]=1;
7094 weapons.length[player[0].weaponids[0]]=1.5;
7097 if(weapons.type[player[0].weaponids[0]]==knife){
7098 weapons.mass[player[0].weaponids[0]]=1;
7099 weapons.tipmass[player[0].weaponids[0]]=1.2;
7100 weapons.length[player[0].weaponids[0]]=.25;
7104 /*for(i=0;i<objects.numobjects;i++){
7105 if(objects.type[i]==treeleavestype){
7106 for(j=0;j<objects.numobjects;j++){
7107 if(objects.type[j]==treetrunktype)
7108 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7109 objects.scale[i]=objects.scale[j];
7113 detailtogglekeydown=1;
7116 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7118 float closestdist=-1;
7121 for(i=1;i<numplayers;i++){
7122 distance=findDistancefast(&player[i].coords,&player[0].coords);
7123 if(closestdist==-1||distance<closestdist){
7124 closestdist=distance;
7129 if(player[closest].num_weapons)
7131 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7132 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7133 else weapons.type[player[closest].weaponids[0]]=sword;
7134 if(weapons.type[player[closest].weaponids[0]]==sword){
7135 weapons.mass[player[closest].weaponids[0]]=1.5;
7136 weapons.tipmass[player[closest].weaponids[0]]=1;
7137 weapons.length[player[closest].weaponids[0]]=.8;
7139 if(weapons.type[player[0].weaponids[0]]==staff){
7140 weapons.mass[player[0].weaponids[0]]=2;
7141 weapons.tipmass[player[0].weaponids[0]]=1;
7142 weapons.length[player[0].weaponids[0]]=1.5;
7144 if(weapons.type[player[closest].weaponids[0]]==knife){
7145 weapons.mass[player[closest].weaponids[0]]=1;
7146 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7147 weapons.length[player[closest].weaponids[0]]=.25;
7150 if(!player[closest].num_weapons)
7152 player[closest].weaponids[0]=weapons.numweapons;
7153 weapons.owner[weapons.numweapons]=closest;
7154 weapons.type[weapons.numweapons]=knife;
7155 weapons.damage[weapons.numweapons]=0;
7156 weapons.numweapons++;
7157 player[closest].num_weapons=1;
7158 if(weapons.type[player[closest].weaponids[0]]==sword){
7159 weapons.mass[player[closest].weaponids[0]]=1.5;
7160 weapons.tipmass[player[closest].weaponids[0]]=1;
7161 weapons.length[player[closest].weaponids[0]]=.8;
7163 if(weapons.type[player[closest].weaponids[0]]==knife){
7164 weapons.mass[player[closest].weaponids[0]]=1;
7165 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7166 weapons.length[player[closest].weaponids[0]]=.25;
7170 detailtogglekeydown=1;
7173 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7175 float closestdist=-1;
7178 for(i=1;i<numplayers;i++){
7179 distance=findDistancefast(&player[i].coords,&player[0].coords);
7180 if(closestdist==-1||distance<closestdist){
7181 closestdist=distance;
7186 player[closest].rotation+=multiplier*50;
7187 player[closest].targetrotation=player[closest].rotation;
7191 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7193 float closestdist=-1;
7196 for(i=1;i<numplayers;i++){
7197 distance=findDistancefast(&player[i].coords,&player[0].coords);
7198 if(closestdist==-1||distance<closestdist){
7199 closestdist=distance;
7203 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7206 player[closest].whichskin++;
7207 if(player[closest].whichskin>9)player[closest].whichskin=0;
7208 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7210 if(player[closest].creature==rabbittype){
7211 if(player[closest].whichskin==0){
7212 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7214 else if(player[closest].whichskin==1){
7215 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7217 else if(player[closest].whichskin==2){
7218 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7220 else if(player[closest].whichskin==3){
7221 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7223 else if(player[closest].whichskin==4){
7224 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7226 else if(player[closest].whichskin==5){
7227 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7229 else if(player[closest].whichskin==6){
7230 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7232 else if(player[closest].whichskin==7){
7233 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7235 else if(player[closest].whichskin==8){
7236 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7238 else if(player[closest].whichskin==9){
7239 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7242 if(player[closest].creature==wolftype){
7244 if(player[closest].whichskin==0){
7245 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7247 else if(player[closest].whichskin==1){
7248 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7250 else if(player[closest].whichskin==2){
7251 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7256 if(player[closest].numclothes){
7257 for(i=0;i<player[closest].numclothes;i++){
7258 tintr=player[closest].clothestintr[i];
7259 tintg=player[closest].clothestintg[i];
7260 tintb=player[closest].clothestintb[i];
7261 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7263 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7266 detailtogglekeydown=1;
7269 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7271 float closestdist=-1;
7274 for(i=1;i<numplayers;i++){
7275 distance=findDistancefast(&player[i].coords,&player[0].coords);
7276 if(closestdist==-1||distance<closestdist){
7277 closestdist=distance;
7282 if(player[closest].creature==wolftype){
7283 headprop=player[closest].proportionhead.x/1.1;
7284 bodyprop=player[closest].proportionbody.x/1.1;
7285 armprop=player[closest].proportionarms.x/1.1;
7286 legprop=player[closest].proportionlegs.x/1.1;
7289 if(player[closest].creature==rabbittype){
7290 headprop=player[closest].proportionhead.x/1.2;
7291 bodyprop=player[closest].proportionbody.x/1.05;
7292 armprop=player[closest].proportionarms.x/1.00;
7293 legprop=player[closest].proportionlegs.x/1.1;
7297 if(player[closest].creature==rabbittype){
7298 player[closest].skeleton.id=closest;
7299 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);
7300 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7301 player[closest].whichskin=0;
7302 player[closest].creature=wolftype;
7304 player[closest].proportionhead=1.1;
7305 player[closest].proportionbody=1.1;
7306 player[closest].proportionarms=1.1;
7307 player[closest].proportionlegs=1.1;
7308 player[closest].proportionlegs.y=1.1;
7309 player[closest].scale=.23*5*player[0].scale;
7311 player[closest].damagetolerance=300;
7315 player[closest].skeleton.id=closest;
7316 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);
7317 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7318 player[closest].whichskin=0;
7319 player[closest].creature=rabbittype;
7321 player[closest].proportionhead=1.2;
7322 player[closest].proportionbody=1.05;
7323 player[closest].proportionarms=1.00;
7324 player[closest].proportionlegs=1.1;
7325 player[closest].proportionlegs.y=1.05;
7326 player[closest].scale=.2*5*player[0].scale;
7328 player[closest].damagetolerance=200;
7331 if(player[closest].creature==wolftype){
7332 player[closest].proportionhead=1.1*headprop;
7333 player[closest].proportionbody=1.1*bodyprop;
7334 player[closest].proportionarms=1.1*armprop;
7335 player[closest].proportionlegs=1.1*legprop;
7338 if(player[closest].creature==rabbittype){
7339 player[closest].proportionhead=1.2*headprop;
7340 player[closest].proportionbody=1.05*bodyprop;
7341 player[closest].proportionarms=1.00*armprop;
7342 player[closest].proportionlegs=1.1*legprop;
7343 player[closest].proportionlegs.y=1.05*legprop;
7347 detailtogglekeydown=1;
7350 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7351 detailtogglekeydown=0;
7354 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7357 slomotogglekeydown=1;
7361 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7363 float closestdist=-1;
7365 XYZ flatfacing2,flatvelocity2;
7368 for(i=1;i<numplayers;i++){
7369 distance=findDistancefast(&player[i].coords,&player[0].coords);
7370 if(distance<144&&!player[i].headless)
7371 if(closestdist==-1||distance<closestdist){
7372 closestdist=distance;
7374 blah = player[i].coords;
7379 XYZ headspurtdirection;
7380 int i = player[closest].skeleton.jointlabels[head];
7381 for(k=0;k<player[closest].skeleton.num_joints; k++){
7382 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7383 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7384 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;
7385 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7386 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7387 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7388 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7389 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7390 Normalise(&headspurtdirection);
7391 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7392 flatvelocity2+=headspurtdirection*8;
7393 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7395 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7405 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7406 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7407 OPENAL_SetVolume(channels[splattersound], 256);
7408 OPENAL_SetPaused(channels[splattersound], false);
7410 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7411 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7412 OPENAL_SetVolume(channels[breaksound2], 100);
7413 OPENAL_SetPaused(channels[breaksound2], false);
7415 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7416 player[closest].RagDoll(0);
7417 player[closest].dead=2;
7418 player[closest].headless=1;
7419 player[closest].DoBloodBig(3,165);
7424 explodetogglekeydown=1;
7427 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7429 float closestdist=-1;
7431 XYZ flatfacing2,flatvelocity2;
7434 for(i=1;i<numplayers;i++){
7435 distance=findDistancefast(&player[i].coords,&player[0].coords);
7437 if(closestdist==-1||distance<closestdist){
7438 closestdist=distance;
7440 blah=player[i].coords;
7454 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7455 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7456 OPENAL_SetVolume(channels[splattersound], 256);
7457 OPENAL_SetPaused(channels[splattersound], false);
7459 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7460 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7461 OPENAL_SetVolume(channels[breaksound2], 600);
7462 OPENAL_SetPaused(channels[breaksound2], false);
7464 for(i=0;i<player[closest].skeleton.num_joints; i++){
7465 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7466 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7467 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;
7468 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7469 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7470 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7471 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7472 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7473 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7474 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7477 for(i=0;i<player[closest].skeleton.num_joints; i++){
7478 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7479 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7480 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;
7481 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7482 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7483 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7484 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7485 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7486 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7489 for(i=0;i<player[closest].skeleton.num_joints; i++){
7490 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7491 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7492 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;
7493 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7494 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7495 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7496 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7497 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7498 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7501 for(i=0;i<player[closest].skeleton.num_joints; i++){
7502 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7503 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7504 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;
7505 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7506 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7507 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7508 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7509 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7510 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7514 for(j=0;j<numplayers; j++){
7516 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7517 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7518 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7519 player[j].skeleton.longdead=0;
7520 player[j].RagDoll(0);
7521 for(i=0;i<player[j].skeleton.num_joints; i++){
7522 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7523 if(findDistancefast(&temppos,&player[closest].coords)<25){
7524 flatvelocity2=temppos-player[closest].coords;
7525 Normalise(&flatvelocity2);
7526 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7533 player[closest].DoDamage(10000);
7534 player[closest].RagDoll(0);
7535 player[closest].dead=2;
7536 player[closest].coords=20;
7537 player[closest].skeleton.free=2;
7543 explodetogglekeydown=1;
7546 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7547 explodetogglekeydown=0;
7551 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7553 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7554 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7555 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7556 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7557 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7558 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7559 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7561 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7562 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7563 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7564 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7565 for(j=0;j<player[0].num_weapons;j++){
7566 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7568 fwrite( &environment, 1, sizeof(int), tfile );
7570 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7571 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7572 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7573 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7574 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7576 fwrite( &numplayers, 1, sizeof(int), tfile );
7577 if(numplayers>1&&numplayers<maxplayers)
7578 for(i=1;i<numplayers;i++){
7579 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7580 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7581 for(j=0;j<player[i].num_weapons;j++){
7582 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7584 if(player[i].numwaypoints<30){
7585 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7586 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7587 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7588 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7591 player[i].numwaypoints=0;
7592 player[i].waypoint=0;
7593 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7594 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7595 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7601 slomotogglekeydown=1;
7604 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7605 slomotogglekeydown=0;
7609 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7610 player[0].onfire=1-player[0].onfire;
7611 if(player[0].onfire){
7612 player[0].CatchFire();
7614 if(!player[0].onfire){
7617 gLoc[0]=player[0].coords.x;
7618 gLoc[1]=player[0].coords.y;
7619 gLoc[2]=player[0].coords.z;
7623 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7624 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7625 OPENAL_SetVolume(channels[fireendsound], 256);
7626 OPENAL_SetPaused(channels[fireendsound], false);
7627 OPENAL_SetPaused(channels[stream_firesound], true);
7629 slomotogglekeydown=1;
7632 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7633 if(player[0].bleeding<=0)
7634 player[0].DoBlood(1,255);
7638 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7640 float closestdist=-1;
7643 for(i=1;i<numplayers;i++){
7644 distance=findDistancefast(&player[i].coords,&player[0].coords);
7645 if(closestdist==-1||distance<closestdist){
7646 closestdist=distance;
7650 if(closestdist>0&&closest>=0){
7651 //player[closest]=player[numplayers-1];
7652 //player[closest].skeleton=player[numplayers-1].skeleton;
7655 drawmodetogglekeydown=1;
7658 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7660 float closestdist=-1;
7663 for(i=1;i<max_objects;i++){
7664 distance=findDistancefast(&objects.position[i],&player[0].coords);
7665 if(closestdist==-1||distance<closestdist){
7666 closestdist=distance;
7670 if(closestdist>0&&closest>=0){
7671 objects.position[closest].y-=500;
7673 drawmodetogglekeydown=1;
7676 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7678 //if(drawmode>2)drawmode=0;
7679 if(objects.numobjects<max_objects-1){
7681 boxcoords.x=player[0].coords.x;
7682 boxcoords.z=player[0].coords.z;
7683 boxcoords.y=player[0].coords.y-3;
7684 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7685 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7686 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7687 float temprotat,temprotat2;
7688 temprotat=editorrotation;
7689 temprotat2=editorrotation2;
7690 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7691 if(temprotat2<0)temprotat2=Random()%360;
7693 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7694 if(editortype==treetrunktype)
7695 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7698 drawmodetogglekeydown=1;
7701 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7702 if(numplayers<maxplayers-1){
7703 player[numplayers].scale=.2*5*player[0].scale;
7704 player[numplayers].creature=rabbittype;
7705 player[numplayers].howactive=editoractive;
7706 player[numplayers].skeleton.id=numplayers;
7707 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);
7709 //texsize=512*512*3/texdetail/texdetail;
7710 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
7711 //player[numplayers].skeleton.skinText.resize(texsize);
7713 k=abs(Random()%2)+1;
7715 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7716 player[numplayers].whichskin=0;
7719 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7720 player[numplayers].whichskin=1;
7723 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7724 player[numplayers].whichskin=2;
7727 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
7728 player[numplayers].power=1;
7729 player[numplayers].speedmult=1;
7730 player[numplayers].currentanimation=bounceidleanim;
7731 player[numplayers].targetanimation=bounceidleanim;
7732 player[numplayers].currentframe=0;
7733 player[numplayers].targetframe=1;
7734 player[numplayers].target=0;
7735 player[numplayers].bled=0;
7736 player[numplayers].speed=1+(float)(Random()%100)/1000;
7738 player[numplayers].targetrotation=player[0].targetrotation;
7739 player[numplayers].rotation=player[0].rotation;
7741 player[numplayers].velocity=0;
7742 player[numplayers].coords=player[0].coords;
7743 player[numplayers].oldcoords=player[numplayers].coords;
7744 player[numplayers].realoldcoords=player[numplayers].coords;
7746 player[numplayers].id=numplayers;
7747 player[numplayers].skeleton.id=numplayers;
7748 player[numplayers].updatedelay=0;
7749 player[numplayers].normalsupdatedelay=0;
7751 player[numplayers].aitype=passivetype;
7752 player[numplayers].aitarget=0;
7754 if(player[0].creature==wolftype){
7755 headprop=player[0].proportionhead.x/1.1;
7756 bodyprop=player[0].proportionbody.x/1.1;
7757 armprop=player[0].proportionarms.x/1.1;
7758 legprop=player[0].proportionlegs.x/1.1;
7761 if(player[0].creature==rabbittype){
7762 headprop=player[0].proportionhead.x/1.2;
7763 bodyprop=player[0].proportionbody.x/1.05;
7764 armprop=player[0].proportionarms.x/1.00;
7765 legprop=player[0].proportionlegs.x/1.1;
7768 if(player[numplayers].creature==wolftype){
7769 player[numplayers].proportionhead=1.1*headprop;
7770 player[numplayers].proportionbody=1.1*bodyprop;
7771 player[numplayers].proportionarms=1.1*armprop;
7772 player[numplayers].proportionlegs=1.1*legprop;
7775 if(player[numplayers].creature==rabbittype){
7776 player[numplayers].proportionhead=1.2*headprop;
7777 player[numplayers].proportionbody=1.05*bodyprop;
7778 player[numplayers].proportionarms=1.00*armprop;
7779 player[numplayers].proportionlegs=1.1*legprop;
7780 player[numplayers].proportionlegs.y=1.05*legprop;
7783 player[numplayers].headless=0;
7784 player[numplayers].onfire=0;
7787 player[numplayers].proportionhead.z=0;
7788 player[numplayers].proportionbody.z=0;
7789 player[numplayers].proportionarms.z=0;
7790 player[numplayers].proportionlegs.z=0;
7793 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
7795 player[numplayers].damagetolerance=200;
7797 player[numplayers].protectionhead=player[0].protectionhead;
7798 player[numplayers].protectionhigh=player[0].protectionhigh;
7799 player[numplayers].protectionlow=player[0].protectionlow;
7800 player[numplayers].armorhead=player[0].armorhead;
7801 player[numplayers].armorhigh=player[0].armorhigh;
7802 player[numplayers].armorlow=player[0].armorlow;
7803 player[numplayers].metalhead=player[0].metalhead;
7804 player[numplayers].metalhigh=player[0].metalhigh;
7805 player[numplayers].metallow=player[0].metallow;
7807 player[numplayers].immobile=player[0].immobile;
7809 player[numplayers].numclothes=player[0].numclothes;
7810 if(player[numplayers].numclothes)
7811 for(i=0;i<player[numplayers].numclothes;i++){
7812 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
7813 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
7814 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
7815 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
7816 tintr=player[numplayers].clothestintr[i];
7817 tintg=player[numplayers].clothestintg[i];
7818 tintb=player[numplayers].clothestintb[i];
7819 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
7821 if(player[numplayers].numclothes){
7822 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
7825 player[numplayers].power=player[0].power;
7826 player[numplayers].speedmult=player[0].speedmult;
7828 player[numplayers].damage=0;
7829 player[numplayers].permanentdamage=0;
7830 player[numplayers].superpermanentdamage=0;
7831 player[numplayers].deathbleeding=0;
7832 player[numplayers].bleeding=0;
7833 player[numplayers].numwaypoints=0;
7834 player[numplayers].waypoint=0;
7835 player[numplayers].jumppath=0;
7836 player[numplayers].weaponstuck=-1;
7837 player[numplayers].weaponactive=-1;
7838 player[numplayers].num_weapons=0;
7839 player[numplayers].bloodloss=0;
7840 player[numplayers].dead=0;
7842 player[numplayers].loaded=1;
7846 drawmodetogglekeydown=1;
7849 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
7850 if(player[numplayers-1].numwaypoints<90){
7851 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
7852 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
7853 player[numplayers-1].numwaypoints++;
7855 drawmodetogglekeydown=1;
7858 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7859 if(numpathpoints<30){
7860 bool connected,alreadyconnected;
7863 for(i=0;i<numpathpoints;i++){
7864 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
7866 for(j=0;j<numpathpointconnect[pathpointselected];j++){
7867 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
7869 if(!alreadyconnected){
7870 numpathpointconnect[pathpointselected]++;
7872 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
7878 pathpoint[numpathpoints-1]=player[0].coords;
7879 numpathpointconnect[numpathpoints-1]=0;
7880 if(numpathpoints>1&&pathpointselected!=-1){
7881 numpathpointconnect[pathpointselected]++;
7882 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
7884 pathpointselected=numpathpoints-1;
7887 drawmodetogglekeydown=1;
7890 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
7891 pathpointselected++;
7892 if(pathpointselected>=numpathpoints)pathpointselected=-1;
7893 drawmodetogglekeydown=1;
7895 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7896 pathpointselected--;
7897 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
7898 drawmodetogglekeydown=1;
7900 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
7901 if(pathpointselected!=-1){
7903 pathpoint[pathpointselected]=pathpoint[numpathpoints];
7904 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
7905 for(i=0;i<numpathpointconnect[pathpointselected];i++){
7906 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
7908 for(i=0;i<numpathpoints;i++){
7909 for(j=0;j<numpathpointconnect[i];j++){
7910 if(pathpointconnect[i][j]==pathpointselected){
7911 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
7912 numpathpointconnect[i]--;
7914 if(pathpointconnect[i][j]==numpathpoints){
7915 pathpointconnect[i][j]=pathpointselected;
7919 pathpointselected=numpathpoints-1;
7921 drawmodetogglekeydown=1;
7924 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7925 editorenabled=1-editorenabled;
7927 player[0].damagetolerance=100000;
7929 player[0].superpermanentdamage=0;
7930 player[0].bloodloss=0;
7931 player[0].deathbleeding=0;
7934 player[0].damagetolerance=200;
7936 player[0].permanentdamage=0;
7937 player[0].superpermanentdamage=0;
7938 player[0].bloodloss=0;
7939 player[0].deathbleeding=0;
7941 drawmodetogglekeydown=1;
7944 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7946 if(editortype==treeleavestype||editortype==10)editortype--;
7947 if(editortype<0)editortype=firetype;
7948 drawmodetogglekeydown=1;
7951 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7953 if(editortype==treeleavestype||editortype==10)editortype++;
7954 if(editortype>firetype)editortype=0;
7955 drawmodetogglekeydown=1;
7958 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7959 editorrotation-=multiplier*100;
7960 if(editorrotation<-.01)editorrotation=-.01;
7961 drawmodetogglekeydown=1;
7964 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7965 editorrotation+=multiplier*100;
7966 drawmodetogglekeydown=1;
7969 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7970 editorsize+=multiplier;
7971 drawmodetogglekeydown=1;
7974 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7975 editorsize-=multiplier;
7976 if(editorsize<.1)editorsize=.1;
7977 drawmodetogglekeydown=1;
7981 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7982 mapradius-=multiplier*10;
7985 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7986 mapradius+=multiplier*10;
7989 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7990 mapcenter.x+=multiplier*20;
7993 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7994 mapcenter.x-=multiplier*20;
7997 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7998 mapcenter.z+=multiplier*20;
8001 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8002 mapcenter.z-=multiplier*20;
8005 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8006 editorrotation2+=multiplier*100;
8009 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8010 editorrotation2-=multiplier*100;
8011 if(editorrotation2<-.01)editorrotation2=-.01;
8013 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8015 float closestdist=-1;
8017 for(i=0;i<objects.numobjects;i++){
8018 distance=findDistancefast(&objects.position[i],&player[0].coords);
8019 if(closestdist==-1||distance<closestdist){
8020 closestdist=distance;
8024 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8025 drawmodetogglekeydown=1;
8029 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)){
8030 drawmodetogglekeydown=0;
8033 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8034 //if(!player[0].skeleton.free)player[0].damage+=500;
8035 player[0].RagDoll(0);
8036 //player[0].spurt=1;
8037 //player[0].DoDamage(1000);
8041 gLoc[0]=player[0].coords.x;
8042 gLoc[1]=player[0].coords.y;
8043 gLoc[2]=player[0].coords.z;
8044 vel[0]=player[0].velocity.x;
8045 vel[1]=player[0].velocity.y;
8046 vel[2]=player[0].velocity.z;
8047 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
8048 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8049 OPENAL_SetVolume(channels[whooshsound], 128);
8050 OPENAL_SetPaused(channels[whooshsound], false);
8051 //OPENAL_SetPaused(channels[whooshsound], true);
8053 texturesizetogglekeydown=1;
8056 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8059 float closestdist=-1;
8061 for(i=0;i<objects.numobjects;i++){
8062 if(objects.type[i]==treeleavestype){
8063 objects.scale[i]*=.9;
8066 texturesizetogglekeydown=1;
8069 static XYZ relative;
8070 static int randattack;
8072 static bool playerrealattackkeydown=0;
8074 if(!buttons[0])oldbutton=0;
8075 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8076 if(oldattackkey)player[0].attackkeydown=0;
8077 if(oldattackkey)playerrealattackkeydown=0;
8078 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8079 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);
8080 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8081 for(k=0;k<numplayers;k++){
8082 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8083 player[k].Reverse();
8087 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8089 for(k=0;k<numplayers;k++){
8090 if(indialogue!=-1)player[k].attackkeydown=0;
8091 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8092 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8093 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)){
8094 player[k].jumppower-=2;
8096 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)){
8097 for(i=0;i<numplayers;i++){
8099 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8100 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8101 player[k].targetanimation=dodgebackanim;
8103 player[k].targetframe=0;
8104 rotatetarget=player[i].coords-player[k].coords;
8105 Normalise(&rotatetarget);
8106 player[k].targetrotation=-asin(0-rotatetarget.x);
8107 player[k].targetrotation*=360/6.28;
8108 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8110 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8113 if(player[k].targetanimation!=dodgebackanim){
8114 if(k==0)numflipped++;
8115 player[k].targetanimation=backhandspringanim;
8117 player[k].targetframe=0;
8118 player[k].targetrotation=-rotation+180;
8119 if(player[k].leftkeydown)player[k].targetrotation-=45;
8120 if(player[k].rightkeydown)player[k].targetrotation+=45;
8121 player[k].rotation=player[k].targetrotation;
8122 player[k].jumppower-=2;
8125 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())){
8126 player[k].hasvictim=0;
8128 for(i=0;i<numplayers;i++){
8130 if(!player[k].hasvictim)
8131 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8132 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){
8133 player[k].victim=&player[i];
8134 player[k].hasvictim=1;
8135 if(player[k].aitype==playercontrolled){
8136 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;
8137 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;
8138 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;
8139 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;
8140 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;
8141 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;
8142 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;
8143 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;
8144 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;
8145 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;
8148 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8149 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8150 else randattack=abs(Random()%5);
8151 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8152 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8153 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8154 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8155 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8157 if(player[k].weaponactive!=-1){
8158 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;
8159 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;
8160 //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;
8161 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;
8162 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;
8163 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;
8164 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;
8165 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;
8169 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8171 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)){
8172 if(player[k].weaponactive==-1){
8173 player[i].targetanimation=sneakattackedanim;
8174 player[i].currentanimation=sneakattackedanim;
8175 player[k].currentanimation=sneakattackanim;
8176 player[k].targetanimation=sneakattackanim;
8177 player[k].oldcoords=player[k].coords;
8178 player[k].coords=player[i].coords;
8180 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8181 player[i].targetanimation=knifesneakattackedanim;
8182 player[i].currentanimation=knifesneakattackedanim;
8183 player[k].currentanimation=knifesneakattackanim;
8184 player[k].targetanimation=knifesneakattackanim;
8185 player[i].oldcoords=player[i].coords;
8186 player[i].coords=player[k].coords;
8188 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8189 player[i].targetanimation=swordsneakattackedanim;
8190 player[i].currentanimation=swordsneakattackedanim;
8191 player[k].currentanimation=swordsneakattackanim;
8192 player[k].targetanimation=swordsneakattackanim;
8193 player[i].oldcoords=player[i].coords;
8194 player[i].coords=player[k].coords;
8196 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8197 player[k].victim=&player[i];
8198 player[k].hasvictim=1;
8199 player[i].targettilt2=0;
8200 player[i].targetframe=1;
8201 player[i].currentframe=0;
8203 player[i].velocity=0;
8204 player[k].targettilt2=player[i].targettilt2;
8205 player[k].currentframe=player[i].currentframe;
8206 player[k].targetframe=player[i].targetframe;
8207 player[k].target=player[i].target;
8208 player[k].velocity=0;
8209 player[k].targetrotation=player[i].rotation;
8210 player[k].rotation=player[i].rotation;
8211 player[i].targetrotation=player[i].rotation;
8214 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8216 player[k].targetframe=0;
8218 //player[k].velocity=0;
8220 rotatetarget=player[i].coords-player[k].coords;
8221 Normalise(&rotatetarget);
8222 player[k].targetrotation=-asin(0-rotatetarget.x);
8223 player[k].targetrotation*=360/6.28;
8224 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8226 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8228 player[k].lastattack3=player[k].lastattack2;
8229 player[k].lastattack2=player[k].lastattack;
8230 player[k].lastattack=player[k].targetanimation;
8231 //player[k].targettilt2=0;
8235 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8236 rotatetarget=player[i].coords-player[k].coords;
8237 Normalise(&rotatetarget);
8238 player[k].targetrotation=-asin(0-rotatetarget.x);
8239 player[k].targetrotation*=360/6.28;
8240 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8241 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8243 player[k].victim=&player[i];
8244 player[k].hasvictim=1;
8245 player[i].targetanimation=knifefollowedanim;
8246 player[i].currentanimation=knifefollowedanim;
8247 player[i].targettilt2=0;
8248 player[i].targettilt2=player[k].targettilt2;
8249 player[i].targetframe=1;
8250 player[i].currentframe=0;
8252 player[i].velocity=0;
8253 player[k].currentanimation=knifefollowanim;
8254 player[k].targetanimation=knifefollowanim;
8255 player[k].targettilt2=player[i].targettilt2;
8256 player[k].currentframe=player[i].currentframe;
8257 player[k].targetframe=player[i].targetframe;
8258 player[k].target=player[i].target;
8259 player[k].velocity=0;
8260 player[k].oldcoords=player[k].coords;
8261 player[i].coords=player[k].coords;
8262 player[i].targetrotation=player[k].targetrotation;
8263 player[i].rotation=player[k].targetrotation;
8264 player[k].rotation=player[k].targetrotation;
8265 player[i].rotation=player[k].targetrotation;
8270 if(player[k].weaponactive!=-1){
8271 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8274 for(i=0;i<numplayers;i++){
8276 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8277 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8278 if(player[i].skeleton.free)
8279 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)))){
8280 player[k].victim=&player[i];
8281 player[k].hasvictim=1;
8282 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8283 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;
8284 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;
8285 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;
8287 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){
8288 player[k].targetanimation=killanim;
8289 for(j=0;j<terrain.numdecals;j++){
8290 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8291 terrain.DeleteDecal(j);
8294 for(l=0;l<objects.numobjects;l++){
8295 if(objects.model[l].type==decalstype)
8296 for(j=0;j<objects.model[l].numdecals;j++){
8297 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8298 objects.model[l].DeleteDecal(j);
8303 if(!player[i].dead||musictype!=2)
8304 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)){
8305 player[k].targetanimation=dropkickanim;
8306 for(j=0;j<terrain.numdecals;j++){
8307 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8308 terrain.DeleteDecal(j);
8311 for(l=0;l<objects.numobjects;l++){
8312 if(objects.model[l].type==decalstype)
8313 for(j=0;j<objects.model[l].numdecals;j++){
8314 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8315 objects.model[l].DeleteDecal(j);
8321 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)){
8323 player[k].targetframe=0;
8325 //player[k].velocity=0;
8327 rotatetarget=player[i].coords-player[k].coords;
8328 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8329 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;
8331 Normalise(&rotatetarget);
8332 player[k].targetrotation=-asin(0-rotatetarget.x);
8333 player[k].targetrotation*=360/6.28;
8334 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8336 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8337 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8340 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8341 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8343 player[k].lastattack3=player[k].lastattack2;
8344 player[k].lastattack2=player[k].lastattack;
8345 player[k].lastattack=player[k].targetanimation;
8347 if(player[k].targetanimation==swordgroundstabanim){
8348 player[k].targetrotation+=30;
8350 //player[k].targettilt2=0;
8356 if(!player[k].hasvictim){
8357 for(i=0;i<numplayers;i++){
8358 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8359 player[k].victim=&player[i];
8360 player[k].hasvictim=1;
8362 if(player[k].hasvictim&&!player[i].skeleton.free)
8363 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8364 player[k].victim=&player[i];
8368 if(player[k].aitype==playercontrolled)
8369 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)){
8371 player[k].targetanimation=rabbitkickanim;
8372 player[k].targetframe=0;
8375 if(animation[player[k].targetanimation].attack&&k==0){
8378 if(player[k].weaponactive!=-1){
8379 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8382 if(player[k].weaponactive!=-1){
8383 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8386 if(player[k].weaponactive!=-1){
8387 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8389 if(armedstaff)numstaffattack++;
8390 else if(armedsword)numswordattack++;
8391 else if(armedknife)numknifeattack++;
8392 else numunarmedattack++;
8399 static float collisionradius;
8401 for(k=0;k<numplayers;k++){
8402 for(i=k;i<numplayers;i++){
8405 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))
8406 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))
8407 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8408 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8409 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)
8410 if(player[i].coords.y>player[k].coords.y-3)
8411 if(player[i].coords.y<player[k].coords.y+3)
8412 if(player[i].coords.x>player[k].coords.x-3)
8413 if(player[i].coords.x<player[k].coords.x+3)
8414 if(player[i].coords.z>player[k].coords.z-3)
8415 if(player[i].coords.z<player[k].coords.z+3){
8416 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)){
8417 if(player[i].onfire||player[k].onfire){
8418 if(!player[i].onfire)player[i].CatchFire();
8419 if(!player[k].onfire)player[k].CatchFire();
8423 tempcoords1=player[i].coords;
8424 tempcoords2=player[k].coords;
8425 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8426 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8427 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8428 if(player[0].hasvictim)
8429 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8430 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8432 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)){
8433 player[k].coords.y=player[i].coords.y;
8434 player[i].velocity=player[k].velocity;
8435 player[i].skeleton.free=0;
8436 player[i].rotation=0;
8437 player[i].RagDoll(0);
8438 player[i].DoDamage(20);
8439 if(k==0)camerashake+=.3;
8440 player[i].skeleton.longdead=0;
8441 player[k].lastcollide=1;
8444 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)){
8445 player[i].coords.y=player[k].coords.y;
8446 player[k].velocity=player[i].velocity;
8447 player[k].skeleton.free=0;
8448 player[k].rotation=0;
8449 player[k].RagDoll(0);
8450 player[k].DoDamage(20);
8451 if(i==0)camerashake+=.3;
8452 player[k].skeleton.longdead=0;
8453 player[i].lastcollide=1;
8456 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)){
8457 rotatetarget=player[k].velocity-player[i].velocity;
8458 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))
8459 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))){
8461 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)){
8462 static float gLoc[3];
8463 static float vel[3];
8464 gLoc[0]=player[i].coords.x;
8465 gLoc[1]=player[i].coords.y;
8466 gLoc[2]=player[i].coords.z;
8467 vel[0]=player[i].velocity.x;
8468 vel[1]=player[i].velocity.y;
8469 vel[2]=player[i].velocity.z;
8470 if(tutoriallevel!=1){
8471 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8472 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8473 OPENAL_SetVolume(channels[heavyimpactsound], 256);
8474 OPENAL_SetPaused(channels[heavyimpactsound], false);
8476 //player[i].velocity=player[k].velocity;
8477 //player[k].velocity=player[i].velocity;
8479 player[i].RagDoll(0);
8480 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8485 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8486 player[k].RagDoll(0);
8487 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8492 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8494 //if(player[i].skeleton.oldfree){
8495 for(j=0;j<player[i].skeleton.num_joints;j++){
8496 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8499 //if(player[k].skeleton.oldfree){
8500 for(j=0;j<player[k].skeleton.num_joints;j++){
8501 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8507 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)){
8509 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8510 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)){
8511 rotatetarget=player[k].coords-player[i].coords;
8512 Normalise(&rotatetarget);
8513 player[k].coords=(player[k].coords+player[i].coords)/2;
8514 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);
8515 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8516 if(player[k].howactive==typeactive||hostile)
8517 if(player[k].isIdle()){
8518 if(player[k].howactive<typesleeping){
8519 player[k].targetanimation=player[k].getStop();
8520 player[k].targetframe=0;
8523 else if(player[k].howactive==typesleeping)
8525 player[k].targetanimation=getupfromfrontanim;
8526 player[k].targetframe=0;
8529 if(!editorenabled)player[k].howactive=typeactive;
8531 if(player[i].howactive==typeactive||hostile)
8532 if(player[i].isIdle()){
8533 if(player[i].howactive<typesleeping){
8534 player[i].targetanimation=player[i].getStop();
8535 player[i].targetframe=0;
8540 player[i].targetanimation=getupfromfrontanim;
8541 player[i].targetframe=0;
8544 if(!editorenabled)player[i].howactive=typeactive;
8548 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){
8549 player[i].velocity=player[k].velocity;
8550 player[k].velocity=player[k].velocity*-.5;
8551 //player[i].velocity.y-=10;
8552 player[k].velocity.y=player[i].velocity.y;
8553 player[i].DoDamage(20);
8554 player[i].RagDoll(0);
8555 player[k].lastcollide=1;
8562 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){
8563 player[k].velocity=player[i].velocity;
8564 player[i].velocity=player[i].velocity*-.3;
8565 //player[k].velocity.y-=10;
8566 player[i].velocity.y=player[k].velocity.y;
8567 player[k].DoDamage(20);
8568 player[k].RagDoll(0);
8569 player[i].lastcollide=1;
8580 player[i].CheckKick();
8581 player[k].CheckKick();
8587 for(k=0;k<numplayers;k++){
8588 for(i=k;i<numplayers;i++){
8590 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))){
8591 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)){
8592 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)){
8593 player[i].victim=&player[k];
8594 player[i].targetanimation=jumpreversedanim;
8595 player[i].currentanimation=jumpreversedanim;
8596 player[k].currentanimation=jumpreversalanim;
8597 player[k].targetanimation=jumpreversalanim;
8598 player[i].targettilt2=0;
8599 player[i].currentframe=0;
8600 player[i].targetframe=1;
8601 player[k].currentframe=0;
8602 player[k].targetframe=1;
8603 if(player[i].coords.y<player[k].coords.y+1){
8604 player[i].targetanimation=rabbitkickreversedanim;
8605 player[i].currentanimation=rabbitkickreversedanim;
8606 player[k].currentanimation=rabbitkickreversalanim;
8607 player[k].targetanimation=rabbitkickreversalanim;
8608 player[k].currentframe=1;
8609 player[k].targetframe=2;
8610 player[i].currentframe=1;
8611 player[i].targetframe=2;
8613 player[k].targettilt2=0;
8615 player[i].velocity=0;
8616 player[k].velocity=0;
8617 player[k].oldcoords=player[k].coords;
8618 player[i].coords=player[k].coords;
8619 player[k].targetrotation=player[i].targetrotation;
8620 player[k].rotation=player[i].targetrotation;
8621 player[k].victim=&player[i];
8622 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8624 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)){
8625 player[k].victim=&player[i];
8626 player[k].targetanimation=jumpreversedanim;
8627 player[k].currentanimation=jumpreversedanim;
8628 player[i].currentanimation=jumpreversalanim;
8629 player[i].targetanimation=jumpreversalanim;
8630 player[k].targettilt2=0;
8631 player[i].targettilt2=0;
8632 player[k].currentframe=0;
8633 player[k].targetframe=1;
8634 player[i].currentframe=0;
8635 player[i].targetframe=1;
8636 if(player[k].coords.y<player[i].coords.y+1){
8637 player[k].targetanimation=rabbitkickreversedanim;
8638 player[k].currentanimation=rabbitkickreversedanim;
8639 player[i].currentanimation=rabbitkickreversalanim;
8640 player[i].targetanimation=rabbitkickreversalanim;
8641 player[k].currentframe=1;
8642 player[k].targetframe=2;
8643 player[i].currentframe=1;
8644 player[i].targetframe=2;
8647 player[k].velocity=0;
8648 player[i].velocity=0;
8649 player[i].oldcoords=player[i].coords;
8650 player[k].coords=player[i].coords;
8651 player[i].targetrotation=player[k].targetrotation;
8652 player[i].rotation=player[k].targetrotation;
8653 player[i].victim=&player[k];
8654 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8661 for(k=0;k<numplayers;k++)
8662 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8671 static float checkdelay;
8672 checkdelay-=multiplier;
8674 static bool checkedcoll[maxplayers][maxplayers];
8675 static bool above[maxplayers];
8677 for(i=0;i<maxplayers;i++){
8678 for(j=0;j<maxplayers;j++){
8679 checkedcoll[i][j]=0;
8683 if(numplayers>1&&checkdelay<=0){
8685 for(k=0;k<numplayers;k++){
8686 if(player[k].skeleton.free!=2)above[k]=-1;
8688 for(i=k;i<numplayers;i++){
8691 if(!checkedcoll[i][k]){
8692 checkedcoll[i][k]=1;
8693 checkedcoll[k][i]=1;
8694 if(player[i].skeleton.free&&player[k].skeleton.free)
8695 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8696 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8697 if(player[i].coords.y>player[k].coords.y-3)
8698 if(player[i].coords.y<player[k].coords.y+3)
8699 if(player[i].coords.x>player[k].coords.x-3)
8700 if(player[i].coords.x<player[k].coords.x+3)
8701 if(player[i].coords.z>player[k].coords.z-3)
8702 if(player[i].coords.z<player[k].coords.z+3)
8703 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)){
8705 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
8717 above[moving]=stuck;
8718 for(l=0;l<player[moving].skeleton.num_joints;l++){
8719 for(m=0;m<player[stuck].skeleton.num_joints;m++){
8720 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
8722 player[moving].skeleton.joints[l].position.y+=.003;
8723 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
8737 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
8738 texturesizetogglekeydown=0;
8741 for(k=0;k<numplayers;k++){
8742 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8743 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
8744 player[k].DoDamage(1000);
8749 static bool respawnkeydown;
8750 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
8751 targetlevel=whichlevel;
8755 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
8756 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
8761 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
8763 if(targetlevel>numchallengelevels-1)targetlevel=0;
8766 slomotogglekeydown=1;
8770 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
8772 OPENAL_SetPaused(channels[whooshsound], true);
8774 for(k=0;k<numplayers;k++){
8777 player[k].permanentdamage=0;
8778 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
8779 player[k].aitype=passivetype;
8781 player[0].aitype=playercontrolled;
8785 static bool movekey;
8786 static bool connected;
8787 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
8788 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
8789 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
8790 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
8791 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
8792 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
8794 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
8796 for(int i=0;i<numplayers;i++){
8797 if(!player[i].skeleton.free){
8798 oldtargetrotation=player[i].targetrotation;
8799 if(i==0&&indialogue==-1){
8800 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){
8801 if(!cameramode)player[0].targetrotation=-rotation+180;
8802 if(cameramode)player[0].targetrotation=0;
8808 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8809 if(cameramode){facing=flatfacing;}
8811 facing=DoRotation(facing,-rotation2,0,0);
8812 facing=DoRotation(facing,0,0-rotation,0);
8815 player[0].lookrotation=-rotation;
8817 player[i].targetheadrotation=rotation;
8818 player[i].targetheadrotation2=rotation2;
8820 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
8821 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){
8822 player[i].targetrotation=-player[i].lookrotation+180;
8828 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
8830 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
8831 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
8833 player[i].targetheadrotation=player[i].lookrotation;
8834 player[i].targetheadrotation2=player[i].lookrotation2;
8837 rotatetarget=participantfacing[whichdialogue][indialogue][i];
8838 Normalise(&rotatetarget);
8839 player[i].targetheadrotation=-asin(0-rotatetarget.x);
8840 player[i].targetheadrotation*=360/6.28;
8841 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
8843 player[i].targetheadrotation*=-1;
8844 player[i].targetheadrotation+=180;
8845 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
8853 player[i].avoidsomething=0;
8855 for(j=0;j<objects.numobjects;j++){
8856 if(objects.onfire[j]){
8857 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
8859 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
8860 player[i].collided=0;
8861 player[i].avoidcollided=1;
8862 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8863 player[i].avoidwhere=objects.position[j];
8869 //Add avoidwhere to players
8871 for(j=0;j<numplayers;j++){
8872 if(player[j].onfire){
8873 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
8875 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
8876 player[i].collided=0;
8877 player[i].avoidcollided=1;
8878 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
8879 player[i].avoidwhere=objects.position[j];
8885 if(player[i].collided>.8)player[i].avoidcollided=0;
8886 if(player[i].aitype!=playercontrolled&&indialogue==-1){
8887 player[i].jumpclimb=0;
8889 if(editorenabled)player[i].stunned=1;
8892 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
8893 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;
8895 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
8896 player[i].forwardkeydown=0;
8897 player[i].leftkeydown=0;
8898 player[i].backkeydown=0;
8899 player[i].rightkeydown=0;
8900 player[i].crouchkeydown=0;
8901 player[i].attackkeydown=0;
8902 player[i].jumpkeydown=0;
8903 player[i].throwkeydown=0;
8906 if(player[i].aitype==pathfindtype){
8907 if(player[i].finalpathfindpoint==-1){
8908 float closestdistance;
8914 for(j=0;j<numpathpoints;j++){
8915 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
8916 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
8918 player[i].finaltarget=pathpoint[j];
8921 player[i].finalpathfindpoint=closest;
8922 for(j=0;j<numpathpoints;j++){
8923 if(numpathpointconnect[j])
8924 for(k=0;k<numpathpointconnect[j];k++){
8925 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8926 if(tempdist*tempdist<closestdistance){
8927 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8928 closestdistance=tempdist*tempdist;
8930 player[i].finaltarget=colpoint;
8935 player[i].finalpathfindpoint=closest;
8938 if(player[i].targetpathfindpoint==-1){
8939 float closestdistance;
8945 if(player[i].lastpathfindpoint==-1){
8946 for(j=0;j<numpathpoints;j++){
8947 if(j!=player[i].lastpathfindpoint)
8948 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
8949 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
8953 player[i].targetpathfindpoint=closest;
8954 for(j=0;j<numpathpoints;j++){
8955 if(j!=player[i].lastpathfindpoint)
8956 if(numpathpointconnect[j])
8957 for(k=0;k<numpathpointconnect[j];k++){
8958 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
8959 if(tempdist*tempdist<closestdistance){
8960 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
8961 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
8962 closestdistance=tempdist*tempdist;
8969 player[i].targetpathfindpoint=closest;
8973 for(j=0;j<numpathpoints;j++){
8974 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
8977 if(numpathpointconnect[j])
8978 for(k=0;k<numpathpointconnect[j];k++){
8979 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
8982 if(numpathpointconnect[player[i].lastpathfindpoint])
8983 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
8984 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
8987 tempdist=findPathDist(j,player[i].finalpathfindpoint);
8988 if(closest==-1||tempdist<closestdistance){
8989 closestdistance=tempdist;
8995 player[i].targetpathfindpoint=closest;
8998 player[i].losupdatedelay-=multiplier;
9000 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9001 Normalise(&rotatetarget);
9002 player[i].targetrotation=-asin(0-rotatetarget.x);
9003 player[i].targetrotation*=360/6.28;
9004 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9005 player[i].lookrotation=player[i].targetrotation;
9006 //player[i].aiupdatedelay=.05;
9008 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9009 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9010 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9011 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9012 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9013 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9014 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9015 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9016 player[i].targetpathfindpoint=-1;
9018 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){
9019 player[i].aitype=passivetype;
9022 player[i].forwardkeydown=1;
9023 player[i].leftkeydown=0;
9024 player[i].backkeydown=0;
9025 player[i].rightkeydown=0;
9026 player[i].crouchkeydown=0;
9027 player[i].attackkeydown=0;
9028 player[i].throwkeydown=0;
9030 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9032 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9033 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9035 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9036 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))
9037 player[i].aitype=attacktypecutoff;
9038 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9039 player[i].aitype=attacktypecutoff;
9041 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9042 player[i].losupdatedelay=.2;
9043 for(j=0;j<numplayers;j++){
9044 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9045 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9046 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9047 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9048 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9049 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)){
9050 player[i].aitype=searchtype;
9051 player[i].lastchecktime=12;
9052 player[i].lastseen=player[j].coords;
9053 player[i].lastseentime=12;
9059 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9060 if(player[i].creature!=wolftype){
9061 player[i].stunned=.6;
9062 player[i].surprised=.6;
9067 if(player[i].aitype!=passivetype&&leveltime>.5){
9068 player[i].howactive=typeactive;
9071 if(player[i].aitype==passivetype){
9072 player[i].aiupdatedelay-=multiplier;
9073 player[i].losupdatedelay-=multiplier;
9074 player[i].lastseentime+=multiplier;
9075 player[i].pausetime-=multiplier;
9076 if(player[i].lastseentime>1)player[i].lastseentime=1;
9078 if(player[i].aiupdatedelay<0){
9079 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9080 rotatetarget=player[i].waypoints[player[i].waypoint]-player[i].coords;
9081 Normalise(&rotatetarget);
9082 player[i].targetrotation=-asin(0-rotatetarget.x);
9083 player[i].targetrotation*=360/6.28;
9084 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9085 player[i].lookrotation=player[i].targetrotation;
9086 player[i].aiupdatedelay=.05;
9088 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9089 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9090 player[i].waypoint++;
9091 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9096 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9097 else player[i].forwardkeydown=0;
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;
9124 if(player[i].howactive<typesleeping)
9125 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9126 for(j=0;j<numenvsounds;j++){
9127 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9128 player[i].aitype=attacktypecutoff;
9132 if(player[i].howactive==typesleeping)
9133 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9134 for(j=0;j<numenvsounds;j++){
9135 if(envsoundvol[j]>14)
9136 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9137 player[i].aitype=attacktypecutoff;
9141 if(player[i].aitype!=passivetype){
9142 if(player[i].howactive==typesleeping){
9143 player[i].targetanimation=getupfromfrontanim;
9144 player[i].targetframe=0;
9148 player[i].howactive=typeactive;
9152 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9153 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9154 player[i].aitype=attacktypecutoff;
9155 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9156 player[i].aitype=attacktypecutoff;
9158 if(player[i].creature==wolftype){
9160 float smelldistance;
9162 for(j=0;j<numplayers;j++){
9163 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9164 if(j==0&&player[j].num_weapons>0){
9165 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9166 if(player[j].num_weapons==2)
9167 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9172 windsmell=windvector;
9173 Normalise(&windsmell);
9174 windsmell=windsmell*2+player[j].coords;
9175 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9176 player[i].aitype=attacktypecutoff;
9181 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9182 player[i].losupdatedelay=.2;
9183 for(j=0;j<numplayers;j++){
9184 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9185 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9186 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9187 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9188 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)){
9189 player[i].lastseentime-=.2;
9190 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9191 else player[i].lastseentime-=.6;
9193 if(player[i].lastseentime<=0){
9194 player[i].aitype=searchtype;
9195 player[i].lastchecktime=12;
9196 player[i].lastseen=player[j].coords;
9197 player[i].lastseentime=12;
9203 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9204 if(player[i].creature!=wolftype){
9205 player[i].stunned=.6;
9206 player[i].surprised=.6;
9208 if(player[i].creature==wolftype){
9209 player[i].stunned=.47;
9210 player[i].surprised=.47;
9216 if(player[i].aitype==searchtype){
9217 player[i].aiupdatedelay-=multiplier;
9218 player[i].losupdatedelay-=multiplier;
9219 if(!player[i].pause)player[i].lastseentime-=multiplier;
9220 player[i].lastchecktime-=multiplier;
9222 if(player[i].isRun()&&!player[i].onground){
9223 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9224 test2=player[i].coords+player[i].facing;
9226 test=player[i].coords+player[i].facing;
9228 j=checkcollide(test2,test,player[i].laststanding);
9229 if(j==-1)j=checkcollide(test2,test);
9231 player[i].velocity=0;
9232 player[i].targetanimation=player[i].getStop();
9233 player[i].targetframe=0;
9235 player[i].targetrotation+=180;
9236 player[i].stunned=.5;
9237 //player[i].aitype=passivetype;
9238 player[i].aitype=pathfindtype;
9239 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9240 player[i].finalpathfindpoint=-1;
9241 player[i].targetpathfindpoint=-1;
9242 player[i].lastpathfindpoint=-1;
9243 player[i].lastpathfindpoint2=-1;
9244 player[i].lastpathfindpoint3=-1;
9245 player[i].lastpathfindpoint4=-1;
9247 else player[i].laststanding=j;
9250 if(player[i].aiupdatedelay<0){
9251 rotatetarget=player[i].lastseen-player[i].coords;
9252 Normalise(&rotatetarget);
9253 player[i].targetrotation=-asin(0-rotatetarget.x);
9254 player[i].targetrotation*=360/6.28;
9255 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9256 player[i].lookrotation=player[i].targetrotation;
9257 player[i].aiupdatedelay=.05;
9258 player[i].forwardkeydown=1;
9260 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9261 player[i].forwardkeydown=0;
9262 player[i].aiupdatedelay=1;
9263 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9264 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9265 player[i].lastchecktime=3;
9268 player[i].leftkeydown=0;
9269 player[i].backkeydown=0;
9270 player[i].rightkeydown=0;
9271 player[i].crouchkeydown=0;
9272 player[i].attackkeydown=0;
9273 player[i].throwkeydown=0;
9275 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9276 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9278 XYZ leftpos,rightpos;
9279 float leftdist,rightdist;
9280 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9281 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9282 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9283 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9284 if(leftdist<rightdist)player[i].targetrotation+=90;
9285 else player[i].targetrotation-=90;
9289 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9290 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9292 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9293 for(j=0;j<numenvsounds;j++){
9294 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9295 player[i].aitype=attacktypecutoff;
9299 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9300 player[i].losupdatedelay=.2;
9301 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9302 {player[i].aitype=attacktypecutoff;
9303 player[i].lastseentime=1;}
9304 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9305 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9306 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9307 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)){
9308 player[i].aitype=attacktypecutoff;
9309 player[i].lastseentime=1;
9312 if(player[i].lastseentime<0){
9313 //player[i].aitype=passivetype;
9315 player[i].aitype=pathfindtype;
9316 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9317 player[i].finalpathfindpoint=-1;
9318 player[i].targetpathfindpoint=-1;
9319 player[i].lastpathfindpoint=-1;
9320 player[i].lastpathfindpoint2=-1;
9321 player[i].lastpathfindpoint3=-1;
9322 player[i].lastpathfindpoint4=-1;
9326 if(player[i].aitype!=gethelptype){
9327 player[i].runninghowlong=0;
9330 if(player[i].aitype==gethelptype){
9331 player[i].runninghowlong+=multiplier;
9332 player[i].aiupdatedelay-=multiplier;
9334 if(player[i].aiupdatedelay<0||player[i].ally==0){
9335 player[i].aiupdatedelay=.2;
9343 if(!player[i].ally){
9344 for(j=0;j<numplayers;j++){
9345 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9346 distance=findDistancefast(&player[i].coords,&player[j].coords);
9347 if(closestdist==-1||distance<closestdist){
9348 closestdist=distance;
9354 if(closest!=-1)player[i].ally=closest;
9355 else player[i].ally=0;
9356 player[i].lastseen=player[0].coords;
9357 player[i].lastseentime=12;
9361 player[i].lastchecktime=12;
9362 //player[i].lastseentime-=.5;
9364 facing=player[i].coords;
9365 flatfacing=player[player[i].ally].coords;
9366 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9367 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9368 if(-1!=checkcollide(facing,flatfacing))
9369 player[i].lastseentime-=.1;
9371 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9372 player[i].aitype=searchtype;
9373 player[i].lastseentime=12;
9376 if(player[i].ally>0){
9377 rotatetarget=player[player[i].ally].coords-player[i].coords;
9378 Normalise(&rotatetarget);
9379 player[i].targetrotation=-asin(0-rotatetarget.x);
9380 player[i].targetrotation*=360/6.28;
9381 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9382 player[i].lookrotation=player[i].targetrotation;
9383 player[i].aiupdatedelay=.05;
9384 player[i].forwardkeydown=1;
9386 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9387 player[i].aitype=searchtype;
9388 player[i].lastseentime=12;
9389 player[player[i].ally].aitype=searchtype;
9390 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9391 player[player[i].ally].lastseen=player[i].lastseen;
9392 player[player[i].ally].lastseentime=player[i].lastseentime;
9393 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9397 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9398 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9400 XYZ leftpos,rightpos;
9401 float leftdist,rightdist;
9402 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9403 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9404 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9405 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9406 if(leftdist<rightdist)player[i].targetrotation+=90;
9407 else player[i].targetrotation-=90;
9412 player[i].leftkeydown=0;
9413 player[i].backkeydown=0;
9414 player[i].rightkeydown=0;
9415 player[i].crouchkeydown=0;
9416 player[i].attackkeydown=0;
9418 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9419 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9422 if(player[i].aitype==getweapontype){
9423 player[i].aiupdatedelay-=multiplier;
9424 player[i].lastchecktime-=multiplier;
9426 if(player[i].aiupdatedelay<0){
9427 player[i].aiupdatedelay=.2;
9435 if(player[i].ally<0){
9436 for(j=0;j<weapons.numweapons;j++){
9437 if(weapons.owner[j]==-1){
9438 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9439 if(closestdist==-1||distance<closestdist){
9440 closestdist=distance;
9446 if(closest!=-1)player[i].ally=closest;
9447 else player[i].ally=-1;
9450 player[i].lastseentime=12;
9452 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9453 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9454 player[i].aitype=attacktypecutoff;
9455 player[i].lastseentime=1;
9458 if(player[i].ally>=0){
9459 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9460 player[i].aitype=attacktypecutoff;
9461 player[i].lastseentime=1;
9463 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9464 Normalise(&rotatetarget);
9465 player[i].targetrotation=-asin(0-rotatetarget.x);
9466 player[i].targetrotation*=360/6.28;
9467 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9468 player[i].lookrotation=player[i].targetrotation;
9469 player[i].aiupdatedelay=.05;
9470 player[i].forwardkeydown=1;
9473 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9474 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9476 XYZ leftpos,rightpos;
9477 float leftdist,rightdist;
9478 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9479 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9480 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9481 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9482 if(leftdist<rightdist)player[i].targetrotation+=90;
9483 else player[i].targetrotation-=90;
9486 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9487 if(abs(Random()%6)){
9488 player[i].crouchkeydown=1;
9489 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9490 if(player[i].isRun()){
9491 player[i].targetframe=0;
9493 player[i].targetanimation=sneakanim;
9496 else player[i].forwardkeydown=0;
9498 else player[i].crouchkeydown=0;
9500 else player[i].crouchkeydown=0;*/
9503 player[i].leftkeydown=0;
9504 player[i].backkeydown=0;
9505 player[i].rightkeydown=0;
9506 player[i].attackkeydown=0;
9507 player[i].throwkeydown=1;
9508 player[i].crouchkeydown=0;
9509 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9510 player[i].drawkeydown=0;
9512 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9513 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9516 if(player[i].aitype==attacktypecutoff){
9517 player[i].aiupdatedelay-=multiplier;
9518 if(player[i].damage<player[i].damagetolerance*2/3)
9519 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)){
9520 player[i].attackkeydown=0;
9521 if(player[i].isIdle())player[i].crouchkeydown=1;
9522 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9523 if(weapons.type[player[0].weaponids[0]]==knife){
9524 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9525 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9526 else player[i].targetanimation=rollanim;
9528 player[i].targetframe=0;
9529 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9530 player[i].wentforweapon=0;
9532 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9533 player[i].targetanimation=flipanim;
9535 player[i].targetframe=0;
9539 player[i].forwardkeydown=0;
9540 player[i].aiupdatedelay=.02;
9542 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9543 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9544 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9546 if(player[i].wentforweapon<3)
9547 for(j=0;j<weapons.numweapons;j++){
9548 if(player[i].creature!=wolftype)
9549 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){
9550 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9551 player[i].wentforweapon++;
9552 player[i].lastchecktime=6;
9553 player[i].aitype=getweapontype;
9558 if(player[i].damage<player[i].damagetolerance/2)
9559 if(animation[player[i].targetanimation].height!=highheight)
9560 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)))){
9561 player[i].crouchkeydown=1;
9563 if(player[i].isRun()&&!player[i].onground){
9564 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9565 test2=player[i].coords+player[i].facing;
9567 test=player[i].coords+player[i].facing;
9569 j=checkcollide(test2,test,player[i].laststanding);
9570 if(j==-1)j=checkcollide(test2,test);
9572 player[i].velocity=0;
9573 player[i].targetanimation=player[i].getStop();
9574 player[i].targetframe=0;
9576 player[i].targetrotation+=180;
9577 player[i].stunned=.5;
9578 //player[i].aitype=passivetype;
9579 player[i].aitype=pathfindtype;
9580 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9581 player[i].finalpathfindpoint=-1;
9582 player[i].targetpathfindpoint=-1;
9583 player[i].lastpathfindpoint=-1;
9584 player[i].lastpathfindpoint2=-1;
9585 player[i].lastpathfindpoint3=-1;
9586 player[i].lastpathfindpoint4=-1;
9588 else player[i].laststanding=j;
9591 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9592 player[i].aitype=pathfindtype;
9593 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9594 player[i].finalpathfindpoint=-1;
9595 player[i].targetpathfindpoint=-1;
9596 player[i].lastpathfindpoint=-1;
9597 player[i].lastpathfindpoint2=-1;
9598 player[i].lastpathfindpoint3=-1;
9599 player[i].lastpathfindpoint4=-1;
9601 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){
9602 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9603 else player[i].drawkeydown=0;
9604 player[i].rabbitkickenabled=Random()%2;
9605 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9606 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9607 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;
9608 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9609 Normalise(&rotatetarget);
9610 player[i].targetrotation=-asin(0-rotatetarget.x);
9611 player[i].targetrotation*=360/6.28;
9612 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9613 player[i].lookrotation=player[i].targetrotation;
9614 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9616 oldkey=player[i].forwardkeydown;
9617 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9618 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;
9619 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9620 else player[i].forwardkeydown=0;
9622 player[i].forwardkeydown=0;
9623 if(Random()%10==0)player[i].forwardkeydown=1;
9624 if(Random()%100==0){
9625 player[i].aitype=pathfindtype;
9626 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9627 player[i].finalpathfindpoint=-1;
9628 player[i].targetpathfindpoint=-1;
9629 player[i].lastpathfindpoint=-1;
9630 player[i].lastpathfindpoint2=-1;
9631 player[i].lastpathfindpoint3=-1;
9632 player[i].lastpathfindpoint4=-1;
9635 player[i].leftkeydown=0;
9636 player[i].backkeydown=0;
9637 player[i].rightkeydown=0;
9638 player[i].crouchkeydown=0;
9639 player[i].throwkeydown=0;
9641 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9642 /*for(j=0;j<numplayers;j++){
9643 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9644 player[i].crouchkeydown=1;
9647 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9648 else player[i].attackkeydown=0;
9649 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9650 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9651 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9652 player[i].attackkeydown=0;
9653 if(player[i].isIdle())player[i].crouchkeydown=1;
9654 player[i].forwardkeydown=0;
9655 player[i].aiupdatedelay=.02;
9658 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9660 for(j=0;j<numplayers;j++){
9661 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)){
9662 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))))){
9663 if(target>=0)target=-1;
9668 if(target>=0)player[target].Reverse();
9671 if(player[i].collided<1)player[i].jumpkeydown=0;
9672 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;
9673 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9674 player[0].jumpkeydown=0;
9675 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9676 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9677 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9679 if(tutoriallevel==1){
9680 if(!canattack)player[i].attackkeydown=0;
9684 facing=player[i].coords;
9685 flatfacing=player[0].coords;
9686 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9687 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9688 if(player[i].occluded>=2)
9689 if(-1!=checkcollide(facing,flatfacing)){
9690 if(!player[i].pause)player[i].lastseentime-=.2;
9691 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9692 player[i].aitype=searchtype;
9693 player[i].lastchecktime=12;
9694 player[i].lastseen=player[0].coords;
9695 player[i].lastseentime=12;
9698 else player[i].lastseentime=1;
9701 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9702 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
9703 test=player[0].coords;
9705 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
9708 // NOTE: Ask about logic of this call : NOTE
9709 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
9710 player[i].stunned>0 ||
9711 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
9713 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
9714 player[i].targetrotation=player[i].rotation;
9715 player[i].forwardkeydown=0;
9716 player[i].leftkeydown=0;
9717 player[i].backkeydown=0;
9718 player[i].rightkeydown=0;
9719 player[i].jumpkeydown=0;
9720 player[i].attackkeydown=0;
9721 player[i].crouchkeydown=0;
9722 player[i].throwkeydown=0;
9729 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9732 if(player[i].aitype==attacktypecutoff){
9733 rotatetarget=player[0].coords-player[i].coords;
9734 Normalise(&rotatetarget);
9735 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9736 player[i].targetheadrotation*=360/6.28;
9737 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9739 player[i].targetheadrotation*=-1;
9740 player[i].targetheadrotation+=180;
9741 //player[i].targetheadrotation2=0;
9742 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9744 else if(player[i].howactive>=typesleeping){
9745 player[i].targetheadrotation=player[i].targetrotation;
9746 player[i].targetheadrotation2=0;
9749 if(player[i].interestdelay<=0){
9750 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
9751 player[i].headtarget=player[i].coords;
9752 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
9753 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
9754 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
9755 player[i].headtarget+=player[i].facing*1.5;
9757 rotatetarget=player[i].headtarget-player[i].coords;
9758 Normalise(&rotatetarget);
9759 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9760 player[i].targetheadrotation*=360/6.28;
9761 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9763 player[i].targetheadrotation*=-1;
9764 player[i].targetheadrotation+=180;
9765 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9767 //if(whichlevel==2)player[i].jumpkeydown=0;
9769 if(animation[player[i].targetanimation].attack==reversed){
9770 //player[i].targetrotation=player[i].rotation;
9771 player[i].forwardkeydown=0;
9772 player[i].leftkeydown=0;
9773 player[i].backkeydown=0;
9774 player[i].rightkeydown=0;
9775 player[i].jumpkeydown=0;
9776 player[i].attackkeydown=0;
9777 //player[i].crouchkeydown=0;
9778 player[i].throwkeydown=0;
9782 player[i].forwardkeydown=0;
9783 player[i].leftkeydown=0;
9784 player[i].backkeydown=0;
9785 player[i].rightkeydown=0;
9786 player[i].jumpkeydown=0;
9787 player[i].crouchkeydown=0;
9788 player[i].drawkeydown=0;
9789 player[i].throwkeydown=0;
9792 if(player[i].collided<-.3)player[i].collided=-.3;
9793 if(player[i].collided>1)player[i].collided=1;
9794 player[i].collided-=multiplier*4;
9795 player[i].whichdirectiondelay-=multiplier;
9796 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
9797 player[i].avoidcollided=-.3;
9798 player[i].whichdirection=abs(Random()%2);
9799 player[i].whichdirectiondelay=.4;
9801 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
9802 player[i].avoidcollided-=multiplier/4;
9803 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
9804 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
9805 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;
9807 if(!player[i].throwkeydown){
9808 player[i].throwtogglekeydown=0;
9810 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
9811 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)){
9812 for(j=0;j<weapons.numweapons;j++){
9813 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)
9814 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
9815 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
9816 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
9817 player[i].throwtogglekeydown=1;
9818 player[i].targetanimation=crouchremoveknifeanim;
9820 player[i].targetframe=0;
9821 rotatetarget=weapons.position[j]-player[i].coords;
9822 Normalise(&rotatetarget);
9823 player[i].targetrotation=-asin(0-rotatetarget.x);
9824 player[i].targetrotation*=360/6.28;
9825 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9826 player[i].hasvictim=0;
9828 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9829 player[i].throwtogglekeydown=1;
9830 player[i].hasvictim=0;
9832 //for(i=0;i<weapons.numweapons;i++){
9833 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))
9834 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
9835 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
9838 gLoc[0]=player[i].coords.x;
9839 gLoc[1]=player[i].coords.y;
9840 gLoc[2]=player[i].coords.z;
9841 vel[0]=player[i].velocity.x;
9842 vel[1]=player[i].velocity.y;
9843 vel[2]=player[i].velocity.z;
9844 if(weapons.type[j]!=staff){
9845 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9846 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9847 OPENAL_SetVolume(channels[knifedrawsound], 128);
9848 OPENAL_SetPaused(channels[knifedrawsound], false);
9851 player[i].weaponactive=0;
9852 weapons.owner[j]=player[i].id;
9853 if(player[i].num_weapons>0){
9854 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9856 player[i].num_weapons++;
9857 player[i].weaponids[0]=j;
9863 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){
9864 if(!player[i].isFlip()){
9865 player[i].throwtogglekeydown=1;
9866 player[i].targetanimation=removeknifeanim;
9868 player[i].targetframe=0;
9869 rotatetarget=weapons.position[j]-player[i].coords;
9870 Normalise(&rotatetarget);
9871 player[i].targetrotation=-asin(0-rotatetarget.x);
9872 player[i].targetrotation*=360/6.28;
9873 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9875 if(player[i].isFlip()){
9876 player[i].throwtogglekeydown=1;
9877 player[i].hasvictim=0;
9879 for(k=0;k<weapons.numweapons;k++){
9880 if(player[i].weaponactive==-1)
9881 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))
9882 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
9885 gLoc[0]=player[i].coords.x;
9886 gLoc[1]=player[i].coords.y;
9887 gLoc[2]=player[i].coords.z;
9888 vel[0]=player[i].velocity.x;
9889 vel[1]=player[i].velocity.y;
9890 vel[2]=player[i].velocity.z;
9891 if(weapons.type[k]!=staff){
9892 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9893 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9894 OPENAL_SetVolume(channels[knifedrawsound], 128);
9895 OPENAL_SetPaused(channels[knifedrawsound], false);
9898 player[i].weaponactive=0;
9899 weapons.owner[k]=player[i].id;
9900 if(player[i].num_weapons>0){
9901 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
9903 player[i].num_weapons++;
9904 player[i].weaponids[0]=k;
9911 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9913 for(j=0;j<numplayers;j++){
9914 if(player[i].weaponactive==-1)
9916 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)){
9917 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
9918 player[i].throwtogglekeydown=1;
9919 player[i].victim=&player[j];
9920 player[i].hasvictim=1;
9921 player[i].targetanimation=crouchremoveknifeanim;
9923 player[i].targetframe=0;
9924 rotatetarget=player[j].coords-player[i].coords;
9925 Normalise(&rotatetarget);
9926 player[i].targetrotation=-asin(0-rotatetarget.x);
9927 player[i].targetrotation*=360/6.28;
9928 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9930 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
9931 player[i].throwtogglekeydown=1;
9932 player[i].victim=&player[j];
9933 player[i].hasvictim=1;
9934 int k = player[j].weaponids[0];
9935 if(player[i].hasvictim){
9938 gLoc[0]=player[i].coords.x;
9939 gLoc[1]=player[i].coords.y;
9940 gLoc[2]=player[i].coords.z;
9941 vel[0]=player[i].velocity.x;
9942 vel[1]=player[i].velocity.y;
9943 vel[2]=player[i].velocity.z;
9946 if(player[i].victim->weaponstuck!=-1){
9947 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9952 if(weapons.type[k]!=staff){
9953 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
9954 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
9955 OPENAL_SetVolume(channels[knifedrawsound], 128);
9956 OPENAL_SetPaused(channels[knifedrawsound], false);
9960 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
9961 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
9962 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
9963 OPENAL_SetPaused(channels[fleshstabremovesound], false);
9966 player[i].weaponactive=0;
9967 if(weapons.owner[k]!=-1){
9968 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
9969 else player[i].victim->num_weapons=1;
9971 player[i].victim->skeleton.longdead=0;
9972 player[i].victim->skeleton.free=1;
9973 player[i].victim->skeleton.broken=0;
9975 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
9976 player[i].victim->skeleton.joints[l].velchange=0;
9977 player[i].victim->skeleton.joints[l].locked=0;
9983 Normalise(&relative);
9984 XYZ footvel,footpoint;
9986 footpoint=weapons.position[k];
9987 if(player[i].victim->weaponstuck!=-1){
9988 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
9989 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
9990 weapons.bloody[k]=2;
9991 weapons.blooddrip[k]=5;
9992 player[i].victim->weaponstuck=-1;
9993 player[i].victim->bloodloss+=2000;
9994 player[i].victim->DoDamage(2000);
9997 if(player[i].victim->num_weapons>0){
9998 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
9999 if(player[i].victim->weaponids[0]==k)
10000 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10003 player[i].victim->weaponactive=-1;
10005 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10006 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10007 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10008 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10010 weapons.owner[k]=i;
10011 if(player[i].num_weapons>0){
10012 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10014 player[i].num_weapons++;
10015 player[i].weaponids[0]=k;
10022 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10023 if(weapons.type[player[i].weaponids[0]]==knife){
10024 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10026 for(j=0;j<numplayers;j++){
10028 if(tutoriallevel!=1||tutorialstage==49)
10030 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)){
10031 if(!player[i].isFlip()){
10032 player[i].throwtogglekeydown=1;
10033 player[i].victim=&player[j];
10034 player[i].targetanimation=knifethrowanim;
10035 player[i].target=0;
10036 player[i].targetframe=0;
10037 rotatetarget=player[j].coords-player[i].coords;
10038 Normalise(&rotatetarget);
10039 player[i].targetrotation=-asin(0-rotatetarget.x);
10040 player[i].targetrotation*=360/6.28;
10041 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10043 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10045 if(player[i].isFlip()){
10046 if(player[i].weaponactive!=-1){
10047 player[i].throwtogglekeydown=1;
10048 player[i].victim=&player[j];
10050 weapons.owner[player[i].weaponids[0]]=-1;
10051 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);
10054 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10056 weapons.velocity[player[i].weaponids[0]]=aim*50;
10057 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10058 weapons.missed[player[i].weaponids[0]]=0;
10059 weapons.freetime[player[i].weaponids[0]]=0;
10060 weapons.firstfree[player[i].weaponids[0]]=1;
10061 weapons.physics[player[i].weaponids[0]]=0;
10062 player[i].num_weapons--;
10063 if(player[i].num_weapons){
10064 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10066 player[i].weaponactive=-1;
10073 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10074 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10076 player[i].throwtogglekeydown=1;
10077 weapons.owner[player[i].weaponids[0]]=-1;
10078 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10079 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10080 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10081 weapons.missed[player[i].weaponids[0]]=1;
10082 weapons.freetime[player[i].weaponids[0]]=0;
10083 weapons.firstfree[player[i].weaponids[0]]=1;
10084 weapons.physics[player[i].weaponids[0]]=1;
10085 player[i].num_weapons--;
10086 if(player[i].num_weapons){
10087 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10088 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10091 player[i].weaponactive=-1;
10092 for(j=0;j<numplayers;j++){
10093 player[j].wentforweapon=0;
10100 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10101 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)){
10102 //Setenvironment(1-environment);
10105 if(player[i].weaponactive!=-1){
10106 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10108 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10109 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10110 player[i].targetanimation=drawrightanim;
10111 player[i].targetframe=0;
10112 player[i].target=0;
10113 player[i].drawtogglekeydown=1;
10115 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){
10116 player[i].targetanimation=drawleftanim;
10117 player[i].targetframe=0;
10118 player[i].target=0;
10119 player[i].drawtogglekeydown=1;
10121 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10122 player[i].targetanimation=crouchdrawrightanim;
10123 player[i].targetframe=0;
10124 player[i].target=0;
10125 player[i].drawtogglekeydown=1;
10129 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){
10130 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10131 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10132 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10133 player[i].targetframe=0;
10134 player[i].target=0;
10135 player[i].hasvictim=0;
10136 //player[i].attacktogglekeydown=1;
10140 if(!player[i].drawkeydown){
10141 player[i].drawtogglekeydown=0;
10146 absflatfacing.z=-1;
10148 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10150 else absflatfacing=flatfacing;
10152 if(indialogue!=-1){
10153 player[i].forwardkeydown=0;
10154 player[i].leftkeydown=0;
10155 player[i].backkeydown=0;
10156 player[i].rightkeydown=0;
10157 player[i].jumpkeydown=0;
10158 player[i].crouchkeydown=0;
10159 player[i].drawkeydown=0;
10160 player[i].throwkeydown=0;
10164 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10165 if(!player[i].forwardkeydown){
10166 player[i].forwardstogglekeydown=0;
10168 if(player[i].crouchkeydown){
10172 player[i].superruntoggle=1;
10174 for(j=0;j<numplayers;j++){
10175 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10176 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10177 player[i].superruntoggle=0;
10184 for(j=0;j<numplayers;j++){
10185 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10186 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))){
10187 if(target>=0)target=-1;
10192 if(target>=0)player[target].Reverse();
10193 player[i].lowreversaldelay=.5;
10195 if(player[i].isIdle()){
10196 player[i].targetanimation=player[i].getCrouch();
10197 player[i].target=0;
10198 player[i].targetframe=0;
10199 player[i].transspeed=10;
10201 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10202 player[i].targetanimation=rollanim;
10203 player[i].target=0;
10204 player[i].targetframe=0;
10205 player[i].transspeed=20;
10208 if(!player[i].crouchkeydown){
10210 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10212 if(player[i].isCrouch()){
10214 for(j=0;j<numplayers;j++){
10215 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10216 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10217 if(target>=0)target=-1;
10222 if(target>=0)player[target].Reverse();
10223 player[i].highreversaldelay=.5;
10225 if(player[i].isCrouch()){
10226 if(!player[i].wasCrouch()){
10227 player[i].currentanimation=player[i].getCrouch();
10228 player[i].currentframe=0;
10230 player[i].target=0;
10231 player[i].targetanimation=player[i].getIdle();
10232 player[i].targetframe=0;
10233 player[i].transspeed=10;
10236 if(player[i].targetanimation==sneakanim){
10237 player[i].targetanimation=player[i].getIdle();
10238 player[i].target=0;
10239 player[i].targetframe=0;
10240 player[i].transspeed=10;
10243 if(player[i].forwardkeydown){
10244 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)){
10245 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10246 else player[i].targetanimation=player[i].getRun();
10247 player[i].target=0;
10248 player[i].targetframe=0;
10250 if(player[i].isCrouch()){
10251 player[i].targetanimation=sneakanim;
10252 if(player[i].wasCrouch())player[i].target=0;
10253 player[i].targetframe=0;
10255 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10256 player[i].targetanimation=climbanim;
10257 player[i].target=0;
10258 player[i].targetframe=1;
10259 player[i].jumpclimb=1;
10261 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10262 player[i].velocity+=absflatfacing*5*multiplier;
10264 player[i].forwardstogglekeydown=1;
10267 if (player[i].rightkeydown){
10268 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)){
10269 player[i].targetanimation=player[i].getRun();
10270 player[i].target=0;
10271 player[i].targetframe=0;
10273 if(player[i].isCrouch()){
10274 player[i].targetanimation=sneakanim;
10275 if(player[i].wasCrouch()) player[i].target=0;
10276 player[i].targetframe=0;
10278 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10279 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10281 player[i].targetrotation-=90;
10282 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10283 if(player[i].backkeydown)player[i].targetrotation-=45;
10286 if ( player[i].leftkeydown){
10287 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)){
10288 player[i].targetanimation=player[i].getRun();
10289 player[i].target=0;
10290 player[i].targetframe=0;
10292 if(player[i].isCrouch()){
10293 player[i].targetanimation=sneakanim;
10294 if(player[i].wasCrouch())player[i].target=0;
10295 player[i].targetframe=0;
10297 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10298 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10300 player[i].targetrotation+=90;
10301 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10302 if(player[i].backkeydown)player[i].targetrotation+=45;
10305 if(player[i].backkeydown){
10306 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)){
10307 player[i].targetanimation=player[i].getRun();
10308 player[i].target=0;
10309 player[i].targetframe=0;
10311 if(player[i].isCrouch()){
10312 player[i].targetanimation=sneakanim;
10313 if(player[i].wasCrouch())player[i].target=0;
10314 player[i].targetframe=0;
10316 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10317 player[i].velocity-=absflatfacing*5*multiplier;
10319 if(player[i].targetanimation==hanganim){
10320 player[i].currentanimation=jumpdownanim;
10321 player[i].targetanimation=jumpdownanim;
10322 player[i].target=0;
10323 player[i].currentframe=0;
10324 player[i].targetframe=1;
10325 player[i].velocity=0;
10326 player[i].velocity.y+=gravity;
10327 player[i].coords.y-=1.4;
10328 player[i].grabdelay=1;
10330 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10331 player[i].targetrotation+=180;
10334 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10335 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)){
10336 player[i].jumpstart=0;
10337 player[i].targetanimation=jumpupanim;
10338 player[i].target=0;
10339 player[i].targetframe=0;
10340 player[i].rotation=player[i].targetrotation;
10341 player[i].transspeed=20;
10342 player[i].FootLand(0,1);
10343 player[i].FootLand(1,1);
10347 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10349 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10350 if(!movekey)player[i].velocity=0;
10355 for(j=0;j<numplayers;j++){
10356 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10357 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10358 if(target>=0)target=-1;
10363 if(target>=0)player[i].velocity.y=1;
10364 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10365 player[i].velocity.y=7;
10366 player[i].crouchtogglekeydown=1;
10368 else player[i].velocity.y=5;
10370 if(mousejump&&i==0&&debugmode){
10371 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10372 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10375 player[i].coords.y+=.2;
10376 player[i].jumppower-=1;
10378 static float gLoc[3];
10379 static float vel[3];
10380 gLoc[0]=player[i].coords.x;
10381 gLoc[1]=player[i].coords.y;
10382 gLoc[2]=player[i].coords.z;
10383 vel[0]=player[i].velocity.x;
10384 vel[1]=player[i].velocity.y;
10385 vel[2]=player[i].velocity.z;
10388 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10389 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10390 OPENAL_SetVolume(channels[whooshsound], 128);
10391 OPENAL_SetPaused(channels[whooshsound], false);
10394 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10395 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10396 OPENAL_SetVolume(channels[jumpsound], 128);
10397 OPENAL_SetPaused(channels[jumpsound], false);
10399 if((player[i].isIdle())&&player[i].jumppower>1){
10400 player[i].targetanimation=player[i].getLanding();
10401 player[i].landhard=0;
10402 player[i].target=0;
10403 player[i].targetframe=2;
10404 player[i].jumpstart=1;
10405 player[i].tempdeltav=deltav;
10407 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10408 if(player[i].jumppower>multiplier*6){
10409 player[i].velocity.y+=multiplier*6;
10410 player[i].jumppower-=multiplier*6;
10412 if(player[i].jumppower<=multiplier*6){
10413 player[i].velocity.y+=player[i].jumppower;
10414 player[i].jumppower=0;
10417 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10421 if(player[i].isRun()||player[i].targetanimation==walkanim){
10422 player[i].targetanimation=player[i].getStop();
10423 player[i].target=0;
10424 player[i].targetframe=0;
10426 if(player[i].targetanimation==sneakanim){
10427 player[i].targetanimation=player[i].getCrouch();
10428 if(player[i].currentanimation==sneakanim)player[i].target=0;
10429 player[i].targetframe=0;
10432 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10433 player[i].targetanimation=player[i].getStop();
10434 player[i].target=0;
10435 player[i].targetframe=0;
10437 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10438 player[i].targetanimation=player[i].getStop();
10439 player[i].target=0;
10440 player[i].targetframe=0;
10444 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10448 for(k=0;k<numplayers;k++){
10449 if(abs(player[k].rotation-player[k].targetrotation)>180){
10450 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10451 else player[k].rotation+=360;
10454 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10455 player[k].targetanimation=player[k].getStop();
10456 player[k].targetframe=0;
10457 player[k].target=0;
10460 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10461 player[k].targettilt=0;
10463 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10464 player[k].targettilt=0;
10465 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10466 player[k].jumppower+=multiplier*7;
10467 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10468 //*(1-(player[k].damage/player[k].damagetolerance))
10469 if(player[k].jumppower>5)player[k].jumppower=5;
10472 if(player[k].isRun()){
10473 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10476 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10477 else if(player[k].tilt>player[k].targettilt){
10478 player[k].tilt-=multiplier*150;
10480 else if(player[k].tilt<player[k].targettilt){
10481 player[k].tilt+=multiplier*150;
10484 player[k].grabdelay-=multiplier;
10487 for(k=0;k<numplayers;k++){
10488 player[k].DoAnimations();
10489 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10490 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10495 player[0].righthandmorphstart=0;
10496 player[0].righthandmorphend=1;
10497 player[0].lefthandmorphstart=0;
10498 player[0].lefthandmorphend=1;
10499 player[0].headmorphstart=0;
10500 player[0].headmorphend=2;*/
10503 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10504 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10505 player[0].righthandmorphend=1;
10506 player[0].targetrighthandmorphness=1;
10508 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10509 player[0].lefthandmorphend=0;
10510 player[0].targetlefthandmorphness=1;
10512 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10513 player[0].headmorphend=2;
10514 player[0].targetheadmorphness=1;
10516 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10517 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10518 player[0].righthandmorphend=0;
10519 player[0].targetrighthandmorphness=1;
10521 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10522 player[0].lefthandmorphend=1;
10523 player[0].targetlefthandmorphness=1;
10525 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10526 player[0].headmorphend=0;
10527 player[0].targetheadmorphness=1;
10530 if(numenvsounds!=0)
10531 for(j=numenvsounds-1;j>=0;j--){
10532 envsoundlife[j]-=multiplier;
10533 if(envsoundlife[j]<0){
10535 envsoundlife[j]=envsoundlife[numenvsounds];
10536 envsound[j]=envsound[numenvsounds];
10539 if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
10540 if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
10542 if(tutoriallevel==1){
10559 if(tutorialstage>=51)
10560 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10561 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10562 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
10564 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10565 OPENAL_SetPaused(channels[stream_music3], false);
10566 OPENAL_SetVolume(channels[stream_music3], 256);
10571 float gLoc[3]={0,0,0};
10572 float vel[3]={0,0,0};
10573 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10574 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10575 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10576 OPENAL_SetVolume(channels[fireendsound], 256);
10577 OPENAL_SetPaused(channels[fireendsound], false);
10578 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10586 if(tutorialstage<51)
10587 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10590 gLoc[0]=player[0].coords.x;
10591 gLoc[1]=player[0].coords.y;
10592 gLoc[2]=player[0].coords.z;
10596 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10597 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10598 OPENAL_SetVolume(channels[fireendsound], 256);
10599 OPENAL_SetPaused(channels[fireendsound], false);
10601 player[0].coords=(oldtemp+oldtemp2)/2;
10609 if(tutorialstage>=14&&tutorialstage<50)
10610 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10613 gLoc[0]=player[1].coords.x;
10614 gLoc[1]=player[1].coords.y;
10615 gLoc[2]=player[1].coords.z;
10619 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10620 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10621 OPENAL_SetVolume(channels[fireendsound], 256);
10622 OPENAL_SetPaused(channels[fireendsound], false);
10624 for(int i=0;i<player[1].skeleton.num_joints;i++){
10626 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10627 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10628 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;
10629 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10630 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10634 player[1].coords=(oldtemp+oldtemp2)/2;
10635 for(int i=0;i<player[1].skeleton.num_joints;i++){
10636 player[1].skeleton.joints[i].velocity=0;
10638 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10639 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10640 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;
10641 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10642 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10650 static float gLoc[3];
10654 static float vel[3];
10655 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10656 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10657 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10659 //Set orientation with forward and up vectors
10660 static XYZ upvector;
10664 upvector=DoRotation(upvector,-rotation2+90,0,0);
10665 upvector=DoRotation(upvector,0,0-rotation,0);
10670 facing=DoRotation(facing,-rotation2,0,0);
10671 facing=DoRotation(facing,0,0-rotation,0);
10674 static float ori[6];
10675 ori[0] = -facing.x;
10677 ori[2] = -facing.z;
10678 ori[3] = -upvector.x;
10679 ori[4] = upvector.y;
10680 ori[5] = -upvector.z;
10682 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10689 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10691 freezetogglekeydown=1;
10695 void Game::TickOnce(){
10698 if(directing||indialogue==-1){
10699 rotation+=deltah*.7;
10700 if(!invertmouse)rotation2+=deltav*.7;
10701 if(invertmouse)rotation2-=deltav*.7;
10702 if(rotation2>90)rotation2=90;
10703 if(rotation2<-70)rotation2=-70;
10705 if(mainmenu)rotation+=multiplier*5;
10710 void Game::TickOnceAfter(){
10711 static XYZ colviewer;
10712 static XYZ coltarget;
10715 static float brotate;
10718 static float changedelay;
10719 static bool alldead;
10720 static float unseendelay;
10721 static float cameraspeed;
10725 if(environment==snowyenvironment)music1=stream_music1snow;
10726 if(environment==grassyenvironment)music1=stream_music1grass;
10727 if(environment==desertenvironment)music1=stream_music1desert;
10732 for(i=0;i<numplayers;i++){
10733 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)){
10734 musictype=stream_music2;
10738 if(player[0].dead)musictype=stream_music3;
10741 if(musictype==stream_music2){
10745 if(oldmusictype==stream_music2&&musictype!=stream_music2){
10746 unseendelay-=multiplier;
10748 musictype=stream_music2;
10754 musictype=stream_music3;
10755 musicvolume[2]=512;
10762 if(musictype!=oldmusictype&&musictype==stream_music2){
10763 static float gLoc[3];
10764 static float vel[3];
10765 gLoc[0]=cameraloc.x;
10766 gLoc[1]=cameraloc.y;
10767 gLoc[2]=cameraloc.z;
10771 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
10772 OPENAL_SetVolume(channels[alarmsound], 512);
10773 OPENAL_SetPaused(channels[alarmsound], false);
10777 musicselected=musictype;
10779 if(musicselected==music1)musicvolume[0]+=multiplier*450;
10780 else musicvolume[0]-=multiplier*450;
10781 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
10782 else musicvolume[1]-=multiplier*450;
10783 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
10784 else musicvolume[2]-=multiplier*450;
10786 if(musicselected==music1)musicvolume[0]+=multiplier*100;
10787 else musicvolume[0]-=multiplier*450;
10788 if(musicselected==music2)musicvolume[1]+=multiplier*150;
10789 else if(player[0].dead)musicvolume[1]-=multiplier*450;
10790 else musicvolume[1]-=multiplier*100;
10791 if(musicselected==music3)musicvolume[2]+=multiplier*450;
10792 else musicvolume[2]-=multiplier*450;*/
10795 if(musicvolume[i]<0)musicvolume[i]=0;
10796 if(musicvolume[i]>512)musicvolume[i]=512;
10799 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
10802 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
10803 PlayStreamEx( music1, strm[music1], NULL, true);
10804 OPENAL_SetPaused(channels[music1], false);
10806 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
10807 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
10808 OPENAL_SetPaused(channels[stream_music2], false);
10810 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
10811 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10812 OPENAL_SetPaused(channels[stream_music3], false);
10817 OPENAL_SetPaused(channels[music1], true);
10818 OPENAL_SetPaused(channels[stream_music2], true);
10819 OPENAL_SetPaused(channels[stream_music3], true);
10822 oldmusicvolume[i]=0;
10828 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
10829 OPENAL_SetPaused(channels[music1], true);
10831 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
10832 OPENAL_SetPaused(channels[stream_music2], true);
10834 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
10835 OPENAL_SetPaused(channels[stream_music3], true);
10838 if(musicvolume[0]!=oldmusicvolume[0]){
10839 OPENAL_SetVolume(channels[music1], musicvolume[0]);
10841 if(musicvolume[1]!=oldmusicvolume[1]){
10842 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
10844 if(musicvolume[2]!=oldmusicvolume[2]){
10845 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
10849 oldmusicvolume[i]=musicvolume[i];
10855 for(i=0;i<numhotspots;i++){
10856 if(hotspottype[i]>10&&hotspottype[i]<20){
10857 if(player[hotspottype[i]-10].dead==0){
10860 else if(killhotspot==2)
10864 if(killhotspot==2)killhotspot=0;
10869 for(i=0;i<numhotspots;i++){
10870 if(hotspottype[i]==-1){
10871 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
10878 for(i=1;i<numplayers;i++){
10879 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
10881 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
10883 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
10884 if(player[0].dead&&changedelay<=0){
10886 targetlevel=whichlevel;
10890 for(i=1;i<numplayers;i++){
10891 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
10895 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
10897 targetlevel=whichlevel+1;
10898 if(targetlevel>numchallengelevels-1)targetlevel=0;
10900 if(winhotspot||windialogue){
10902 targetlevel=whichlevel+1;
10903 if(targetlevel>numchallengelevels-1)targetlevel=0;
10909 targetlevel=whichlevel+1;
10910 if(targetlevel>numchallengelevels-1)targetlevel=0;
10913 if(changedelay>0&&!player[0].dead&&!won){
10914 //high scores, awards, win
10917 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
10918 accountcampaignchoicesmade[accountactive]++;
10919 accountcampaignscore[accountactive]+=bonustotal;
10921 accountcampaigntime[accountactive]+=leveltime;
10922 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
10924 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10930 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
10931 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
10933 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
10949 if(!editorenabled&&gameon&&!mainmenu){
10950 if(changedelay!=-999)changedelay-=multiplier/7;
10951 if(player[0].dead)targetlevel=whichlevel;
10952 if(loading==2&&!campaign){
10960 float gLoc[3]={0,0,0};
10961 float vel[3]={0,0,0};
10962 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10963 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10964 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10965 OPENAL_SetVolume(channels[firestartsound], 256);
10966 OPENAL_SetPaused(channels[firestartsound], false);
10967 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
10969 if(!player[0].dead&&targetlevel!=whichlevel){
10970 startbonustotal=bonustotal;
10972 if(!player[0].dead)Loadlevel(targetlevel);
10973 if(player[0].dead)Loadlevel(whichlevel);
10975 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10976 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10977 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10978 OPENAL_SetVolume(channels[fireendsound], 256);
10979 OPENAL_SetPaused(channels[fireendsound], false);
10980 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10984 if(loading==2&&targetlevel==whichlevel){
10992 float gLoc[3]={0,0,0};
10993 float vel[3]={0,0,0};
10994 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
10995 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
10996 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
10997 OPENAL_SetVolume(channels[firestartsound], 256);
10998 OPENAL_SetPaused(channels[firestartsound], false);
10999 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11001 for(i=0;i<255;i++){
11015 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11016 Loadlevel(mapname);
11018 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11019 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11020 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11021 OPENAL_SetVolume(channels[fireendsound], 256);
11022 OPENAL_SetPaused(channels[fireendsound], false);
11023 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11027 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11028 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11030 if(whichlevel!=-2&&!loading&&!player[0].dead){
11034 if(player[0].dead)loading=1;
11040 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11041 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11045 else if(mainmenu==0&&winfreeze){
11046 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11048 else stealthloading=0;
11050 if(!stealthloading){
11051 float gLoc[3]={0,0,0};
11052 float vel[3]={0,0,0};
11053 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11054 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11055 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11056 OPENAL_SetVolume(channels[firestartsound], 256);
11057 OPENAL_SetPaused(channels[firestartsound], false);
11058 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11069 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11070 //campaignnumlevels=0;
11071 //accountcampaignchoicesmade[accountactive]=0;
11072 ipstream.ignore(256,':');
11073 ipstream >> campaignnumlevels;
11074 for(i=0;i<campaignnumlevels;i++){
11075 ipstream.ignore(256,':');
11076 ipstream.ignore(256,':');
11077 ipstream.ignore(256,' ');
11078 ipstream >> campaignmapname[i];
11079 ipstream.ignore(256,':');
11080 ipstream >> campaigndescription[i];
11081 for(j=0;j<256;j++){
11082 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11084 ipstream.ignore(256,':');
11085 ipstream >> campaignchoosenext[i];
11086 ipstream.ignore(256,':');
11087 ipstream >> campaignnumnext[i];
11088 if(campaignnumnext[i])
11089 for(j=0;j<campaignnumnext[i];j++){
11090 ipstream.ignore(256,':');
11091 ipstream >> campaignnextlevel[i][j];
11092 campaignnextlevel[i][j]-=1;
11094 ipstream.ignore(256,':');
11095 ipstream >> campaignlocationx[i];
11096 ipstream.ignore(256,':');
11097 ipstream >> campaignlocationy[i];
11101 for(i=0;i<campaignnumlevels;i++){
11103 levelhighlight[i]=0;
11107 for(i=0;i<campaignnumlevels;i++){
11109 levelhighlight[i]=0;
11114 if(accountcampaignchoicesmade[accountactive])
11115 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11116 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11117 levelvisible[levelorder[i+1]]=1;
11119 int whichlevelstart;
11120 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11121 if(whichlevelstart<0){
11122 campaignchoicenum=1;
11123 campaignchoicewhich[0]=0;
11127 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11128 if(campaignchoicenum)
11129 for(i=0;i<campaignchoicenum;i++){
11130 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11131 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11132 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11139 //if(firstload)TickOnceAfter();
11140 if(!firstload)LoadStuff();
11142 for(i=0;i<255;i++){
11157 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11158 //accountcampaignchoicesmade[accountactive]++;
11161 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11165 Loadlevel(mapname);
11169 OPENAL_SetPaused(channels[stream_music3], true);
11174 if(loading==3)loading=0;
11178 oldmusictype=musictype;
11184 facing=DoRotation(facing,-rotation2,0,0);
11185 facing=DoRotation(facing,0,0-rotation,0);
11186 viewerfacing=facing;
11190 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;
11191 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;
11193 if(player[0].skeleton.free){
11194 for(i=0;i<player[0].skeleton.num_joints;i++){
11195 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11196 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11200 if(player[0].skeleton.free!=2&&!autocam){
11202 if(findLengthfast(&player[0].velocity)>400){
11203 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11205 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11206 coltarget=target-cameraloc;
11207 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11209 Normalise(&coltarget);
11210 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11211 else cameraloc=cameraloc+coltarget*multiplier*8;
11213 if(editorenabled)cameraloc=target;
11214 cameradist+=multiplier*5;
11215 if(cameradist>2.3)cameradist=2.3;
11216 viewer=cameraloc-facing*cameradist;
11218 coltarget=cameraloc;
11219 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11220 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11221 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11222 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11224 coltarget=cameraloc;
11225 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11227 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11228 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11229 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11231 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11235 cameradist=findDistance(&viewer,&target);
11236 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11237 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11239 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11240 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11243 if(player[0].skeleton.free!=2&&autocam){
11245 if(findLengthfast(&player[0].velocity)>400){
11246 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11248 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11249 cameradist+=multiplier*5;
11250 if(cameradist>3.3)cameradist=3.3;
11251 coltarget=target-cameraloc;
11252 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11253 else if(findLengthfast(&coltarget)>1)
11255 Normalise(&coltarget);
11256 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11257 else cameraloc=cameraloc+coltarget*multiplier*8;
11259 if(editorenabled)cameraloc=target;
11262 coltarget=cameraloc;
11263 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11264 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11265 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11266 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11268 coltarget=cameraloc;
11269 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11271 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11272 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11273 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11275 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11279 cameradist=findDistance(&viewer,&target);
11280 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11281 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11283 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11284 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11287 if(camerashake>.8)camerashake=.8;
11288 //if(woozy>10)woozy=10;
11289 //woozy+=multiplier;
11291 if(player[0].dead)camerashake=0;
11292 if(player[0].dead)woozy=0;
11293 camerashake-=multiplier*2;
11294 blackout-=multiplier*2;
11295 //if(player[0].isCrouch())woozy-=multiplier*8;
11296 if(camerashake<0)camerashake=0;
11297 if(blackout<0)blackout=0;
11298 //if(woozy<0)woozy=0;
11300 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11301 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11302 viewer.z+=(float)(Random()%100)*.0005*camerashake;