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==12&&!tryquit)||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||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 !USE_SDL // we'll take anything that works.
1875 if(newscreenwidth>3000)newscreenwidth=screenwidth;
1876 if(newscreenheight>3000)newscreenheight=screenheight;
1878 if(newscreenwidth<0)newscreenwidth=screenwidth;
1879 if(newscreenheight<0)newscreenheight=screenheight;
1881 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
1882 opstream << "Screenwidth:\n";
1883 opstream << newscreenwidth;
1884 opstream << "\nScreenheight:\n";
1885 opstream << newscreenheight;
1886 opstream << "\nMouse sensitivity:\n";
1887 opstream << usermousesensitivity;
1888 opstream << "\nBlur(0,1):\n";
1889 opstream << ismotionblur;
1890 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
1891 opstream << newdetail;
1892 opstream << "\nFloating jump:\n";
1893 opstream << floatjump;
1894 opstream << "\nMouse jump:\n";
1895 opstream << mousejump;
1896 opstream << "\nAmbient sound:\n";
1897 opstream << ambientsound;
1898 opstream << "\nBlood (0,1,2):\n";
1899 opstream << bloodtoggle;
1900 opstream << "\nAuto slomo:\n";
1901 opstream << autoslomo;
1902 opstream << "\nFoliage:\n";
1903 opstream << foliage;
1904 opstream << "\nMusic:\n";
1905 opstream << musictoggle;
1906 opstream << "\nTrilinear:\n";
1907 opstream << trilinear;
1908 opstream << "\nDecals(shadows,blood puddles,etc):\n";
1910 opstream << "\nInvert mouse:\n";
1911 opstream << invertmouse;
1912 opstream << "\nGamespeed:\n";
1913 if(oldgamespeed==0)oldgamespeed=1;
1914 opstream << oldgamespeed;
1915 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
1916 opstream << difficulty;
1917 opstream << "\nDamage effects(blackout, doublevision):\n";
1918 opstream << damageeffects;
1919 opstream << "\nText:\n";
1920 opstream << texttoggle;
1921 opstream << "\nDebug:\n";
1922 opstream << debugmode;
1923 opstream << "\nVBL Sync:\n";
1924 opstream << vblsync;
1925 opstream << "\nShow Points:\n";
1926 opstream << showpoints;
1927 opstream << "\nAlways Blur:\n";
1928 opstream << alwaysblur;
1929 opstream << "\nImmediate mode (turn on on G5):\n";
1930 opstream << immediate;
1931 opstream << "\nVelocity blur:\n";
1932 opstream << velocityblur;
1933 opstream << "\nVolume:\n";
1935 opstream << "\nForward key:\n";
1936 opstream << KeyToChar(forwardkey);
1937 opstream << "\nBack key:\n";
1938 opstream << KeyToChar(backkey);
1939 opstream << "\nLeft key:\n";
1940 opstream << KeyToChar(leftkey);
1941 opstream << "\nRight key:\n";
1942 opstream << KeyToChar(rightkey);
1943 opstream << "\nJump key:\n";
1944 opstream << KeyToChar(jumpkey);
1945 opstream << "\nCrouch key:\n";
1946 opstream << KeyToChar(crouchkey);
1947 opstream << "\nDraw key:\n";
1948 opstream << KeyToChar(drawkey);
1949 opstream << "\nThrow key:\n";
1950 opstream << KeyToChar(throwkey);
1951 opstream << "\nAttack key:\n";
1952 opstream << KeyToChar(attackkey);
1953 opstream << "\nChat key:\n";
1954 opstream << KeyToChar(chatkey);
1957 if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==10||mainmenu==11||mainmenu==100){
1958 float gLoc[3]={0,0,0};
1959 float vel[3]={0,0,0};
1960 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1961 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1962 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1963 OPENAL_SetVolume(channels[fireendsound], 256);
1964 OPENAL_SetPaused(channels[fireendsound], false);
1965 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1973 if(mainmenu==3&&gameon)mainmenu=2;
1974 if(mainmenu==3&&!gameon)mainmenu=1;
1975 if(mainmenu==5&&gameon)mainmenu=2;
1976 if(mainmenu==5&&!gameon)mainmenu=1;
1977 if(mainmenu==4)mainmenu=3;
1978 if(mainmenu==6)mainmenu=5;
1979 if(mainmenu==7)mainmenu=1;
1980 if(mainmenu==9)mainmenu=5;
1981 if(mainmenu==11)mainmenu=5;
1982 if(mainmenu==12)mainmenu=5;
1983 if(mainmenu==13)mainmenu=12;
1984 if(mainmenu==14)mainmenu=13;
1985 if(mainmenu==10)mainmenu=5;
1991 mainmenutogglekeydown=1;
1993 if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
1994 mainmenutogglekeydown=0;
1998 /*static bool minimaptogglekeydown;
1999 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
2001 minimaptogglekeydown=1;
2003 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
2004 minimaptogglekeydown=0;
2008 static bool minimaptogglekeydown;
2009 if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
2010 if(tutorialstage!=51)
2011 tutorialstagetime=tutorialmaxtime;
2012 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
2013 OPENAL_SetVolume(channels[consolefailsound], 128);
2014 OPENAL_SetPaused(channels[consolefailsound], false);
2015 minimaptogglekeydown=1;
2017 if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
2018 minimaptogglekeydown=0;
2023 if(mainmenu==1||mainmenu==2){
2024 if(Button()&&!oldbutton&&selected==1){
2026 float gLoc[3]={0,0,0};
2027 float vel[3]={0,0,0};
2028 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2029 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2030 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2031 OPENAL_SetVolume(channels[firestartsound], 256);
2032 OPENAL_SetPaused(channels[firestartsound], false);
2033 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2042 if(accountactive!=-1)mainmenu=5;
2049 if(firstload)TickOnceAfter();
2050 if(!firstload)LoadStuff();
2056 OPENAL_SetPaused(channels[music3], true); */
2062 OPENAL_SetPaused(channels[stream_music3], true);
2063 OPENAL_SetPaused(channels[music1], false);
2067 if(Button()&&!oldbutton&&selected==2){
2068 float gLoc[3]={0,0,0};
2069 float vel[3]={0,0,0};
2070 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2071 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2072 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2073 OPENAL_SetVolume(channels[firestartsound], 256);
2074 OPENAL_SetPaused(channels[firestartsound], false);
2075 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2087 if(newdetail>2)newdetail=detail;
2088 if(newdetail<0)newdetail=detail;
2089 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2090 if(newscreenwidth<0)newscreenwidth=screenwidth;
2091 if(newscreenheight>3000)newscreenheight=screenheight;
2092 if(newscreenheight<0)newscreenheight=screenheight;
2095 if(Button()&&!oldbutton&&selected==3){
2096 float gLoc[3]={0,0,0};
2097 float vel[3]={0,0,0};
2098 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2099 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2100 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2101 OPENAL_SetVolume(channels[fireendsound], 256);
2102 OPENAL_SetPaused(channels[fireendsound], false);
2103 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2114 if(registered)OPENAL_SetPaused(channels[stream_music3], true);
2122 if(Button())oldbutton=1;
2127 if(Button()&&!oldbutton&&selected!=-1){
2128 float gLoc[3]={0,0,0};
2129 float vel[3]={0,0,0};
2130 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2131 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2132 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2133 OPENAL_SetVolume(channels[firestartsound], 256);
2134 OPENAL_SetPaused(channels[firestartsound], false);
2135 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2137 if(Button()&&!oldbutton&&selected==0){
2139 extern SDL_Rect **resolutions;
2140 bool isCustomResolution = true;
2142 for (int i = 0; (!found) && (resolutions[i]); i++)
2144 if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth))
2145 isCustomResolution = false;
2147 if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight))
2150 if (resolutions[i] != NULL)
2152 newscreenwidth = (int) resolutions[i]->w;
2153 newscreenheight = (int) resolutions[i]->h;
2155 else if (isCustomResolution)
2157 if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight))
2159 newscreenwidth = (int) resolutions[0]->w;
2160 newscreenheight = (int) resolutions[0]->h;
2164 newscreenwidth = screenwidth;
2165 newscreenheight = screenheight;
2170 newscreenwidth = (int) resolutions[0]->w;
2171 newscreenheight = (int) resolutions[0]->h;
2179 newscreenwidth = (int) resolutions[0]->w;
2180 newscreenheight = (int) resolutions[0]->h;
2186 if(newscreenwidth==640&&newscreenheight==480)whichres=0;
2187 if(newscreenwidth==800&&newscreenheight==600)whichres=1;
2188 if(newscreenwidth==1024&&newscreenheight==768)whichres=2;
2189 if(newscreenwidth==1280&&newscreenheight==1024)whichres=3;
2190 if(newscreenwidth==1600&&newscreenheight==1200)whichres=4;
2191 if(newscreenwidth==840&&newscreenheight==524)whichres=5;
2192 if(newscreenwidth==1024&&newscreenheight==640)whichres=6;
2193 if(newscreenwidth==1344&&newscreenheight==840)whichres=7;
2194 if(newscreenwidth==1920&&newscreenheight==1200)whichres=8;
2196 if(whichres==-1||whichres==8){
2198 newscreenheight=480;
2202 newscreenheight=600;
2205 newscreenwidth=1024;
2206 newscreenheight=768;
2209 newscreenwidth=1280;
2210 newscreenheight=1024;
2213 newscreenwidth=1600;
2214 newscreenheight=1200;
2218 newscreenheight=524;
2221 newscreenwidth=1024;
2222 newscreenheight=640;
2225 newscreenwidth=1344;
2226 newscreenheight=840;
2229 newscreenwidth=1920;
2230 newscreenheight=1200;
2234 if(Button()&&!oldbutton&&selected==1){
2236 if(newdetail>2)newdetail=0;
2238 if(Button()&&!oldbutton&&selected==2){
2240 if(bloodtoggle>2)bloodtoggle=0;
2242 if(Button()&&!oldbutton&&selected==3){
2244 if(difficulty>2)difficulty=0;
2246 if(Button()&&!oldbutton&&selected==4){
2247 ismotionblur=1-ismotionblur;
2249 if(Button()&&!oldbutton&&selected==5){
2252 if(Button()&&!oldbutton&&selected==6){
2253 musictoggle=1-musictoggle;
2256 OPENAL_SetPaused(channels[music1], true);
2257 OPENAL_SetPaused(channels[stream_music2], true);
2258 OPENAL_SetPaused(channels[stream_music3], true);
2261 oldmusicvolume[i]=0;
2267 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2268 OPENAL_SetPaused(channels[stream_music3], false);
2269 OPENAL_SetVolume(channels[stream_music3], 256);
2272 if(Button()&&!oldbutton&&selected==9){
2273 invertmouse=1-invertmouse;
2275 if(Button()&&!oldbutton&&selected==10){
2276 usermousesensitivity+=.2;
2277 if(usermousesensitivity>2)usermousesensitivity=.2;
2279 if(Button()&&!oldbutton&&selected==11){
2281 if(volume>1.0001f)volume=0;
2282 OPENAL_SetSFXMasterVolume((int)(volume*255));
2284 if(Button()&&!oldbutton&&selected==7){
2285 /*float gLoc[3]={0,0,0};
2286 float vel[3]={0,0,0};
2287 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2288 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2289 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2290 OPENAL_SetVolume(channels[firestartsound], 256);
2291 OPENAL_SetPaused(channels[firestartsound], false);
2292 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2305 if(Button()&&!oldbutton&&selected==8){
2306 float gLoc[3]={0,0,0};
2307 float vel[3]={0,0,0};
2308 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2309 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2310 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2311 OPENAL_SetVolume(channels[fireendsound], 256);
2312 OPENAL_SetPaused(channels[fireendsound], false);
2313 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2321 if(newdetail>2)newdetail=detail;
2322 if(newdetail<0)newdetail=detail;
2323 #if !USE_SDL // we'll take anything that works.
2324 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2325 if(newscreenheight>3000)newscreenheight=screenheight;
2327 if(newscreenwidth<0)newscreenwidth=screenwidth;
2328 if(newscreenheight<0)newscreenheight=screenheight;
2331 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
2332 opstream << "Screenwidth:\n";
2333 opstream << newscreenwidth;
2334 opstream << "\nScreenheight:\n";
2335 opstream << newscreenheight;
2336 opstream << "\nMouse sensitivity:\n";
2337 opstream << usermousesensitivity;
2338 opstream << "\nBlur(0,1):\n";
2339 opstream << ismotionblur;
2340 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
2341 opstream << newdetail;
2342 opstream << "\nFloating jump:\n";
2343 opstream << floatjump;
2344 opstream << "\nMouse jump:\n";
2345 opstream << mousejump;
2346 opstream << "\nAmbient sound:\n";
2347 opstream << ambientsound;
2348 opstream << "\nBlood (0,1,2):\n";
2349 opstream << bloodtoggle;
2350 opstream << "\nAuto slomo:\n";
2351 opstream << autoslomo;
2352 opstream << "\nFoliage:\n";
2353 opstream << foliage;
2354 opstream << "\nMusic:\n";
2355 opstream << musictoggle;
2356 opstream << "\nTrilinear:\n";
2357 opstream << trilinear;
2358 opstream << "\nDecals(shadows,blood puddles,etc):\n";
2360 opstream << "\nInvert mouse:\n";
2361 opstream << invertmouse;
2362 opstream << "\nGamespeed:\n";
2363 if(oldgamespeed==0)oldgamespeed=1;
2364 opstream << oldgamespeed;
2365 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
2366 opstream << difficulty;
2367 opstream << "\nDamage effects(blackout, doublevision):\n";
2368 opstream << damageeffects;
2369 opstream << "\nText:\n";
2370 opstream << texttoggle;
2371 opstream << "\nDebug:\n";
2372 opstream << debugmode;
2373 opstream << "\nVBL Sync:\n";
2374 opstream << vblsync;
2375 opstream << "\nShow Points:\n";
2376 opstream << showpoints;
2377 opstream << "\nAlways Blur:\n";
2378 opstream << alwaysblur;
2379 opstream << "\nImmediate mode (turn on on G5):\n";
2380 opstream << immediate;
2381 opstream << "\nVelocity blur:\n";
2382 opstream << velocityblur;
2383 opstream << "\nVolume:\n";
2385 opstream << "\nForward key:\n";
2386 opstream << KeyToChar(forwardkey);
2387 opstream << "\nBack key:\n";
2388 opstream << KeyToChar(backkey);
2389 opstream << "\nLeft key:\n";
2390 opstream << KeyToChar(leftkey);
2391 opstream << "\nRight key:\n";
2392 opstream << KeyToChar(rightkey);
2393 opstream << "\nJump key:\n";
2394 opstream << KeyToChar(jumpkey);
2395 opstream << "\nCrouch key:\n";
2396 opstream << KeyToChar(crouchkey);
2397 opstream << "\nDraw key:\n";
2398 opstream << KeyToChar(drawkey);
2399 opstream << "\nThrow key:\n";
2400 opstream << KeyToChar(throwkey);
2401 opstream << "\nAttack key:\n";
2402 opstream << KeyToChar(attackkey);
2403 opstream << "\nChat key:\n";
2404 opstream << KeyToChar(chatkey);
2407 if(mainmenu==3&&gameon)mainmenu=2;
2408 if(mainmenu==3&&!gameon)mainmenu=1;
2410 if(Button())oldbutton=1;
2414 if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
2415 float gLoc[3]={0,0,0};
2416 float vel[3]={0,0,0};
2417 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2418 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2419 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2420 OPENAL_SetVolume(channels[firestartsound], 256);
2421 OPENAL_SetPaused(channels[firestartsound], false);
2422 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2424 if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
2432 if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
2434 if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
2435 if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
2436 float gLoc[3]={0,0,0};
2437 float vel[3]={0,0,0};
2438 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2439 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2440 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2441 OPENAL_SetVolume(channels[fireendsound], 256);
2442 OPENAL_SetPaused(channels[fireendsound], false);
2443 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2447 if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
2448 if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
2452 if(keyselect==0)forwardkey=keynum;
2453 if(keyselect==1)backkey=keynum;
2454 if(keyselect==2)leftkey=keynum;
2455 if(keyselect==3)rightkey=keynum;
2456 if(keyselect==4)crouchkey=keynum;
2457 if(keyselect==5)jumpkey=keynum;
2458 if(keyselect==6)drawkey=keynum;
2459 if(keyselect==7)throwkey=keynum;
2460 if(keyselect==8)attackkey=keynum;
2465 if(Button()&&!oldbutton&&selected==9){
2466 float gLoc[3]={0,0,0};
2467 float vel[3]={0,0,0};
2468 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2469 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2470 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2471 OPENAL_SetVolume(channels[fireendsound], 256);
2472 OPENAL_SetPaused(channels[fireendsound], false);
2473 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2483 if(newdetail>2)newdetail=detail;
2484 if(newdetail<0)newdetail=detail;
2485 if(newscreenwidth>3000)newscreenwidth=screenwidth;
2486 if(newscreenwidth<0)newscreenwidth=screenwidth;
2487 if(newscreenheight>3000)newscreenheight=screenheight;
2488 if(newscreenheight<0)newscreenheight=screenheight;
2493 if(accountcampaignchoicesmade[accountactive]>8&&!registered){
2494 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
2495 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
2496 OPENAL_SetPaused(channels[stream_music3], false);
2497 OPENAL_SetVolume(channels[stream_music3], 256);
2501 accountcampaignchoicesmade[accountactive]=0;
2502 accountcampaignscore[accountactive]=0;
2503 accountcampaigntime[accountactive]=0;
2505 float gLoc[3]={0,0,0};
2506 float vel[3]={0,0,0};
2507 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2508 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2509 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2510 OPENAL_SetVolume(channels[fireendsound], 256);
2511 OPENAL_SetPaused(channels[fireendsound], false);
2512 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2522 accountcampaignchoicesmade[accountactive]=0;
2523 accountcampaignscore[accountactive]=0;
2524 accountcampaigntime[accountactive]=0;
2528 if(Button()&&!oldbutton&&selected==1){
2529 float gLoc[3]={0,0,0};
2530 float vel[3]={0,0,0};
2531 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2532 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2533 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2534 OPENAL_SetVolume(channels[firestartsound], 256);
2535 OPENAL_SetPaused(channels[firestartsound], false);
2536 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2549 if(firstload)TickOnceAfter();
2550 if(!firstload)LoadStuff();
2557 OPENAL_SetPaused(channels[stream_music3], true);
2559 if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
2560 float gLoc[3]={0,0,0};
2561 float vel[3]={0,0,0};
2562 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2563 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2564 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2565 OPENAL_SetVolume(channels[firestartsound], 256);
2566 OPENAL_SetPaused(channels[firestartsound], false);
2567 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2580 if(firstload)TickOnceAfter();
2581 if(!firstload)LoadStuff();
2597 strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
2598 whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
2602 //Loadlevel(campaignmapname[levelorder[selected-7]]);
2607 OPENAL_SetPaused(channels[stream_music3], true);
2609 if(Button()&&!oldbutton&&selected==4){
2610 float gLoc[3]={0,0,0};
2611 float vel[3]={0,0,0};
2612 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2613 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2614 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2615 OPENAL_SetVolume(channels[fireendsound], 256);
2616 OPENAL_SetPaused(channels[fireendsound], false);
2617 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2625 if(mainmenu==5&&gameon)mainmenu=2;
2626 if(mainmenu==5&&!gameon)mainmenu=1;
2628 if(Button()&&!oldbutton&&selected==5){
2629 float gLoc[3]={0,0,0};
2630 float vel[3]={0,0,0};
2631 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2632 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2633 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2634 OPENAL_SetVolume(channels[fireendsound], 256);
2635 OPENAL_SetPaused(channels[fireendsound], false);
2636 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2646 if(Button()&&!oldbutton&&selected==3){
2647 float gLoc[3]={0,0,0};
2648 float vel[3]={0,0,0};
2649 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2650 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2651 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2652 OPENAL_SetVolume(channels[firestartsound], 256);
2653 OPENAL_SetPaused(channels[firestartsound], false);
2654 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2664 if(Button()&&!oldbutton&&selected==2){
2665 float gLoc[3]={0,0,0};
2666 float vel[3]={0,0,0};
2667 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2668 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2669 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2670 OPENAL_SetVolume(channels[firestartsound], 256);
2671 OPENAL_SetPaused(channels[firestartsound], false);
2672 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2682 if(Button())oldbutton=1;
2686 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2687 float gLoc[3]={0,0,0};
2688 float vel[3]={0,0,0};
2689 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2690 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2691 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2692 OPENAL_SetVolume(channels[firestartsound], 256);
2693 OPENAL_SetPaused(channels[firestartsound], false);
2694 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2706 targetlevel=selected;
2707 if(firstload)TickOnceAfter();
2708 if(!firstload)LoadStuff();
2710 Loadlevel(selected);
2716 OPENAL_SetPaused(channels[stream_music3], true);
2718 if(Button()&&!oldbutton&&selected==numchallengelevels){
2719 float gLoc[3]={0,0,0};
2720 float vel[3]={0,0,0};
2721 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2722 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2723 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2724 OPENAL_SetVolume(channels[fireendsound], 256);
2725 OPENAL_SetPaused(channels[fireendsound], false);
2726 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2736 if(Button())oldbutton=1;
2740 if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
2741 float gLoc[3]={0,0,0};
2742 float vel[3]={0,0,0};
2743 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2744 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2745 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2746 OPENAL_SetVolume(channels[firestartsound], 256);
2747 OPENAL_SetPaused(channels[firestartsound], false);
2748 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2760 targetlevel=selected;
2761 if(firstload)TickOnceAfter();
2762 if(!firstload)LoadStuff();
2764 Loadlevel(selected);
2770 OPENAL_SetPaused(channels[stream_music3], true);
2772 if(Button()&&!oldbutton&&selected==numchallengelevels){
2773 float gLoc[3]={0,0,0};
2774 float vel[3]={0,0,0};
2775 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2776 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2777 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2778 OPENAL_SetVolume(channels[fireendsound], 256);
2779 OPENAL_SetPaused(channels[fireendsound], false);
2780 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2790 if(Button())oldbutton=1;
2795 if(Button()&&!oldbutton&&selected==3){
2796 float gLoc[3]={0,0,0};
2797 float vel[3]={0,0,0};
2798 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2799 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2800 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2801 OPENAL_SetVolume(channels[fireendsound], 256);
2802 OPENAL_SetPaused(channels[fireendsound], false);
2803 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2813 if(Button())oldbutton=1;
2817 if(mainmenu==15||mainmenu==16){
2818 if(Button()&&!oldbutton&&selected==1){
2819 float gLoc[3]={0,0,0};
2820 float vel[3]={0,0,0};
2821 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2822 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2823 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2824 OPENAL_SetVolume(channels[fireendsound], 256);
2825 OPENAL_SetPaused(channels[fireendsound], false);
2826 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2834 if(mainmenu==15)mainmenu=5;
2837 if(Button())oldbutton=1;
2843 if(Button()&&!oldbutton&&selected==3){
2845 float gLoc[3]={0,0,0};
2846 float vel[3]={0,0,0};
2847 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2848 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2849 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2850 OPENAL_SetVolume(channels[fireendsound], 256);
2851 OPENAL_SetPaused(channels[fireendsound], false);
2852 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2863 if(Button()&&!oldbutton&&selected==4){
2866 float gLoc[3]={0,0,0};
2867 float vel[3]={0,0,0};
2868 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2869 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2870 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2871 OPENAL_SetVolume(channels[fireendsound], 256);
2872 OPENAL_SetPaused(channels[fireendsound], false);
2873 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2883 if(Button()&&!oldbutton&&selected==5){
2885 float gLoc[3]={0,0,0};
2886 float vel[3]={0,0,0};
2887 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2888 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2889 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2890 OPENAL_SetVolume(channels[fireendsound], 256);
2891 OPENAL_SetPaused(channels[fireendsound], false);
2892 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2902 if(Button())oldbutton=1;
2906 if(Button()&&!oldbutton&&selected!=-1){
2907 float gLoc[3]={0,0,0};
2908 float vel[3]={0,0,0};
2909 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2910 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2911 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2912 OPENAL_SetVolume(channels[firestartsound], 256);
2913 OPENAL_SetPaused(channels[firestartsound], false);
2914 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2916 if(Button()&&!oldbutton&&selected==1){
2917 float gLoc[3]={0,0,0};
2918 float vel[3]={0,0,0};
2919 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2920 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2921 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2922 OPENAL_SetVolume(channels[fireendsound], 256);
2923 OPENAL_SetPaused(channels[fireendsound], false);
2924 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2932 for(i=accountactive;i<numaccounts-1;i++){
2933 accountdifficulty[i]=accountdifficulty[i+1];
2934 accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
2935 for(j=0;j<accountcampaignchoicesmade[i+1];j++){
2936 accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
2938 accountpoints[i]=accountpoints[i+1];
2940 accounthighscore[i][j]=accounthighscore[i+1][j];
2941 accountfasttime[i][j]=accountfasttime[i+1][j];
2944 accountunlocked[i][j]=accountunlocked[i+1][j];
2947 accountname[i][j]=accountname[i+1][j];
2949 accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
2950 accountprogress[i]=accountprogress[i+1];
2951 accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
2952 accountcampaignscore[i]=accountcampaignscore[i+1];
2953 accountcampaigntime[i]=accountcampaigntime[i+1];
2962 if(Button()&&!oldbutton&&selected==2){
2963 float gLoc[3]={0,0,0};
2964 float vel[3]={0,0,0};
2965 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
2966 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2967 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2968 OPENAL_SetVolume(channels[fireendsound], 256);
2969 OPENAL_SetPaused(channels[fireendsound], false);
2970 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
2980 if(Button())oldbutton=1;
2984 if(Button()&&!oldbutton&&selected!=-1){
2985 float gLoc[3]={0,0,0};
2986 float vel[3]={0,0,0};
2987 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
2988 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
2989 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
2990 OPENAL_SetVolume(channels[firestartsound], 256);
2991 OPENAL_SetPaused(channels[firestartsound], false);
2992 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
2994 if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
2997 if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
2998 accountactive=selected-1;
3006 if(Button()&&!oldbutton&&selected==numaccounts+1){
3007 float gLoc[3]={0,0,0};
3008 float vel[3]={0,0,0};
3009 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
3010 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
3011 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
3012 OPENAL_SetVolume(channels[fireendsound], 256);
3013 OPENAL_SetPaused(channels[fireendsound], false);
3014 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
3025 displaytext[0][j]=' ';
3031 if(Button())oldbutton=1;
3035 if(Button()&&!oldbutton&&selected!=-1){
3036 float gLoc[3]={0,0,0};
3037 float vel[3]={0,0,0};
3038 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3039 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3040 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3041 OPENAL_SetVolume(channels[firestartsound], 256);
3042 OPENAL_SetPaused(channels[firestartsound], false);
3043 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3045 if(selected==0)accountdifficulty[accountactive]=0;
3046 if(selected==1)accountdifficulty[accountactive]=1;
3047 if(selected==2)accountdifficulty[accountactive]=2;
3058 if(Button())oldbutton=1;
3063 if(Button())oldbutton=1;
3066 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
3069 if(newdetail>2)newdetail=detail;
3070 if(newdetail<0)newdetail=detail;
3071 #if !USE_SDL // we'll take anything that works.
3072 if(newscreenwidth>3000)newscreenwidth=screenwidth;
3073 if(newscreenheight>3000)newscreenheight=screenheight;
3075 if(newscreenwidth<0)newscreenwidth=screenwidth;
3076 if(newscreenheight<0)newscreenheight=screenheight;
3078 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
3079 opstream << "Screenwidth:\n";
3080 opstream << newscreenwidth;
3081 opstream << "\nScreenheight:\n";
3082 opstream << newscreenheight;
3083 opstream << "\nMouse sensitivity:\n";
3084 opstream << usermousesensitivity;
3085 opstream << "\nBlur(0,1):\n";
3086 opstream << ismotionblur;
3087 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
3088 opstream << newdetail;
3089 opstream << "\nFloating jump:\n";
3090 opstream << floatjump;
3091 opstream << "\nMouse jump:\n";
3092 opstream << mousejump;
3093 opstream << "\nAmbient sound:\n";
3094 opstream << ambientsound;
3095 opstream << "\nBlood (0,1,2):\n";
3096 opstream << bloodtoggle;
3097 opstream << "\nAuto slomo:\n";
3098 opstream << autoslomo;
3099 opstream << "\nFoliage:\n";
3100 opstream << foliage;
3101 opstream << "\nMusic:\n";
3102 opstream << musictoggle;
3103 opstream << "\nTrilinear:\n";
3104 opstream << trilinear;
3105 opstream << "\nDecals(shadows,blood puddles,etc):\n";
3107 opstream << "\nInvert mouse:\n";
3108 opstream << invertmouse;
3109 opstream << "\nGamespeed:\n";
3110 if(oldgamespeed==0)oldgamespeed=1;
3111 opstream << oldgamespeed;
3112 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
3113 opstream << difficulty;
3114 opstream << "\nDamage effects(blackout, doublevision):\n";
3115 opstream << damageeffects;
3116 opstream << "\nText:\n";
3117 opstream << texttoggle;
3118 opstream << "\nDebug:\n";
3119 opstream << debugmode;
3120 opstream << "\nVBL Sync:\n";
3121 opstream << vblsync;
3122 opstream << "\nShow Points:\n";
3123 opstream << showpoints;
3124 opstream << "\nAlways Blur:\n";
3125 opstream << alwaysblur;
3126 opstream << "\nImmediate mode (turn on on G5):\n";
3127 opstream << immediate;
3128 opstream << "\nVelocity blur:\n";
3129 opstream << velocityblur;
3130 opstream << "\nVolume:\n";
3132 opstream << "\nForward key:\n";
3133 opstream << KeyToChar(forwardkey);
3134 opstream << "\nBack key:\n";
3135 opstream << KeyToChar(backkey);
3136 opstream << "\nLeft key:\n";
3137 opstream << KeyToChar(leftkey);
3138 opstream << "\nRight key:\n";
3139 opstream << KeyToChar(rightkey);
3140 opstream << "\nJump key:\n";
3141 opstream << KeyToChar(jumpkey);
3142 opstream << "\nCrouch key:\n";
3143 opstream << KeyToChar(crouchkey);
3144 opstream << "\nDraw key:\n";
3145 opstream << KeyToChar(drawkey);
3146 opstream << "\nThrow key:\n";
3147 opstream << KeyToChar(throwkey);
3148 opstream << "\nAttack key:\n";
3149 opstream << KeyToChar(attackkey);
3150 opstream << "\nChat key:\n";
3151 opstream << KeyToChar(chatkey);
3156 if(mainmenu==1||mainmenu==2){
3157 if(loaddistrib>4)transition+=multiplier/8;
3165 OPENAL_SetFrequency(channels[stream_music3], 22050);
3167 if(entername||mainmenu==13||mainmenu==14){
3169 if(IsKeyDown(theKeyMap, i)){
3170 togglekeydelay[i]+=multiplier;
3171 if(togglekeydelay[i]>.4){
3173 togglekeydelay[i]=.36;
3176 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3177 for(j=255;j>=displayselected+1;j--){
3178 displaytext[0][j]=displaytext[0][j-1];
3180 displaytext[0][displayselected]=KeyToSingleChar(i);
3181 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3185 if(i==MAC_DELETE_KEY&&displayselected!=0){
3186 for(j=displayselected-1;j<255;j++){
3187 displaytext[0][j]=displaytext[0][j+1];
3189 displaytext[0][255]=' ';
3193 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3196 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3199 if(i==MAC_RETURN_KEY&&entername){
3200 if(displaychars[0]){
3202 strcpy(accountname[numaccounts-1],displaytext[0]);
3203 accountactive=numaccounts-1;
3204 accountdifficulty[accountactive]=1;
3205 accountprogress[accountactive]=0;
3206 accountpoints[accountactive]=0;
3207 accountcampaigntime[accountactive]=0;
3208 accountcampaignscore[accountactive]=0;
3209 accountcampaignfasttime[accountactive]=0;
3210 accountcampaignhighscore[accountactive]=0;
3212 accounthighscore[accountactive][j]=0;
3213 accountfasttime[accountactive][j]=0;
3216 accountunlocked[accountactive][j]=0;
3218 accountcampaignchoicesmade[accountactive]=0;
3221 displaytext[0][j]=' ';
3235 float gLoc[3]={0,0,0};
3236 float vel[3]={0,0,0};
3237 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3238 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3239 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3240 OPENAL_SetVolume(channels[firestartsound], 256);
3241 OPENAL_SetPaused(channels[firestartsound], false);
3242 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3245 displaytext[0][j]=' ';
3253 if(i==MAC_RETURN_KEY&&mainmenu==14){
3254 if(displaychars[0]){
3255 char serialstring[256];
3256 char tempstring[256];
3257 #if defined(__APPLE__)
3258 sprintf (tempstring, "%s", registrationname);
3259 #elif defined(_WIN32) || defined(__linux__)
3260 sprintf (tempstring, "%s-windows", registrationname);
3262 #error Please make sure you have the right registration key stuff here!
3269 longnum = MD5_string ( tempstring);
3270 //longnum = 1111111111111111;
3271 num1 = longnum/100000000;
3272 num2 = longnum%100000000;
3273 sprintf (tempstring, "%ld-%ld-%ld-%ld\0\0\0\0\0", num1/10000, num1%10000, num2/10000, num2%10000);
3277 if(num1/10000>999)numchars+=4;
3278 else if(num1/10000>99)numchars+=3;
3279 else if(num1/10000>9)numchars+=2;
3281 if(num1%10000>999)numchars+=4;
3282 else if(num1%10000>99)numchars+=3;
3283 else if(num1%10000>9)numchars+=2;
3285 if(num2/10000>999)numchars+=4;
3286 else if(num2/10000>99)numchars+=3;
3287 else if(num2/10000>9)numchars+=2;
3289 if(num2%10000>999)numchars+=4;
3290 else if(num2%10000>99)numchars+=3;
3291 else if(num2%10000>9)numchars+=2;
3296 for(j=0;j<numchars;j++){
3297 if(displaytext[0][j]!=tempstring[j]&&tempstring[j]!=' '&&tempstring[j]!='\0')goodcode--;
3300 if(longnum==LONGLONGCONST(5077041556214789))goodcode=-1;
3302 if(goodcode<0)goodcode=0;
3309 tfile=fopen( ":Data:Sounds:flame.ogg", "wb" );
3313 numchars=strlen(registrationname);
3314 fpackf(tfile, "Bb", registered);
3315 fpackf(tfile, "Bi", numchars);
3318 for(j=0;j<numchars;j++)
3320 fpackf(tfile, "Bb", registrationname[j]);
3323 fpackf(tfile, "Bi", num1);
3324 fpackf(tfile, "Bi", num2);
3338 float gLoc[3]={0,0,0};
3339 float vel[3]={0,0,0};
3340 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3341 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3342 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3343 OPENAL_SetVolume(channels[firestartsound], 256);
3344 OPENAL_SetPaused(channels[firestartsound], false);
3345 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3348 displaytext[0][j]=' ';
3354 if(i==MAC_RETURN_KEY&&mainmenu==13){
3355 if(displaychars[0]){
3356 sprintf (registrationname, "%s", displaytext[0]);
3357 if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
3367 float gLoc[3]={0,0,0};
3368 float vel[3]={0,0,0};
3369 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
3370 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
3371 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
3372 OPENAL_SetVolume(channels[firestartsound], 256);
3373 OPENAL_SetPaused(channels[firestartsound], false);
3374 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
3377 displaytext[0][j]=' ';
3381 /*char tempstring[50];
3382 sprintf (tempstring, registrationname);
3388 longnum = MD5_string ( tempstring);
3389 num1 = longnum/100000000;
3390 num2 = longnum%100000000;
3391 sprintf (displaytext[0], "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3393 displaychars[0]=strlen(displaytext[0]);
3402 togglekeydelay[i]=0;
3406 displayblinkdelay-=multiplier;
3407 if(displayblinkdelay<=0){
3408 displayblinkdelay=.3;
3409 displayblink=1-displayblink;
3415 if(hostile==1)hostiletime+=multiplier;
3417 if(!winfreeze)leveltime+=multiplier;
3418 if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
3425 if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
3427 chattogglekeydown=1;
3428 togglekey[chatkey]=1;
3429 togglekeydelay[chatkey]=-20;
3432 if(!IsKeyDown(theKeyMap, chatkey)){
3433 chattogglekeydown=0;
3438 if(IsKeyDown(theKeyMap, i)){
3439 togglekeydelay[i]+=multiplier;
3440 if(togglekeydelay[i]>.4){
3442 togglekeydelay[i]=.36;
3445 if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
3446 for(j=255;j>=displayselected+1;j--){
3447 displaytext[0][j]=displaytext[0][j-1];
3449 displaytext[0][displayselected]=KeyToSingleChar(i);
3450 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
3454 if(i==MAC_DELETE_KEY&&displayselected!=0){
3455 for(j=displayselected-1;j<255;j++){
3456 displaytext[0][j]=displaytext[0][j+1];
3458 displaytext[0][255]=' ';
3462 if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
3465 if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
3468 if(i==MAC_RETURN_KEY){
3469 if(displaychars[0]){
3470 /*for(j=0;j<displaychars[0];j++){
3471 talkname[j]=displaytext[0][j];
3473 talkname[displaychars[0]]='\0';
3474 sprintf (chatname, "%s: %s",playerName,talkname);
3475 //NetworkSendInformation(chatname);
3478 displaytext[0][j]=' ';
3490 togglekeydelay[i]=0;
3494 displayblinkdelay-=multiplier;
3495 if(displayblinkdelay<=0){
3496 displayblinkdelay=.3;
3497 displayblink=1-displayblink;
3501 if(chatting)keyboardfrozen=1;
3503 if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
3506 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3508 freezetogglekeydown=1;
3511 if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
3512 freezetogglekeydown=0;
3515 if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
3517 if(!console)freeze=0;
3519 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
3521 consoletogglekeydown=1;
3524 if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
3525 consoletogglekeydown=0;
3528 if(console)freeze=1;
3530 if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
3532 if(IsKeyDown(theKeyMap, i)){
3533 togglekeydelay[i]+=multiplier;
3534 if(togglekeydelay[i]>.4){
3536 togglekeydelay[i]=.36;
3539 if(KeyToSingleChar(i)!='\0'&&consolechars[0]<255){
3540 for(j=255;j>=consoleselected+1;j--){
3541 consoletext[0][j]=consoletext[0][j-1];
3543 consoletext[0][consoleselected]=KeyToSingleChar(i);
3544 if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
3548 else if(i==MAC_ENTER_KEY){
3549 for(j=255;j>=consoleselected+1;j--){
3550 consoletext[0][j]=consoletext[0][j-1];
3552 consoletext[0][consoleselected]='\n';
3556 if(i==MAC_DELETE_KEY&&consoleselected!=0){
3557 for(j=consoleselected-1;j<255;j++){
3558 consoletext[0][j]=consoletext[0][j+1];
3560 consoletext[0][255]=' ';
3564 if(i==MAC_ARROW_UP_KEY){
3565 if(archiveselected<14)archiveselected++;
3567 consolechars[0]=consolechars[archiveselected];
3568 consoletext[0][j]=consoletext[archiveselected][j];
3569 consoleselected=consolechars[0];
3572 if(i==MAC_ARROW_DOWN_KEY){
3573 if(archiveselected>0)archiveselected--;
3575 consolechars[0]=consolechars[archiveselected];
3576 consoletext[0][j]=consoletext[archiveselected][j];
3577 consoleselected=consolechars[0];
3580 if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
3583 if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
3586 if(i==MAC_RETURN_KEY){
3589 if(Compare(consoletext[0],"quit ",0,4)||Compare(consoletext[0],"exit ",0,4)){
3590 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3591 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3592 OPENAL_SetPaused(channels[consolesuccesssound], false);
3596 /*if(Compare(consoletext[0],"send ",0,4)){
3597 for(j=5;j<consolechars[0];j++){
3598 talkname[j-5]=consoletext[0][j];
3600 talkname[consolechars[0]-5]='\0';
3601 sprintf (chatname, "%s: %s",playerName,talkname);
3602 //NetworkSendInformation(chatname);
3605 if(Compare(consoletext[0],"name ",0,4)){
3607 numchars=consolechars[0]-5;
3608 if(numchars>32)numchars=32;
3609 for(j=5;j<numchars+5;j++){
3610 talkname[j-5]=consoletext[0][j];
3612 talkname[numchars]='\0';
3613 sprintf (chatname, "Player %s is now known as %s.",playerName,talkname);
3614 //NetworkSendInformation(chatname);
3615 sprintf (playerName, "%s",talkname);
3616 //NetworkSendName(playerName);
3619 if(Compare(consoletext[0],"map ",0,3)){
3631 for(j=4;j<consolechars[0];j++){
3632 mapname[j-4+11]=consoletext[0][j];
3634 mapname[consolechars[0]-4+11]='\0';
3640 /*if(Compare(consoletext[0],"connect ",0,7)&&!ishost){
3642 unsigned char playerNameStr[32];
3643 char theIPAddress[256];
3645 NMUInt32 port = 25710;
3647 strcpy(playerName, "Client");
3648 GameC2PStr( playerName, playerNameStr );
3650 for(j=0;j<consolechars[0]-8;j++){
3651 theIPAddress[j]=consoletext[0][j+8];
3653 theIPAddress[consolechars[0]-8]='\0';
3655 sprintf( thePort, "%li", port );
3656 v=NetworkStartClient( theIPAddress, thePort, playerNameStr );
3659 if(consolechars[0]>0){
3662 consoletext[k][j]=consoletext[k-1][j];
3664 consolechars[k]=consolechars[k-1];
3667 consoletext[0][j]=' ';
3669 if(v!=-4994)sprintf (consoletext[0], "Error #%d!!!",v);
3670 else sprintf (consoletext[0], "Could not open connection");
3672 consolechars[0]=255;
3679 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3680 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3681 OPENAL_SetPaused(channels[consolesuccesssound], false);
3683 if(consolechars[0]>0){
3686 consoletext[k][j]=consoletext[k-1][j];
3688 consolechars[k]=consolechars[k-1];
3691 consoletext[0][j]=' ';
3693 sprintf (consoletext[0], "Connected to %s",theIPAddress);
3695 consolechars[0]=255;
3701 if(Compare(consoletext[0],"host ",0,4)){
3702 unsigned char gameNameStr[32], playerNameStr[32];
3703 char gameName[32];//, playerName[32];
3711 strcpy(gameName, "Host's game");
3712 strcpy(playerName, "Host");
3713 GameC2PStr( gameName, gameNameStr );
3714 GameC2PStr( playerName, playerNameStr );
3716 v=NetworkStartServer( (NMUInt16)port, players, gameNameStr, playerNameStr );
3719 if(consolechars[0]>0){
3722 consoletext[k][j]=consoletext[k-1][j];
3724 consolechars[k]=consolechars[k-1];
3727 consoletext[0][j]=' ';
3729 sprintf (consoletext[0], "Error #%d!!!",v);
3731 consolechars[0]=255;
3738 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3739 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3740 OPENAL_SetPaused(channels[consolesuccesssound], false);
3742 if(consolechars[0]>0){
3745 consoletext[k][j]=consoletext[k-1][j];
3747 consolechars[k]=consolechars[k-1];
3750 consoletext[0][j]=' ';
3752 sprintf (consoletext[0], "Game hosted");
3754 consolechars[0]=255;
3760 if(Compare(consoletext[0],"save ",0,4)){
3772 for(j=5;j<consolechars[0];j++){
3773 mapname[j-5+11]=consoletext[0][j];
3775 mapname[consolechars[0]-5+11]='\0';
3777 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
3778 OPENAL_SetVolume(channels[consolesuccesssound], 256);
3779 OPENAL_SetPaused(channels[consolesuccesssound], false);
3786 tfile=fopen( mapname, "wb" );
3787 fpackf(tfile, "Bi", mapvers);
3788 //fpackf(tfile, "Bi", indemo);
3789 fpackf(tfile, "Bi", maptype);
3790 fpackf(tfile, "Bi", hostile);
3791 fpackf(tfile, "Bf Bf", viewdistance, fadestart);
3792 fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
3793 fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
3794 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);
3795 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3796 for(j=0;j<player[0].num_weapons;j++){
3797 fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
3800 fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
3801 fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
3802 fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
3803 fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
3805 fpackf(tfile, "Bi", player[0].numclothes);
3807 fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
3809 fpackf(tfile, "Bi", numdialogues);
3811 for(k=0;k<numdialogues;k++){
3812 fpackf(tfile, "Bi", numdialogueboxes[k]);
3813 fpackf(tfile, "Bi", dialoguetype[k]);
3815 fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
3816 fpackf(tfile, "Bf", participantrotation[k][l]);
3818 if(numdialogueboxes)
3819 for(l=0;l<numdialogueboxes[k];l++){
3820 fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
3821 fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
3822 fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
3823 fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
3824 fpackf(tfile, "Bi", dialogueboxsound[k][l]);
3826 templength=strlen(dialoguetext[k][l]);
3827 fpackf(tfile, "Bi",(templength));
3828 for(m=0;m<templength;m++){
3829 fpackf(tfile, "Bb", dialoguetext[k][l][m]);
3830 if(dialoguetext[k][l][m]=='\0')break;
3833 templength=strlen(dialoguename[k][l]);
3834 fpackf(tfile, "Bi",templength);
3835 for(m=0;m<templength;m++){
3836 fpackf(tfile, "Bb", dialoguename[k][l][m]);
3837 if(dialoguename[k][l][m]=='\0')break;
3840 fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
3841 fpackf(tfile, "Bi", participantfocus[k][l]);
3842 fpackf(tfile, "Bi", participantaction[k][l]);
3845 fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
3847 fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
3851 if(player[0].numclothes)
3852 for(k=0;k<player[0].numclothes;k++){
3853 templength=strlen(player[0].clothes[k]);
3854 fpackf(tfile, "Bi", templength);
3855 for(l=0;l<templength;l++)
3856 fpackf(tfile, "Bb", player[0].clothes[k][l]);
3857 fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
3860 fpackf(tfile, "Bi", environment);
3862 fpackf(tfile, "Bi", objects.numobjects);
3864 if(objects.numobjects)
3865 for(k=0;k<objects.numobjects;k++){
3866 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]);
3869 fpackf(tfile, "Bi", numhotspots);
3871 for(i=0;i<numhotspots;i++){
3872 fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
3873 templength=strlen(hotspottext[i]);
3874 fpackf(tfile, "Bi",templength);
3875 for(l=0;l<templength;l++)
3876 fpackf(tfile, "Bb", hotspottext[i][l]);
3879 fpackf(tfile, "Bi", numplayers);
3880 if(numplayers>1&&numplayers<maxplayers)
3881 for(j=1;j<numplayers;j++){
3882 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);
3883 if(player[j].num_weapons>0&&player[j].num_weapons<5)
3884 for(k=0;k<player[j].num_weapons;k++){
3885 fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
3887 if(player[j].numwaypoints<30){
3888 fpackf(tfile, "Bi", player[j].numwaypoints);
3889 for(k=0;k<player[j].numwaypoints;k++){
3890 fpackf(tfile, "Bf", player[j].waypoints[k].x);
3891 fpackf(tfile, "Bf", player[j].waypoints[k].y);
3892 fpackf(tfile, "Bf", player[j].waypoints[k].z);
3893 fpackf(tfile, "Bi", player[j].waypointtype[k]);
3895 fpackf(tfile, "Bi", player[j].waypoint);
3898 player[j].numwaypoints=0;
3899 player[j].waypoint=0;
3900 fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
3903 fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
3904 fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
3905 fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
3906 fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
3908 if(player[j].creature==wolftype){
3909 headprop=player[j].proportionhead.x/1.1;
3910 bodyprop=player[j].proportionbody.x/1.1;
3911 armprop=player[j].proportionarms.x/1.1;
3912 legprop=player[j].proportionlegs.x/1.1;
3915 if(player[j].creature==rabbittype){
3916 headprop=player[j].proportionhead.x/1.2;
3917 bodyprop=player[j].proportionbody.x/1.05;
3918 armprop=player[j].proportionarms.x/1.00;
3919 legprop=player[j].proportionlegs.x/1.1;
3922 fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
3926 fpackf(tfile, "Bi", player[j].numclothes);
3927 if(player[j].numclothes)
3928 for(k=0;k<player[j].numclothes;k++){
3930 templength=strlen(player[j].clothes[k]);
3931 fpackf(tfile, "Bi", templength);
3932 for(l=0;l<templength;l++)
3933 fpackf(tfile, "Bb", player[j].clothes[k][l]);
3934 fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
3938 fpackf(tfile, "Bi", numpathpoints);
3940 for(j=0;j<numpathpoints;j++){
3941 fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
3942 for(k=0;k<numpathpointconnect[j];k++){
3943 fpackf(tfile, "Bi", pathpointconnect[j][k]);
3947 fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
3955 tfile=fopen( mapname, "wb" );
3956 fwrite( &mapvers, 1, sizeof(int), tfile );
3957 fwrite( &player[0].coords.x, 1, sizeof(float), tfile );
3958 fwrite( &player[0].coords.y, 1, sizeof(float), tfile );
3959 fwrite( &player[0].coords.z, 1, sizeof(float), tfile );
3960 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
3961 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
3962 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
3963 if(player[0].num_weapons>0&&player[0].num_weapons<5)
3964 for(j=0;j<player[0].num_weapons;j++){
3965 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
3968 fwrite( &player[0].armorhead, 1, sizeof(int), tfile );
3969 fwrite( &player[0].armorhigh, 1, sizeof(int), tfile );
3970 fwrite( &player[0].armorlow, 1, sizeof(int), tfile );
3971 fwrite( &player[0].protectionhead, 1, sizeof(int), tfile );
3972 fwrite( &player[0].protectionhigh, 1, sizeof(int), tfile );
3973 fwrite( &player[0].protectionlow, 1, sizeof(int), tfile );
3974 fwrite( &player[0].metalhead, 1, sizeof(int), tfile );
3975 fwrite( &player[0].metalhigh, 1, sizeof(int), tfile );
3976 fwrite( &player[0].metallow, 1, sizeof(int), tfile );
3977 fwrite( &player[0].power, 1, sizeof(int), tfile );
3978 fwrite( &player[0].speedmult, 1, sizeof(int), tfile );
3980 fwrite( &player[0].numclothes, 1, sizeof(int), tfile );
3981 if(player[0].numclothes)
3982 for(k=0;k<player[0].numclothes;k++){
3984 templength=strlen(player[0].clothes[k]);
3985 fwrite( &templength,1,sizeof(int),tfile);
3986 for(l=0;l<templength;l++)
3987 fwrite( &player[0].clothes[k][l],1,sizeof(char),tfile);
3988 fwrite( &player[0].clothestintr[k],1,sizeof(float),tfile);
3989 fwrite( &player[0].clothestintg[k],1,sizeof(float),tfile);
3990 fwrite( &player[0].clothestintb[k],1,sizeof(float),tfile);
3993 fwrite( &environment, 1, sizeof(int), tfile );
3995 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
3997 for(k=0;k<objects.numobjects;k++){
3998 fwrite( &objects.type[k], 1, sizeof(int), tfile );
3999 fwrite( &objects.rotation[k], 1, sizeof(float), tfile );
4000 fwrite( &objects.rotation2[k], 1, sizeof(float), tfile );
4001 fwrite( &objects.position[k].x, 1, sizeof(float), tfile );
4002 fwrite( &objects.position[k].y, 1, sizeof(float), tfile );
4003 fwrite( &objects.position[k].z, 1, sizeof(float), tfile );
4004 fwrite( &objects.scale[k], 1, sizeof(float), tfile );
4007 fwrite( &numplayers, 1, sizeof(int), tfile );
4008 if(numplayers>1&&numplayers<maxplayers)
4009 for(j=1;j<numplayers;j++){
4010 fwrite( &player[j].whichskin, 1, sizeof(int), tfile );
4011 fwrite( &player[j].creature, 1, sizeof(int), tfile );
4012 fwrite( &player[j].coords.x, 1, sizeof(float), tfile );
4013 fwrite( &player[j].coords.y, 1, sizeof(float), tfile );
4014 fwrite( &player[j].coords.z, 1, sizeof(float), tfile );
4015 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4016 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4017 for(k=0;k<player[j].num_weapons;k++){
4018 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4020 if(player[j].numwaypoints<30){
4021 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4022 for(k=0;k<player[j].numwaypoints;k++){
4023 fwrite( &player[j].waypoints[k].x, 1, sizeof(float), tfile );
4024 fwrite( &player[j].waypoints[k].y, 1, sizeof(float), tfile );
4025 fwrite( &player[j].waypoints[k].z, 1, sizeof(float), tfile );
4027 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4028 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4031 player[j].numwaypoints=0;
4032 player[j].waypoint=0;
4033 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4034 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4035 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4037 fwrite( &player[j].armorhead, 1, sizeof(int), tfile );
4038 fwrite( &player[j].armorhigh, 1, sizeof(int), tfile );
4039 fwrite( &player[j].armorlow, 1, sizeof(int), tfile );
4040 fwrite( &player[j].protectionhead, 1, sizeof(int), tfile );
4041 fwrite( &player[j].protectionhigh, 1, sizeof(int), tfile );
4042 fwrite( &player[j].protectionlow, 1, sizeof(int), tfile );
4043 fwrite( &player[j].metalhead, 1, sizeof(int), tfile );
4044 fwrite( &player[j].metalhigh, 1, sizeof(int), tfile );
4045 fwrite( &player[j].metallow, 1, sizeof(int), tfile );
4046 fwrite( &player[j].power, 1, sizeof(int), tfile );
4047 fwrite( &player[j].speedmult, 1, sizeof(int), tfile );
4049 fwrite( &player[j].numclothes, 1, sizeof(int), tfile );
4050 if(player[j].numclothes)
4051 for(k=0;k<player[j].numclothes;k++){
4053 templength=strlen(player[j].clothes[k]);
4054 fwrite( &templength,1,sizeof(int),tfile);
4055 for(l=0;l<templength;l++)
4056 fwrite( &player[j].clothes[k][l],1,sizeof(char),tfile);
4057 fwrite( &player[j].clothestintr[k],1,sizeof(float),tfile);
4058 fwrite( &player[j].clothestintg[k],1,sizeof(float),tfile);
4059 fwrite( &player[j].clothestintb[k],1,sizeof(float),tfile);
4062 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4064 for(j=0;j<numpathpoints;j++){
4065 fwrite( &pathpoint[j].x, 1, sizeof(float), tfile );
4066 fwrite( &pathpoint[j].y, 1, sizeof(float), tfile );
4067 fwrite( &pathpoint[j].z, 1, sizeof(float), tfile );
4068 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4069 for(k=0;k<numpathpointconnect[j];k++){
4070 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4074 fwrite( &mapcenter.x, 1, sizeof(float), tfile );
4075 fwrite( &mapcenter.y, 1, sizeof(float), tfile );
4076 fwrite( &mapcenter.z, 1, sizeof(float), tfile );
4078 fwrite( &mapradius, 1, sizeof(float), tfile );
4084 if(Compare(consoletext[0],"save ",0,4)){
4096 for(j=5;j<consolechars[0];j++){
4097 mapname[j-5+11]=consoletext[0][j];
4099 mapname[consolechars[0]-5+11]='\0';
4101 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
4102 OPENAL_SetVolume(channels[consolesuccesssound], 256);
4103 OPENAL_SetPaused(channels[consolesuccesssound], false);
4106 tfile=fopen( mapname, "wb" );
4107 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
4108 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
4109 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
4110 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
4111 if(player[0].num_weapons>0&&player[0].num_weapons<5)
4112 for(j=0;j<player[0].num_weapons;j++){
4113 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
4115 fwrite( &environment, 1, sizeof(int), tfile );
4117 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
4118 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
4119 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
4120 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
4121 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
4123 fwrite( &numplayers, 1, sizeof(int), tfile );
4124 if(numplayers>1&&numplayers<maxplayers)
4125 for(j=1;j<numplayers;j++){
4126 fwrite( &player[j].coords, 1, sizeof(XYZ), tfile );
4127 fwrite( &player[j].num_weapons, 1, sizeof(int), tfile );
4128 if(player[j].num_weapons>0&&player[j].num_weapons<5)
4129 for(k=0;k<player[j].num_weapons;k++){
4130 fwrite( &weapons.type[player[j].weaponids[k]], 1, sizeof(int), tfile );
4132 if(player[j].numwaypoints<30){
4133 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4134 fwrite( &player[j].waypoints, 1, sizeof(XYZ)*player[j].numwaypoints, tfile );
4135 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4136 //fwrite( &player[j].jumppath, 1, sizeof(bool), tfile );
4139 player[j].numwaypoints=0;
4140 player[j].waypoint=0;
4141 fwrite( &player[j].numwaypoints, 1, sizeof(int), tfile );
4142 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4143 fwrite( &player[j].waypoint, 1, sizeof(int), tfile );
4146 fwrite( &numpathpoints, 1, sizeof(int), tfile );
4148 for(j=0;j<numpathpoints;j++){
4149 fwrite( &pathpoint[j], 1, sizeof(XYZ), tfile );
4150 fwrite( &numpathpointconnect[j], 1, sizeof(int), tfile );
4151 for(k=0;k<numpathpointconnect[j];k++){
4152 fwrite( &pathpointconnect[j][k], 1, sizeof(int), tfile );
4158 if(Compare(consoletext[0],"cellar door ",0,11)||Compare(consoletext[0],"cellardoor ",0,10)){
4159 LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4162 /*if(Compare(consoletext[0],"Pants ",0,5)){
4163 AddClothes(":Data:Textures:Pants.png",0,1,&player[i].skeleton.skinText[0],&player[i].skeleton.skinsize);
4164 player[i].DoMipmaps(5,0,0,player[i].skeleton.skinsize,player[i].skeleton.skinsize);
4168 if(Compare(consoletext[0],"tintr ",0,5)||Compare(consoletext[0],"Tintr ",0,5)){
4169 for(j=6;j<consolechars[0];j++){
4170 mapname[j-6]=consoletext[0][j];
4173 tintr=atof(mapname);
4178 if(Compare(consoletext[0],"speed ",0,5)||Compare(consoletext[0],"Speed ",0,5)){
4179 for(j=6;j<consolechars[0];j++){
4180 mapname[j-6]=consoletext[0][j];
4183 player[0].speedmult=atof(mapname);
4188 if(Compare(consoletext[0],"strength ",0,8)||Compare(consoletext[0],"Strength ",0,8)){
4189 for(j=9;j<consolechars[0];j++){
4190 mapname[j-9]=consoletext[0][j];
4193 player[0].power=atof(mapname);
4198 if(Compare(consoletext[0],"viewdistance ",0,12)||Compare(consoletext[0],"Viewdistance ",0,12)){
4199 for(j=13;j<consolechars[0];j++){
4200 mapname[j-13]=consoletext[0][j];
4203 viewdistance=atof(mapname)*100;
4208 if(Compare(consoletext[0],"fadestart ",0,9)||Compare(consoletext[0],"Fadestart ",0,9)){
4209 for(j=10;j<consolechars[0];j++){
4210 mapname[j-10]=consoletext[0][j];
4213 fadestart=atof(mapname);
4218 if(Compare(consoletext[0],"power ",0,5)||Compare(consoletext[0],"Power ",0,5)){
4219 for(j=6;j<consolechars[0];j++){
4220 mapname[j-6]=consoletext[0][j];
4223 player[0].power=atof(mapname);
4228 if(Compare(consoletext[0],"slomo ",0,5)||Compare(consoletext[0],"Slomo ",0,5)){
4229 for(j=6;j<consolechars[0];j++){
4230 mapname[j-6]=consoletext[0][j];
4233 slomospeed=atof(mapname);
4240 if(Compare(consoletext[0],"slofreq ",0,7)||Compare(consoletext[0],"Slofreq ",0,7)){
4241 for(j=8;j<consolechars[0];j++){
4242 mapname[j-8]=consoletext[0][j];
4245 slomofreq=atoi(mapname);
4250 if(Compare(consoletext[0],"size ",0,4)||Compare(consoletext[0],"Size ",0,4)){
4251 for(j=5;j<consolechars[0];j++){
4252 mapname[j-5]=consoletext[0][j];
4255 player[0].scale=atof(mapname)*.2;
4260 if(Compare(consoletext[0],"sizenear ",0,8)||Compare(consoletext[0],"Sizenear ",0,8)){
4262 float closestdist=-1;
4265 for(i=1;i<numplayers;i++){
4266 distance=findDistancefast(&player[i].coords,&player[0].coords);
4267 if(closestdist==-1||distance<closestdist){
4268 closestdist=distance;
4273 for(j=9;j<consolechars[0];j++){
4274 mapname[j-9]=consoletext[0][j];
4277 player[closest].scale=atof(mapname)*.2;
4282 if(Compare(consoletext[0],"proportionnear ",0,14)||Compare(consoletext[0],"Proportionnear ",0,14)){
4287 float closestdist=-1;
4290 for(i=1;i<numplayers;i++){
4291 distance=findDistancefast(&player[i].coords,&player[0].coords);
4292 if(closestdist==-1||distance<closestdist){
4293 closestdist=distance;
4301 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4302 mapname[j-startpoint]=consoletext[0][j];
4304 if(consoletext[0][j]=='\0')alldone=1;
4306 mapname[j-startpoint]='\0';
4308 headprop=atof(mapname);
4312 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4313 mapname[j-startpoint]=consoletext[0][j];
4315 if(consoletext[0][j]=='\0')alldone=1;
4317 mapname[j-startpoint]='\0';
4319 bodyprop=atof(mapname);
4323 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4324 mapname[j-startpoint]=consoletext[0][j];
4326 if(consoletext[0][j]=='\0')alldone=1;
4328 mapname[j-startpoint]='\0';
4330 armprop=atof(mapname);
4334 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4335 mapname[j-startpoint]=consoletext[0][j];
4337 if(consoletext[0][j]=='\0')alldone=1;
4339 mapname[j-startpoint]='\0';
4341 legprop=atof(mapname);
4343 if(player[closest].creature==wolftype){
4344 player[closest].proportionhead=1.1*headprop;
4345 player[closest].proportionbody=1.1*bodyprop;
4346 player[closest].proportionarms=1.1*armprop;
4347 player[closest].proportionlegs=1.1*legprop;
4350 if(player[closest].creature==rabbittype){
4351 player[closest].proportionhead=1.2*headprop;
4352 player[closest].proportionbody=1.05*bodyprop;
4353 player[closest].proportionarms=1.00*armprop;
4354 player[closest].proportionlegs=1.1*legprop;
4355 player[closest].proportionlegs.y=1.05*legprop;
4362 if(Compare(consoletext[0],"sizemin ",0,7)||Compare(consoletext[0],"Sizemin ",0,7)){
4363 for(i=1;i<numplayers;i++){
4364 if(player[i].scale<0.8*0.2)player[i].scale=0.8*0.2;
4370 if(Compare(consoletext[0],"tutorial ",0,8)||Compare(consoletext[0],"Tutorial ",0,8)){
4371 for(j=9;j<consolechars[0];j++){
4372 mapname[j-9]=consoletext[0][j];
4375 tutoriallevel=atoi(mapname);
4381 if(Compare(consoletext[0],"tintg ",0,5)||Compare(consoletext[0],"Tintg ",0,5)){
4382 for(j=6;j<consolechars[0];j++){
4383 mapname[j-6]=consoletext[0][j];
4386 tintg=atof(mapname);
4391 if(Compare(consoletext[0],"tintb ",0,5)||Compare(consoletext[0],"Tintb ",0,5)){
4392 for(j=6;j<consolechars[0];j++){
4393 mapname[j-6]=consoletext[0][j];
4396 tintb=atof(mapname);
4401 if(Compare(consoletext[0],"hostile ",0,7)){
4402 for(j=8;j<consolechars[0];j++){
4403 mapname[j-8]=consoletext[0][j];
4406 hostile=atoi(mapname);
4412 if(Compare(consoletext[0],"type active ",0,11)){
4413 editoractive=typeactive;
4418 if(Compare(consoletext[0],"indemo ",0,6)){
4420 hotspot[numhotspots]=player[0].coords;
4421 hotspotsize[numhotspots]=0;
4422 hotspottype[numhotspots]=-111;
4424 strcpy(hotspottext[numhotspots],"mapname");
4430 if(Compare(consoletext[0],"notindemo ",0,9)){
4437 if(Compare(consoletext[0],"type sitting ",0,12)){
4438 editoractive=typesitting;
4443 if(Compare(consoletext[0],"type sitting wall ",0,17)){
4444 editoractive=typesittingwall;
4449 if(Compare(consoletext[0],"type sleeping ",0,13)){
4450 editoractive=typesleeping;
4454 if(Compare(consoletext[0],"type dead1 ",0,10)){
4455 editoractive=typedead1;
4459 if(Compare(consoletext[0],"type dead2 ",0,10)){
4460 editoractive=typedead2;
4464 if(Compare(consoletext[0],"type dead3 ",0,10)){
4465 editoractive=typedead3;
4468 if(Compare(consoletext[0],"type dead4 ",0,10)){
4469 editoractive=typedead4;
4474 if(Compare(consoletext[0],"path keepwalking ",0,16)){
4475 editorpathtype=wpkeepwalking;
4480 if(Compare(consoletext[0],"path pause ",0,10)){
4481 editorpathtype=wppause;
4486 if(Compare(consoletext[0],"mapkilleveryone ",0,15)){
4487 maptype=mapkilleveryone;
4492 if(Compare(consoletext[0],"mapgosomewhere ",0,14)){
4493 maptype=mapgosomewhere;
4498 if(Compare(consoletext[0],"mapkillsomeone ",0,14)){
4499 maptype=mapkillsomeone;
4505 if(Compare(consoletext[0],"mapkillmost ",0,11)){
4506 maptype=mapkillmost;
4512 if(Compare(consoletext[0],"hs ",0,2)){
4516 hotspot[numhotspots]=player[0].coords;
4521 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4522 mapname[j-startpoint]=consoletext[0][j];
4524 if(consoletext[0][j]=='\0')alldone=1;
4526 mapname[j-startpoint]='\0';
4528 hotspotsize[numhotspots]=atof(mapname);
4532 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4533 mapname[j-startpoint]=consoletext[0][j];
4535 if(consoletext[0][j]=='\0')alldone=1;
4537 mapname[j-startpoint]='\0';
4539 hotspottype[numhotspots]=atoi(mapname);
4543 while(consoletext[0][j]!='\0'&&!alldone&&j<255){
4544 mapname[j-startpoint]=consoletext[0][j];
4546 if(consoletext[0][j]=='\0')alldone=1;
4548 mapname[j-startpoint]='\n';
4549 mapname[j-startpoint+1]='\0';
4551 strcpy(hotspottext[numhotspots],mapname);
4558 if(Compare(consoletext[0],"dialogue ",0,8)){
4565 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4566 mapname[j-startpoint]=consoletext[0][j];
4568 if(consoletext[0][j]=='\0')alldone=1;
4570 mapname[j-startpoint]='\0';
4573 dialoguetype[numdialogues]=atoi(mapname);
4591 for(j=startpoint;j<consolechars[0];j++){
4592 mapname[j-startpoint+16]=consoletext[0][j];
4594 mapname[consolechars[0]-startpoint+16]='.';
4595 mapname[consolechars[0]-startpoint+17]='t';
4596 mapname[consolechars[0]-startpoint+18]='x';
4597 mapname[consolechars[0]-startpoint+19]='t';
4598 mapname[consolechars[0]-startpoint+20]='\0';
4600 for(j=0;j<max_dialoguelength;j++){
4602 dialoguetext[numdialogues][j][k]='\0';
4605 dialoguename[numdialogues][j][k]='\0';
4609 ifstream ipstream(ConvertFileName(mapname));
4610 ipstream.ignore(256,':');
4611 ipstream >> numdialogueboxes[numdialogues];
4612 for(i=0;i<numdialogueboxes[numdialogues];i++){
4613 ipstream.ignore(256,':');
4614 ipstream.ignore(256,':');
4615 ipstream.ignore(256,' ');
4616 ipstream >> dialogueboxlocation[numdialogues][i];
4617 ipstream.ignore(256,':');
4618 ipstream >> dialogueboxcolor[numdialogues][i][0];
4619 ipstream >> dialogueboxcolor[numdialogues][i][1];
4620 ipstream >> dialogueboxcolor[numdialogues][i][2];
4621 ipstream.ignore(256,':');
4622 ipstream.getline(dialoguename[numdialogues][i],64);
4623 ipstream.ignore(256,':');
4624 ipstream.ignore(256,' ');
4625 ipstream.getline(dialoguetext[numdialogues][i],128);
4627 if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
4629 ipstream.ignore(256,':');
4630 ipstream >> dialogueboxsound[numdialogues][i];
4633 for(i=0;i<numdialogueboxes[numdialogues];i++){
4634 for(j=0;j<numplayers;j++){
4635 participantfacing[numdialogues][i][j]=player[j].facing;
4642 whichdialogue=numdialogues;
4650 if(Compare(consoletext[0],"fixdialogue ",0,11)){
4658 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4659 mapname[j-startpoint]=consoletext[0][j];
4661 if(consoletext[0][j]=='\0')alldone=1;
4663 mapname[j-startpoint]='\0';
4666 whichdi=atoi(mapname);
4684 for(j=startpoint;j<consolechars[0];j++){
4685 mapname[j-startpoint+16]=consoletext[0][j];
4687 mapname[consolechars[0]-startpoint+16]='.';
4688 mapname[consolechars[0]-startpoint+17]='t';
4689 mapname[consolechars[0]-startpoint+18]='x';
4690 mapname[consolechars[0]-startpoint+19]='t';
4691 mapname[consolechars[0]-startpoint+20]='\0';
4693 for(j=0;j<max_dialoguelength;j++){
4695 dialoguetext[whichdi][j][k]='\0';
4698 dialoguename[whichdi][j][k]='\0';
4702 ifstream ipstream(ConvertFileName(mapname));
4703 ipstream.ignore(256,':');
4704 ipstream >> numdialogueboxes[whichdi];
4705 for(i=0;i<numdialogueboxes[whichdi];i++){
4706 ipstream.ignore(256,':');
4707 ipstream.ignore(256,':');
4708 ipstream.ignore(256,' ');
4709 ipstream >> dialogueboxlocation[whichdi][i];
4710 ipstream.ignore(256,':');
4711 ipstream >> dialogueboxcolor[whichdi][i][0];
4712 ipstream >> dialogueboxcolor[whichdi][i][1];
4713 ipstream >> dialogueboxcolor[whichdi][i][2];
4714 ipstream.ignore(256,':');
4715 ipstream.getline(dialoguename[whichdi][i],64);
4716 ipstream.ignore(256,':');
4717 ipstream.ignore(256,' ');
4718 ipstream.getline(dialoguetext[whichdi][i],128);
4720 if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
4722 ipstream.ignore(256,':');
4723 ipstream >> dialogueboxsound[whichdi][i];
4731 if(Compare(consoletext[0],"fixtype ",0,7)){
4739 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4740 mapname[j-startpoint]=consoletext[0][j];
4742 if(consoletext[0][j]=='\0')alldone=1;
4744 mapname[j-startpoint]='\0';
4745 dialoguetype[0]=atoi(mapname);
4753 if(Compare(consoletext[0],"fixrotation ",0,11)){
4754 participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
4759 if(Compare(consoletext[0],"ddialogue ",0,9)){
4761 if(numdialogues<0)numdialogues=0;
4766 if(Compare(consoletext[0],"immobile ",0,8)){
4767 player[0].immobile=1;
4771 if(Compare(consoletext[0],"mobile ",0,6)){
4772 player[0].immobile=0;
4776 if(Compare(consoletext[0],"play ",0,4)){
4783 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4784 mapname[j-startpoint]=consoletext[0][j];
4786 if(consoletext[0][j]=='\0')alldone=1;
4788 mapname[j-startpoint]='\0';
4791 whichdialogue=atoi(mapname);
4793 if(numdialogues>whichdialogue){
4794 for(i=0;i<numdialogueboxes[whichdialogue];i++){
4795 player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
4796 player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4797 player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
4798 player[participantfocus[whichdialogue][i]].velocity=0;
4799 player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
4800 player[participantfocus[whichdialogue][i]].targetframe=0;
4808 //if(dialogueboxsound[whichdialogue][indialogue]!=0){
4812 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
4813 temppos=temppos-viewer;
4814 Normalise(&temppos);
4824 whichsoundplay=rabbitchitter;
4825 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
4826 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
4827 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
4828 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
4829 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
4830 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
4831 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
4832 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
4833 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
4834 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
4835 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
4836 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
4837 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
4838 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
4839 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
4840 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
4841 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
4842 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
4843 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
4844 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
4845 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
4846 OPENAL_SetVolume(channels[whichsoundplay], 256);
4847 OPENAL_SetPaused(channels[whichsoundplay], false);
4855 if(Compare(consoletext[0],"dhs ",0,3)){
4857 if(numhotspots<0)numhotspots=0;
4862 if(Compare(consoletext[0],"proportion ",0,10)||Compare(consoletext[0],"Proportion ",0,4)){
4869 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4870 mapname[j-startpoint]=consoletext[0][j];
4872 if(consoletext[0][j]=='\0')alldone=1;
4874 mapname[j-startpoint]='\0';
4876 headprop=atof(mapname);
4880 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4881 mapname[j-startpoint]=consoletext[0][j];
4883 if(consoletext[0][j]=='\0')alldone=1;
4885 mapname[j-startpoint]='\0';
4887 bodyprop=atof(mapname);
4891 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4892 mapname[j-startpoint]=consoletext[0][j];
4894 if(consoletext[0][j]=='\0')alldone=1;
4896 mapname[j-startpoint]='\0';
4898 armprop=atof(mapname);
4902 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
4903 mapname[j-startpoint]=consoletext[0][j];
4905 if(consoletext[0][j]=='\0')alldone=1;
4907 mapname[j-startpoint]='\0';
4909 legprop=atof(mapname);
4911 if(player[0].creature==wolftype){
4912 player[0].proportionhead=1.1*headprop;
4913 player[0].proportionbody=1.1*bodyprop;
4914 player[0].proportionarms=1.1*armprop;
4915 player[0].proportionlegs=1.1*legprop;
4918 if(player[0].creature==rabbittype){
4919 player[0].proportionhead=1.2*headprop;
4920 player[0].proportionbody=1.05*bodyprop;
4921 player[0].proportionarms=1.00*armprop;
4922 player[0].proportionlegs=1.1*legprop;
4923 player[0].proportionlegs.y=1.05*legprop;
4929 if(Compare(consoletext[0],"allimmobile ",0,11)||Compare(consoletext[0],"Allimmobile ",0,11)){
4930 for(i=0;i<numplayers;i++){
4931 if(i>0)player[i].immobile=1;
4937 if(Compare(consoletext[0],"default ",0,7)||Compare(consoletext[0],"Default ",0,7)){
4938 player[0].armorhead=1;
4939 player[0].armorhigh=1;
4940 player[0].armorlow=1;
4941 player[0].protectionhead=1;
4942 player[0].protectionhigh=1;
4943 player[0].protectionlow=1;
4944 player[0].metalhead=1;
4945 player[0].metalhigh=1;
4946 player[0].metallow=1;
4948 player[0].speedmult=1;
4951 if(player[0].creature==wolftype){
4952 player[0].proportionhead=1.1;
4953 player[0].proportionbody=1.1;
4954 player[0].proportionarms=1.1;
4955 player[0].proportionlegs=1.1;
4958 if(player[0].creature==rabbittype){
4959 player[0].proportionhead=1.2;
4960 player[0].proportionbody=1.05;
4961 player[0].proportionarms=1.00;
4962 player[0].proportionlegs=1.1;
4963 player[0].proportionlegs.y=1.05;
4966 player[0].numclothes=0;
4967 if(player[0].whichskin==0){
4968 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4970 else if(player[0].whichskin==1){
4971 LoadTextureSave(":Data:Textures:Fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4973 else if(player[0].whichskin==2){
4974 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4976 else if(player[0].whichskin==3){
4977 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4979 else if(player[0].whichskin==4){
4980 LoadTextureSave(":Data:Textures:Otter.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4982 else if(player[0].whichskin==5){
4983 LoadTextureSave(":Data:Textures:Opal.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4985 else if(player[0].whichskin==6){
4986 LoadTextureSave(":Data:Textures:Sable.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4988 else if(player[0].whichskin==7){
4989 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4991 else if(player[0].whichskin==8){
4992 LoadTextureSave(":Data:Textures:BW2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4994 else if(player[0].whichskin==9){
4995 LoadTextureSave(":Data:Textures:WB2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
4998 editoractive=typeactive;
4999 player[0].immobile=0;
5006 if(Compare(consoletext[0],"tint ",0,4)||Compare(consoletext[0],"Tint ",0,4)){
5012 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5013 mapname[j-startpoint]=consoletext[0][j];
5015 if(consoletext[0][j]=='\0')alldone=1;
5017 mapname[j-startpoint]='\0';
5019 tintr=atof(mapname);
5023 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5024 mapname[j-startpoint]=consoletext[0][j];
5026 if(consoletext[0][j]=='\0')alldone=1;
5028 mapname[j-startpoint]='\0';
5030 tintg=atof(mapname);
5034 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5035 mapname[j-startpoint]=consoletext[0][j];
5037 if(consoletext[0][j]=='\0')alldone=1;
5039 mapname[j-startpoint]='\0';
5041 tintb=atof(mapname);
5046 if(Compare(consoletext[0],"sky tint ",0,8)||Compare(consoletext[0],"Sky Tint ",0,8)){
5052 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5053 mapname[j-startpoint]=consoletext[0][j];
5055 if(consoletext[0][j]=='\0')alldone=1;
5057 mapname[j-startpoint]='\0';
5059 skyboxr=atof(mapname);
5063 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5064 mapname[j-startpoint]=consoletext[0][j];
5066 if(consoletext[0][j]=='\0')alldone=1;
5068 mapname[j-startpoint]='\0';
5070 skyboxg=atof(mapname);
5074 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5075 mapname[j-startpoint]=consoletext[0][j];
5077 if(consoletext[0][j]=='\0')alldone=1;
5079 mapname[j-startpoint]='\0';
5081 skyboxb=atof(mapname);
5083 skyboxlightr=skyboxr;
5084 skyboxlightg=skyboxg;
5085 skyboxlightb=skyboxb;
5089 //if(skyboxtexture){
5090 terrain.DoShadows();
5091 objects.DoShadows();
5093 else terrain.DoLighting();
5098 if(Compare(consoletext[0],"sky light ",0,9)||Compare(consoletext[0],"Sky Light ",0,9)){
5104 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5105 mapname[j-startpoint]=consoletext[0][j];
5107 if(consoletext[0][j]=='\0')alldone=1;
5109 mapname[j-startpoint]='\0';
5111 skyboxlightr=atof(mapname);
5115 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5116 mapname[j-startpoint]=consoletext[0][j];
5118 if(consoletext[0][j]=='\0')alldone=1;
5120 mapname[j-startpoint]='\0';
5122 skyboxlightg=atof(mapname);
5126 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5127 mapname[j-startpoint]=consoletext[0][j];
5129 if(consoletext[0][j]=='\0')alldone=1;
5131 mapname[j-startpoint]='\0';
5133 skyboxlightb=atof(mapname);
5137 //if(skyboxtexture){
5138 terrain.DoShadows();
5139 objects.DoShadows();
5141 else terrain.DoLighting();
5146 if(Compare(consoletext[0],"skybox ",0,6)||Compare(consoletext[0],"Skybox ",0,6)){
5147 skyboxtexture=1-skyboxtexture;
5150 //if(skyboxtexture){
5151 terrain.DoShadows();
5152 objects.DoShadows();
5154 else terrain.DoLighting();
5159 if(Compare(consoletext[0],"protection ",0,10)||Compare(consoletext[0],"Protection ",0,10)){
5165 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5166 mapname[j-startpoint]=consoletext[0][j];
5168 if(consoletext[0][j]=='\0')alldone=1;
5170 mapname[j-startpoint]='\0';
5172 player[0].protectionhead=atof(mapname);
5176 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5177 mapname[j-startpoint]=consoletext[0][j];
5179 if(consoletext[0][j]=='\0')alldone=1;
5181 mapname[j-startpoint]='\0';
5183 player[0].protectionhigh=atof(mapname);
5187 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5188 mapname[j-startpoint]=consoletext[0][j];
5190 if(consoletext[0][j]=='\0')alldone=1;
5192 mapname[j-startpoint]='\0';
5194 player[0].protectionlow=atof(mapname);
5199 if(Compare(consoletext[0],"armor ",0,5)||Compare(consoletext[0],"Armor ",0,5)){
5205 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5206 mapname[j-startpoint]=consoletext[0][j];
5208 if(consoletext[0][j]=='\0')alldone=1;
5210 mapname[j-startpoint]='\0';
5212 player[0].armorhead=atof(mapname);
5216 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5217 mapname[j-startpoint]=consoletext[0][j];
5219 if(consoletext[0][j]=='\0')alldone=1;
5221 mapname[j-startpoint]='\0';
5223 player[0].armorhigh=atof(mapname);
5227 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5228 mapname[j-startpoint]=consoletext[0][j];
5230 if(consoletext[0][j]=='\0')alldone=1;
5232 mapname[j-startpoint]='\0';
5234 player[0].armorlow=atof(mapname);
5239 if(Compare(consoletext[0],"protectionreset ",0,15)||Compare(consoletext[0],"Protectionreset ",0,15)){
5240 for(i=0;i<numplayers;i++){
5241 player[i].protectionhead=1.0;
5242 player[i].protectionhigh=1.0;
5243 player[i].protectionlow=1.0;
5244 player[i].armorhead=1.0;
5245 player[i].armorhigh=1.0;
5246 player[i].armorlow=1.0;
5252 if(Compare(consoletext[0],"protectionnear ",0,14)||Compare(consoletext[0],"Protectionnear ",0,14)){
5254 float closestdist=-1;
5257 for(i=1;i<numplayers;i++){
5258 distance=findDistancefast(&player[i].coords,&player[0].coords);
5259 if(closestdist==-1||distance<closestdist){
5260 closestdist=distance;
5270 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5271 mapname[j-startpoint]=consoletext[0][j];
5273 if(consoletext[0][j]=='\0')alldone=1;
5275 mapname[j-startpoint]='\0';
5277 player[closest].protectionhead=atof(mapname);
5281 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5282 mapname[j-startpoint]=consoletext[0][j];
5284 if(consoletext[0][j]=='\0')alldone=1;
5286 mapname[j-startpoint]='\0';
5288 player[closest].protectionhigh=atof(mapname);
5292 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5293 mapname[j-startpoint]=consoletext[0][j];
5295 if(consoletext[0][j]=='\0')alldone=1;
5297 mapname[j-startpoint]='\0';
5299 player[closest].protectionlow=atof(mapname);
5304 if(Compare(consoletext[0],"armornear ",0,9)||Compare(consoletext[0],"Armornear ",0,9)){
5306 float closestdist=-1;
5309 for(i=1;i<numplayers;i++){
5310 distance=findDistancefast(&player[i].coords,&player[0].coords);
5311 if(closestdist==-1||distance<closestdist){
5312 closestdist=distance;
5321 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5322 mapname[j-startpoint]=consoletext[0][j];
5324 if(consoletext[0][j]=='\0')alldone=1;
5326 mapname[j-startpoint]='\0';
5328 player[closest].armorhead=atof(mapname);
5332 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5333 mapname[j-startpoint]=consoletext[0][j];
5335 if(consoletext[0][j]=='\0')alldone=1;
5337 mapname[j-startpoint]='\0';
5339 player[closest].armorhigh=atof(mapname);
5343 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5344 mapname[j-startpoint]=consoletext[0][j];
5346 if(consoletext[0][j]=='\0')alldone=1;
5348 mapname[j-startpoint]='\0';
5350 player[closest].armorlow=atof(mapname);
5356 if(Compare(consoletext[0],"metal ",0,5)||Compare(consoletext[0],"Metal ",0,5)){
5362 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5363 mapname[j-startpoint]=consoletext[0][j];
5365 if(consoletext[0][j]=='\0')alldone=1;
5367 mapname[j-startpoint]='\0';
5369 player[0].metalhead=atof(mapname);
5373 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5374 mapname[j-startpoint]=consoletext[0][j];
5376 if(consoletext[0][j]=='\0')alldone=1;
5378 mapname[j-startpoint]='\0';
5380 player[0].metalhigh=atof(mapname);
5384 while(consoletext[0][j]!='\0'&&consoletext[0][j]!=' '&&!alldone&&j<255){
5385 mapname[j-startpoint]=consoletext[0][j];
5387 if(consoletext[0][j]=='\0')alldone=1;
5390 mapname[j-startpoint]='\0';
5392 player[0].metallow=atof(mapname);
5397 if(Compare(consoletext[0],"noclothesnear ",0,13)||Compare(consoletext[0],"Noclothesnear ",0,13)){
5399 float closestdist=-1;
5402 for(i=1;i<numplayers;i++){
5403 distance=findDistancefast(&player[i].coords,&player[0].coords);
5404 if(closestdist==-1||distance<closestdist){
5405 closestdist=distance;
5409 player[closest].numclothes=0;
5410 if(player[closest].whichskin==0){
5411 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5413 else if(player[closest].whichskin==1){
5414 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5416 else if(player[closest].whichskin==2){
5417 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5419 else if(player[closest].whichskin==3){
5420 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5422 else if(player[closest].whichskin==4){
5423 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5425 else if(player[closest].whichskin==5){
5426 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5428 else if(player[closest].whichskin==6){
5429 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5431 else if(player[closest].whichskin==7){
5432 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5434 else if(player[closest].whichskin==8){
5435 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5437 else if(player[closest].whichskin==9){
5438 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5444 if(Compare(consoletext[0],"noclothes ",0,9)||Compare(consoletext[0],"Noclothes ",0,9)){
5447 player[closest].numclothes=0;
5448 if(player[closest].whichskin==0){
5449 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5451 else if(player[closest].whichskin==1){
5452 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5454 else if(player[closest].whichskin==2){
5455 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5457 else if(player[closest].whichskin==3){
5458 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5460 else if(player[closest].whichskin==4){
5461 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5463 else if(player[closest].whichskin==5){
5464 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5466 else if(player[closest].whichskin==6){
5467 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5469 else if(player[closest].whichskin==7){
5470 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5472 else if(player[closest].whichskin==8){
5473 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5475 else if(player[closest].whichskin==9){
5476 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
5482 if((Compare(consoletext[0],"Clothes ",0,7)||Compare(consoletext[0],"clothes ",0,7))){
5498 for(j=8;j<consolechars[0];j++){
5499 mapname[j-8+15]=consoletext[0][j];
5501 mapname[consolechars[0]-8+15]='.';
5502 mapname[consolechars[0]-8+16]='p';
5503 mapname[consolechars[0]-8+17]='n';
5504 mapname[consolechars[0]-8+18]='g';
5505 mapname[consolechars[0]-8+19]='\0';
5507 //:Data:Textures:Pants.png
5509 if(AddClothes((char *)mapname,0,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize)){
5510 player[0].DoMipmaps(5,0,0,player[0].skeleton.skinsize,player[0].skeleton.skinsize);
5511 strcpy(player[0].clothes[player[0].numclothes],mapname);
5512 player[0].clothestintr[player[0].numclothes]=tintr;
5513 player[0].clothestintg[player[0].numclothes]=tintg;
5514 player[0].clothestintb[player[0].numclothes]=tintb;
5515 player[0].numclothes++;
5521 if(Compare(consoletext[0],"belt ",0,4)||Compare(consoletext[0],"belt ",0,4)){
5522 player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
5527 if(Compare(consoletext[0],"Cellophane ",0,10)||Compare(consoletext[0],"cellophane ",0,10)){
5528 cellophane=1-cellophane;
5531 for(i=0;i<numplayers;i++){
5532 player[i].proportionhead.z=0;
5533 player[i].proportionbody.z=0;
5534 player[i].proportionarms.z=0;
5535 player[i].proportionlegs.z=0;
5540 for(i=0;i<numplayers;i++){
5541 player[i].proportionhead.z=player[i].proportionhead.x;
5542 player[i].proportionbody.z=player[i].proportionbody.x;
5543 player[i].proportionarms.z=player[i].proportionarms.x;
5544 player[i].proportionlegs.z=player[i].proportionlegs.x;
5551 if((Compare(consoletext[0],"Clothesnear ",0,11)||Compare(consoletext[0],"clothesnear ",0,11))){
5567 for(j=12;j<consolechars[0];j++){
5568 mapname[j-12+15]=consoletext[0][j];
5570 mapname[consolechars[0]-12+15]='.';
5571 mapname[consolechars[0]-12+16]='p';
5572 mapname[consolechars[0]-12+17]='n';
5573 mapname[consolechars[0]-12+18]='g';
5574 mapname[consolechars[0]-12+19]='\0';
5576 //:Data:Textures:Pants.png
5578 float closestdist=-1;
5581 for(i=1;i<numplayers;i++){
5582 distance=findDistancefast(&player[i].coords,&player[0].coords);
5583 if(closestdist==-1||distance<closestdist){
5584 closestdist=distance;
5589 if(AddClothes((char *)mapname,0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize)){
5590 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
5591 strcpy(player[closest].clothes[player[closest].numclothes],mapname);
5592 player[closest].clothestintr[player[closest].numclothes]=tintr;
5593 player[closest].clothestintg[player[closest].numclothes]=tintg;
5594 player[closest].clothestintb[player[closest].numclothes]=tintb;
5595 player[closest].numclothes++;
5601 if(Compare(consoletext[0],"funnybunny ",0,10)||Compare(consoletext[0],"funny bunny ",0,11)){
5602 player[0].skeleton.id=0;
5603 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);
5604 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5605 player[0].creature=rabbittype;
5608 player[0].proportionhead=1.2;
5609 player[0].proportionbody=1.05;
5610 player[0].proportionarms=1.00;
5611 player[0].proportionlegs=1.1;
5612 player[0].proportionlegs.y=1.05;
5613 player[0].headless=0;
5615 player[0].damagetolerance=200;
5619 if(Compare(consoletext[0],"wolfieisgod ",0,11)||Compare(consoletext[0],"wolfie is god ",0,12)){
5620 player[0].skeleton.id=0;
5621 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);
5622 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5623 player[0].creature=wolftype;
5625 player[0].proportionhead=1.1;
5626 player[0].proportionbody=1.1;
5627 player[0].proportionarms=1.1;
5628 player[0].proportionlegs=1.1;
5629 player[0].proportionlegs.y=1.1;
5630 player[0].scale=.23;
5632 player[0].damagetolerance=300;
5636 /*if(Compare(consoletext[0],"kungfu ",0,6)||Compare(consoletext[0],"kung fu ",0,7)){
5637 LoadTextureSave(":Data:Textures:Kungfu.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5640 if(Compare(consoletext[0],"rambo ",0,5)){
5641 LoadTextureSave(":Data:Textures:Leather.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5644 if(Compare(consoletext[0],"david ",0,5)){
5645 LoadTextureSave(":Data:Textures:David.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5648 if(Compare(consoletext[0],"wolf ",0,4)){
5649 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5652 if(Compare(consoletext[0],"darkwolf ",0,8)){
5653 LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5656 if(Compare(consoletext[0],"snowwolf ",0,8)){
5657 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5660 if(Compare(consoletext[0],"lizardwolf ",0,10)){
5661 LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5664 if(Compare(consoletext[0],"white ",0,5)){
5665 LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5668 if(Compare(consoletext[0],"brown ",0,5)){
5669 LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5672 if(Compare(consoletext[0],"black ",0,5)){
5673 LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
5676 if(consolechars[0]>0){
5679 consoletext[k][j]=consoletext[k-1][j];
5681 consolechars[k]=consolechars[k-1];
5684 consoletext[0][j]=' ';
5690 PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
5691 OPENAL_SetVolume(channels[consolefailsound], 256);
5692 OPENAL_SetPaused(channels[consolefailsound], false);
5701 togglekeydelay[i]=0;
5705 consoleblinkdelay-=multiplier;
5706 if(consoleblinkdelay<=0){
5707 consoleblinkdelay=.3;
5708 consoleblink=1-consoleblink;
5712 if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
5715 if(newdetail>2)newdetail=detail;
5716 if(newdetail<0)newdetail=detail;
5717 #if !USE_SDL // we'll take anything that works.
5718 if(newscreenwidth>3000)newscreenwidth=screenwidth;
5719 if(newscreenheight>3000)newscreenheight=screenheight;
5721 if(newscreenwidth<0)newscreenwidth=screenwidth;
5722 if(newscreenheight<0)newscreenheight=screenheight;
5724 ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
5725 opstream << "Screenwidth:\n";
5726 opstream << newscreenwidth;
5727 opstream << "\nScreenheight:\n";
5728 opstream << newscreenheight;
5729 opstream << "\nMouse sensitivity:\n";
5730 opstream << usermousesensitivity;
5731 opstream << "\nBlur(0,1):\n";
5732 opstream << ismotionblur;
5733 opstream << "\nOverall Detail(0,1,2) higher=better:\n";
5734 opstream << newdetail;
5735 opstream << "\nFloating jump:\n";
5736 opstream << floatjump;
5737 opstream << "\nMouse jump:\n";
5738 opstream << mousejump;
5739 opstream << "\nAmbient sound:\n";
5740 opstream << ambientsound;
5741 opstream << "\nBlood (0,1,2):\n";
5742 opstream << bloodtoggle;
5743 opstream << "\nAuto slomo:\n";
5744 opstream << autoslomo;
5745 opstream << "\nFoliage:\n";
5746 opstream << foliage;
5747 opstream << "\nMusic:\n";
5748 opstream << musictoggle;
5749 opstream << "\nTrilinear:\n";
5750 opstream << trilinear;
5751 opstream << "\nDecals(shadows,blood puddles,etc):\n";
5753 opstream << "\nInvert mouse:\n";
5754 opstream << invertmouse;
5755 opstream << "\nGamespeed:\n";
5756 if(oldgamespeed==0)oldgamespeed=1;
5757 opstream << oldgamespeed;
5758 opstream << "\nDifficulty(0,1,2) higher=harder:\n";
5759 opstream << difficulty;
5760 opstream << "\nDamage effects(blackout, doublevision):\n";
5761 opstream << damageeffects;
5762 opstream << "\nText:\n";
5763 opstream << texttoggle;
5764 opstream << "\nDebug:\n";
5765 opstream << debugmode;
5766 opstream << "\nVBL Sync:\n";
5767 opstream << vblsync;
5768 opstream << "\nShow Points:\n";
5769 opstream << showpoints;
5770 opstream << "\nAlways Blur:\n";
5771 opstream << alwaysblur;
5772 opstream << "\nImmediate mode (turn on on G5):\n";
5773 opstream << immediate;
5774 opstream << "\nVelocity blur:\n";
5775 opstream << velocityblur;
5776 opstream << "\nVolume:\n";
5778 opstream << "\nForward key:\n";
5779 opstream << KeyToChar(forwardkey);
5780 opstream << "\nBack key:\n";
5781 opstream << KeyToChar(backkey);
5782 opstream << "\nLeft key:\n";
5783 opstream << KeyToChar(leftkey);
5784 opstream << "\nRight key:\n";
5785 opstream << KeyToChar(rightkey);
5786 opstream << "\nJump key:\n";
5787 opstream << KeyToChar(jumpkey);
5788 opstream << "\nCrouch key:\n";
5789 opstream << KeyToChar(crouchkey);
5790 opstream << "\nDraw key:\n";
5791 opstream << KeyToChar(drawkey);
5792 opstream << "\nThrow key:\n";
5793 opstream << KeyToChar(throwkey);
5794 opstream << "\nAttack key:\n";
5795 opstream << KeyToChar(attackkey);
5796 opstream << "\nChat key:\n";
5797 opstream << KeyToChar(chatkey);
5802 static int oldwinfreeze;
5803 if(winfreeze&&!oldwinfreeze){
5804 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
5805 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
5806 OPENAL_SetVolume(channels[consolesuccesssound], 256);
5807 OPENAL_SetPaused(channels[consolesuccesssound], false);
5809 if(winfreeze==0)oldwinfreeze=winfreeze;
5810 else oldwinfreeze++;
5812 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
5813 if(winfreeze)winfreeze=0;
5816 if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
5822 if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
5825 if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
5827 if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
5829 static bool oldbuttondialogue;
5831 if(indialogue!=-1)talkdelay=1;
5832 talkdelay-=multiplier;
5835 if(indialogue==-1&&(animation[player[0].targetanimation].height!=highheight)/*&&!hostile*/)
5836 for(i=0;i<numdialogues;i++){
5837 int realdialoguetype;
5839 if(dialoguetype[i]>49){
5840 realdialoguetype=dialoguetype[i]-50;
5843 else if(dialoguetype[i]>39){
5844 realdialoguetype=dialoguetype[i]-40;
5847 else if(dialoguetype[i]>29){
5848 realdialoguetype=dialoguetype[i]-30;
5851 else if(dialoguetype[i]>19){
5852 realdialoguetype=dialoguetype[i]-20;
5855 else if(dialoguetype[i]>9){
5856 realdialoguetype=dialoguetype[i]-10;
5860 realdialoguetype=dialoguetype[i];
5863 if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
5864 if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
5866 for(j=0;j<numdialogueboxes[whichdialogue];j++){
5867 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
5868 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5869 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
5870 player[participantfocus[whichdialogue][j]].velocity=0;
5871 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
5872 player[participantfocus[whichdialogue][j]].targetframe=0;
5877 dialoguegonethrough[i]++;
5878 if(dialogueboxsound[whichdialogue][indialogue]!=0){
5879 static float gLoc[3];
5880 static float vel[3];
5882 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
5883 temppos=temppos-viewer;
5884 Normalise(&temppos);
5889 gLoc[2]=temppos.z;vel[0]=0;
5893 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
5894 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
5895 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
5896 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
5897 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
5898 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
5899 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
5900 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
5901 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
5902 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
5903 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
5904 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
5905 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
5906 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
5907 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
5908 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
5909 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
5910 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
5911 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
5912 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
5913 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
5914 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
5915 OPENAL_SetVolume(channels[whichsoundplay], 256);
5916 OPENAL_SetPaused(channels[whichsoundplay], false);
5918 if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
5923 windvar+=multiplier;
5924 smoketex+=multiplier;
5925 tutorialstagetime+=multiplier;
5927 static float hotspotvisual[40];
5931 for(i=0;i<numhotspots;i++)
5932 hotspotvisual[i]-=multiplier/320;
5934 for(i=0;i<numhotspots;i++){
5935 //if(hotspottype[i]<=10)
5936 while(hotspotvisual[i]<0){
5938 hotspotsprite.x=float(abs(Random()%100000))/100000*hotspotsize[i];
5939 hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
5940 hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
5941 hotspotsprite+=hotspot[i];
5942 sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
5943 hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
5947 for(i=0;i<numhotspots;i++){
5948 if(hotspottype[i]<=10&&hotspottype[i]>0){
5949 hotspot[i]=player[hotspottype[i]].coords;
5955 if(tutoriallevel&&tutorialstagetime>tutorialmaxtime){
5958 if(tutorialstage<=1){
5963 if(tutorialstage==1){
5966 if(tutorialstage==2){
5969 if(tutorialstage==3){
5970 tutorialmaxtime=600;
5972 if(tutorialstage==4){
5973 tutorialmaxtime=1000;
5975 if(tutorialstage==5){
5976 tutorialmaxtime=600;
5978 if(tutorialstage==6){
5979 tutorialmaxtime=600;
5981 if(tutorialstage==7){
5982 tutorialmaxtime=600;
5984 if(tutorialstage==8){
5985 tutorialmaxtime=600;
5987 if(tutorialstage==9){
5988 tutorialmaxtime=600;
5990 if(tutorialstage==10){
5993 if(tutorialstage==11){
5994 tutorialmaxtime=1000;
5996 if(tutorialstage==12){
5997 tutorialmaxtime=1000;
5999 if(tutorialstage==13){
6002 if(tutorialstage==14){
6014 player[1].coords=(temp+temp2)/2;
6018 gLoc[0]=player[1].coords.x;
6019 gLoc[1]=player[1].coords.y;
6020 gLoc[2]=player[1].coords.z;
6024 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6025 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6026 OPENAL_SetVolume(channels[fireendsound], 256);
6027 OPENAL_SetPaused(channels[fireendsound], false);
6029 for(i=0;i<player[1].skeleton.num_joints;i++){
6031 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6032 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6033 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;
6034 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6035 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6040 if(tutorialstage==15){
6041 tutorialmaxtime=500;
6043 if(tutorialstage==16){
6044 tutorialmaxtime=500;
6046 if(tutorialstage==17){
6047 tutorialmaxtime=500;
6049 if(tutorialstage==18){
6050 tutorialmaxtime=500;
6052 if(tutorialstage==19){
6054 //tutorialmaxtime=500;
6056 if(tutorialstage==20){
6057 tutorialmaxtime=500;
6059 if(tutorialstage==21){
6060 tutorialmaxtime=500;
6067 if(tutorialstage==22){
6068 tutorialmaxtime=500;
6070 if(tutorialstage==23){
6071 tutorialmaxtime=500;
6073 if(tutorialstage==24){
6074 tutorialmaxtime=500;
6076 if(tutorialstage==25){
6077 tutorialmaxtime=500;
6079 if(tutorialstage==26){
6082 if(tutorialstage==27){
6086 player[1].aitype=attacktypecutoff;
6088 if(tutorialstage==28){
6089 tutorialmaxtime=400;
6091 if(tutorialstage==29){
6092 tutorialmaxtime=400;
6093 player[0].escapednum=0;
6095 if(tutorialstage==30){
6099 player[1].aitype=passivetype;
6101 if(tutorialstage==31){
6104 if(tutorialstage==32){
6107 if(tutorialstage==33){
6108 tutorialmaxtime=400;
6111 player[1].aitype=attacktypecutoff;
6113 if(tutorialstage==34){
6114 tutorialmaxtime=400;
6116 if(tutorialstage==35){
6117 tutorialmaxtime=400;
6119 if(tutorialstage==36){
6123 player[1].aitype=passivetype;
6125 if(tutorialstage==37){
6131 player[1].aitype=attacktypecutoff;
6133 if(tutorialstage==38){
6137 player[1].aitype=passivetype;
6139 if(tutorialstage==39){
6150 weapons.owner[weapons.numweapons]=-1;
6151 weapons.type[weapons.numweapons]=knife;
6152 weapons.damage[weapons.numweapons]=0;
6153 weapons.mass[weapons.numweapons]=1;
6154 weapons.tipmass[weapons.numweapons]=1.2;
6155 weapons.length[weapons.numweapons]=.25;
6156 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6157 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6159 weapons.velocity[weapons.numweapons]=0.1;
6160 weapons.tipvelocity[weapons.numweapons]=0.1;
6161 weapons.missed[weapons.numweapons]=1;
6162 weapons.hitsomething[weapons.numweapons]=0;
6163 weapons.freetime[weapons.numweapons]=0;
6164 weapons.firstfree[weapons.numweapons]=1;
6165 weapons.physics[weapons.numweapons]=1;
6167 weapons.numweapons++;
6169 if(tutorialstage==40){
6170 tutorialmaxtime=300;
6172 if(tutorialstage==41){
6173 tutorialmaxtime=300;
6175 if(tutorialstage==42){
6178 if(tutorialstage==43){
6179 tutorialmaxtime=300;
6181 if(tutorialstage==44){
6183 player[0].weaponactive=-1;
6184 player[0].num_weapons=0;
6185 player[1].weaponactive=0;
6186 player[1].num_weapons=1;
6187 player[1].weaponids[0]=0;
6191 player[1].aitype=attacktypecutoff;
6193 tutorialmaxtime=300;
6195 if(tutorialstage==45){
6197 player[0].weaponactive=-1;
6198 player[0].num_weapons=0;
6199 player[1].weaponactive=0;
6200 player[1].num_weapons=1;
6201 player[1].weaponids[0]=0;
6203 tutorialmaxtime=300;
6205 if(tutorialstage==46){
6207 player[0].weaponactive=-1;
6208 player[0].num_weapons=0;
6209 player[1].weaponactive=0;
6210 player[1].num_weapons=1;
6211 player[1].weaponids[0]=0;
6213 weapons.type[0]=sword;
6215 tutorialmaxtime=300;
6218 if(tutorialstage==47){
6230 weapons.owner[weapons.numweapons]=-1;
6231 weapons.type[weapons.numweapons]=sword;
6232 weapons.damage[weapons.numweapons]=0;
6233 weapons.mass[weapons.numweapons]=1;
6234 weapons.tipmass[weapons.numweapons]=1.2;
6235 weapons.length[weapons.numweapons]=.25;
6236 weapons.position[weapons.numweapons]=(temp+temp2)/2;
6237 weapons.tippoint[weapons.numweapons]=(temp+temp2)/2;
6239 weapons.velocity[weapons.numweapons]=0.1;
6240 weapons.tipvelocity[weapons.numweapons]=0.1;
6241 weapons.missed[weapons.numweapons]=1;
6242 weapons.hitsomething[weapons.numweapons]=0;
6243 weapons.freetime[weapons.numweapons]=0;
6244 weapons.firstfree[weapons.numweapons]=1;
6245 weapons.physics[weapons.numweapons]=1;
6249 player[0].weaponactive=0;
6250 player[0].num_weapons=1;
6251 player[0].weaponids[0]=1;
6252 player[1].weaponactive=0;
6253 player[1].num_weapons=1;
6254 player[1].weaponids[0]=0;
6256 weapons.numweapons++;
6258 if(tutorialstage==48){
6261 player[1].aitype=passivetype;
6267 player[0].weaponactive=0;
6268 player[0].num_weapons=1;
6269 player[0].weaponids[0]=1;
6270 player[1].weaponactive=0;
6271 player[1].num_weapons=1;
6272 player[1].weaponids[0]=0;
6274 if(player[0].weaponactive!=-1)weapons.type[player[0].weaponids[player[0].weaponactive]]=staff;
6275 else weapons.type[0]=staff;
6277 weapons.numweapons++;
6279 if(tutorialstage==49){
6282 player[1].aitype=passivetype;
6284 tutorialmaxtime=200;
6286 weapons.position[1]=1000;
6287 weapons.tippoint[1]=1000;
6289 weapons.numweapons=1;
6291 player[1].weaponactive=-1;
6292 player[1].num_weapons=0;
6293 player[0].weaponactive=0;
6294 player[0].num_weapons=1;
6295 player[0].weaponids[0]=0;
6297 weapons.type[0]=knife;
6299 weapons.numweapons++;
6301 if(tutorialstage==50){
6307 gLoc[0]=player[1].coords.x;
6308 gLoc[1]=player[1].coords.y;
6309 gLoc[2]=player[1].coords.z;
6313 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6314 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
6315 OPENAL_SetVolume(channels[fireendsound], 256);
6316 OPENAL_SetPaused(channels[fireendsound], false);
6318 for(i=0;i<player[1].skeleton.num_joints;i++){
6320 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
6321 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
6322 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;
6323 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
6324 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
6328 player[1].num_weapons=0;
6329 player[1].weaponstuck=-1;
6330 player[1].weaponactive=-1;
6332 weapons.numweapons=0;
6334 weapons.owner[0]=-1;
6335 weapons.velocity[0]=0.1;
6336 weapons.tipvelocity[0]=-0.1;
6337 weapons.missed[0]=1;
6338 weapons.hitsomething[0]=0;
6339 weapons.freetime[0]=0;
6340 weapons.firstfree[0]=1;
6341 weapons.physics[0]=1;
6343 if(tutorialstage==51){
6344 tutorialmaxtime=80000;
6346 if(tutorialstage<=51)tutorialstagetime=0;
6350 if(tutoriallevel&&tutorialstagetime<tutorialmaxtime-3){
6351 if(tutorialstage==3){
6352 if(deltah||deltav)tutorialsuccess+=multiplier;
6354 if(tutorialstage==4){
6355 if(player[0].forwardkeydown||player[0].backkeydown||player[0].leftkeydown||player[0].rightkeydown)tutorialsuccess+=multiplier;
6357 if(tutorialstage==5){
6358 if(player[0].jumpkeydown)tutorialsuccess=1;
6360 if(tutorialstage==6){
6361 if(player[0].isCrouch())tutorialsuccess=1;
6363 if(tutorialstage==7){
6364 if(player[0].targetanimation==rollanim)tutorialsuccess=1;
6366 if(tutorialstage==8){
6367 if(player[0].targetanimation==sneakanim)tutorialsuccess+=multiplier;
6369 if(tutorialstage==9){
6370 if(player[0].targetanimation==rabbitrunninganim||player[0].targetanimation==wolfrunninganim)tutorialsuccess+=multiplier;
6372 if(tutorialstage==11){
6373 if(player[0].isWallJump())tutorialsuccess=1;
6375 if(tutorialstage==12){
6376 if(player[0].targetanimation==flipanim)tutorialsuccess=1;
6378 if(tutorialstage==15){
6379 if(player[0].targetanimation==upunchanim||player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6381 if(tutorialstage==16){
6382 if(player[0].targetanimation==winduppunchanim)tutorialsuccess=1;
6384 if(tutorialstage==17){
6385 if(player[0].targetanimation==spinkickanim)tutorialsuccess=1;
6387 if(tutorialstage==18){
6388 if(player[0].targetanimation==sweepanim)tutorialsuccess=1;
6390 if(tutorialstage==19){
6391 if(player[0].targetanimation==dropkickanim)tutorialsuccess=1;
6393 if(tutorialstage==20){
6394 if(player[0].targetanimation==rabbitkickanim)tutorialsuccess=1;
6396 if(tutorialstage==21){
6397 if(bonus==cannon)tutorialsuccess=1;
6399 if(tutorialstage==22){
6400 if(bonus==spinecrusher)tutorialsuccess=1;
6402 if(tutorialstage==23){
6403 if(player[0].targetanimation==walljumprightkickanim||player[0].targetanimation==walljumpleftkickanim)tutorialsuccess=1;
6405 if(tutorialstage==24){
6406 if(player[0].targetanimation==rabbittacklinganim)tutorialsuccess=1;
6408 if(tutorialstage==25){
6409 if(player[0].targetanimation==backhandspringanim)tutorialsuccess=1;
6411 if(tutorialstage==28){
6412 if(animation[player[0].targetanimation].attack==reversed&&player[0].feint)tutorialsuccess=1;
6414 if(tutorialstage==29){
6415 if(player[0].escapednum==2){
6419 player[1].aitype=passivetype;
6422 if(tutorialstage==33){
6423 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6425 if(tutorialstage==34){
6426 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6428 if(tutorialstage==35){
6429 if(animation[player[0].targetanimation].attack==reversal){
6433 player[1].aitype=passivetype;
6436 if(tutorialstage==40){
6437 if(player[0].num_weapons>0)tutorialsuccess=1;
6439 if(tutorialstage==41){
6440 if(player[0].weaponactive==-1&&player[0].num_weapons>0)tutorialsuccess=1;
6442 if(tutorialstage==43){
6443 if(player[0].targetanimation==knifeslashstartanim)tutorialsuccess=1;
6445 if(tutorialstage==44){
6446 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6448 if(tutorialstage==45){
6449 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6451 if(tutorialstage==46){
6452 if(animation[player[0].targetanimation].attack==reversal)tutorialsuccess=1;
6454 if(tutorialstage==49){
6455 if(player[1].weaponstuck!=-1)tutorialsuccess=1;
6457 if(tutorialsuccess>=1)tutorialstagetime=tutorialmaxtime-3;
6460 if(tutorialstagetime==tutorialmaxtime-3){
6461 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6462 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6463 OPENAL_SetPaused(channels[consolesuccesssound], false);
6466 if(tutorialsuccess>=1){
6467 if(tutorialstage==34||tutorialstage==35)
6468 tutorialstagetime=tutorialmaxtime-1;
6473 if(tutorialstage<14||tutorialstage>=50){
6474 player[1].coords.y=300;
6475 player[1].velocity=0;
6479 if(tutoriallevel!=1){
6480 if(bonustime==0&&bonus!=solidhit&&bonus!=spinecrusher&&bonus!=tracheotomy&&bonus!=backstab&&bonusvalue>10){
6481 PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
6482 OPENAL_SetVolume(channels[consolesuccesssound], 256);
6483 OPENAL_SetPaused(channels[consolesuccesssound], false);
6488 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
6489 OPENAL_SetVolume(channels[fireendsound], 256);
6490 OPENAL_SetPaused(channels[fireendsound], false);
6493 if(bonus!=solidhit&&bonus!=twoxcombo&&bonus!=threexcombo&&bonus!=fourxcombo&&bonus!=megacombo)bonusnum[bonus]++;
6494 else bonusnum[bonus]+=0.15;
6495 if(tutoriallevel)bonusvalue=0;
6496 bonusvalue/=bonusnum[bonus];
6497 bonustotal+=bonusvalue;
6499 bonustime+=multiplier;
6501 if(environment==snowyenvironment){
6502 precipdelay-=multiplier;
6503 while(precipdelay<0){
6505 if(!detail)precipdelay+=.04;
6506 XYZ footvel,footpoint;
6509 footpoint=viewer+viewerfacing*6;
6510 footpoint.y+=((float)abs(Random()%1200))/100-6;
6511 footpoint.x+=((float)abs(Random()%1200))/100-6;
6512 footpoint.z+=((float)abs(Random()%1200))/100-6;
6513 sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
6516 for(k=0;k<numplayers;k++){
6517 if(player[k].aitype==playercontrolled)player[k].turnspeed=500;
6518 if(player[k].aitype!=playercontrolled)player[k].turnspeed=500;
6520 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){
6521 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6522 else if(player[k].rotation>player[k].targetrotation){
6523 player[k].rotation-=multiplier*player[k].turnspeed;
6525 else if(player[k].rotation<player[k].targetrotation){
6526 player[k].rotation+=multiplier*player[k].turnspeed;
6531 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))){
6532 player[k].turnspeed*=2;
6533 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6534 else if(player[k].rotation>player[k].targetrotation){
6535 player[k].rotation-=multiplier*player[k].turnspeed;
6537 else if(player[k].rotation<player[k].targetrotation){
6538 player[k].rotation+=multiplier*player[k].turnspeed;
6540 player[k].turnspeed/=2;
6543 if(player[k].targetanimation==sneakanim&&player[k].currentanimation!=sneakanim){
6544 player[k].turnspeed*=4;
6545 if(abs(player[k].rotation-player[k].targetrotation)<multiplier*player[k].turnspeed)player[k].rotation=player[k].targetrotation;
6546 else if(player[k].rotation>player[k].targetrotation){
6547 player[k].rotation-=multiplier*player[k].turnspeed;
6549 else if(player[k].rotation<player[k].targetrotation){
6550 player[k].rotation+=multiplier*player[k].turnspeed;
6552 player[k].turnspeed/=4;
6555 /*if(player[k].aitype!=passivetype||(findDistancefast(&player[k].coords,&viewer)<viewdistance*viewdistance))*/ player[k].DoStuff();
6556 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
6558 if(findDistancefast(&player[k].coords,&player[k].realoldcoords)>0){
6559 if(!player[k].skeleton.free&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim){
6562 if(player[k].collide<-.3)player[k].collide=-.3;
6563 if(player[k].collide>1)player[k].collide=1;
6564 player[k].collide-=multiplier*30;
6566 if(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z)){
6567 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6569 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
6570 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6571 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6572 if(objects.type[i]!=rocktype||(((objects.scale[i]>.5&&player[k].aitype==playercontrolled)||objects.position[i].y>player[k].coords.y))){
6573 lowpoint=player[k].coords;
6574 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip())lowpoint.y+=1.25;
6575 else lowpoint.y+=1.3;
6576 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){
6577 player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z);
6579 /*while(player[k].coords.y<terrain.getHeight(player[k].coords.x,player[k].coords.z))
6580 player[k].coords+=terrain.getNormal(player[k].coords.x,player[k].coords.z)/50;
6582 if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6583 flatfacing=lowpoint-player[k].coords;
6584 player[k].coords=lowpoint;
6585 player[k].coords.y-=1.3;
6586 player[k].collide=1;
6588 if(player[k].aitype==playercontrolled&&(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].jumptogglekeydown&&player[k].jumpkeydown){
6589 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5;
6590 tempcoords1=lowpoint;
6591 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6592 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6594 player[k].targetanimation=walljumpleftanim;
6595 player[k].targetframe=0;
6598 gLoc[0]=player[k].coords.x;
6599 gLoc[1]=player[k].coords.y;
6600 gLoc[2]=player[k].coords.z;
6604 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6605 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6606 OPENAL_SetVolume(channels[movewhooshsound], 256);
6607 OPENAL_SetPaused(channels[movewhooshsound], false);
6608 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6610 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6611 player[k].rotation=-asin(0-lowpointtarget.x);
6612 player[k].rotation*=360/6.28;
6613 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6614 player[k].targetrotation=player[k].rotation;
6615 player[k].lowrotation=player[k].rotation;
6616 if(k==0)numwallflipped++;
6620 lowpoint=tempcoords1;
6621 lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5;
6622 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6623 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6625 player[k].targetanimation=walljumprightanim;
6626 player[k].targetframe=0;
6629 gLoc[0]=player[k].coords.x;
6630 gLoc[1]=player[k].coords.y;
6631 gLoc[2]=player[k].coords.z;
6635 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6636 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6637 OPENAL_SetVolume(channels[movewhooshsound], 256);
6638 OPENAL_SetPaused(channels[movewhooshsound], false);
6639 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6641 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6642 player[k].rotation=-asin(0-lowpointtarget.x);
6643 player[k].rotation*=360/6.28;
6644 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6645 player[k].targetrotation=player[k].rotation;
6646 player[k].lowrotation=player[k].rotation;
6647 if(k==0)numwallflipped++;
6651 lowpoint=tempcoords1;
6652 lowpointtarget=lowpoint+player[k].facing*2;
6653 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6654 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6656 player[k].targetanimation=walljumpbackanim;
6657 player[k].targetframe=0;
6660 gLoc[0]=player[k].coords.x;
6661 gLoc[1]=player[k].coords.y;
6662 gLoc[2]=player[k].coords.z;
6666 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6667 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6668 OPENAL_SetVolume(channels[movewhooshsound], 256);
6669 OPENAL_SetPaused(channels[movewhooshsound], false);
6670 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6672 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6673 player[k].rotation=-asin(0-lowpointtarget.x);
6674 player[k].rotation*=360/6.28;
6675 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6676 player[k].targetrotation=player[k].rotation;
6677 player[k].lowrotation=player[k].rotation;
6678 if(k==0)numwallflipped++;
6682 lowpoint=tempcoords1;
6683 lowpointtarget=lowpoint-player[k].facing*2;
6684 whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6685 if(whichhit!=-1&&abs(objects.model[i].facenormals[whichhit].y)<.3){
6687 player[k].targetanimation=walljumpfrontanim;
6688 player[k].targetframe=0;
6691 gLoc[0]=player[k].coords.x;
6692 gLoc[1]=player[k].coords.y;
6693 gLoc[2]=player[k].coords.z;
6697 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6698 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6699 OPENAL_SetVolume(channels[movewhooshsound], 256);
6700 OPENAL_SetPaused(channels[movewhooshsound], false);
6701 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6703 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6704 player[k].rotation=-asin(0-lowpointtarget.x);
6705 player[k].rotation*=360/6.28;
6706 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6707 player[k].rotation+=180;
6708 player[k].targetrotation=player[k].rotation;
6709 player[k].lowrotation=player[k].rotation;
6710 if(k==0)numwallflipped++;
6718 else if(objects.type[i]==rocktype){
6719 lowpoint2=player[k].coords;
6720 lowpoint=player[k].coords;
6722 if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){
6723 player[k].coords=colpoint;
6724 player[k].collide=1;
6727 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())){
6728 if(player[k].isFlip()&&animation[player[k].targetanimation].label[player[k].targetframe]==7)player[k].RagDoll(0);
6730 if(player[k].targetanimation==jumpupanim){player[k].jumppower=-4;player[k].targetanimation=player[k].getIdle();}
6732 player[k].targetframe=0;
6733 player[k].onterrain=1;
6735 if(player[k].id==0){
6736 OPENAL_SetPaused(channels[whooshsound], true);
6737 OPENAL_SetVolume(channels[whooshsound], 0);
6740 if((player[k].targetanimation==jumpdownanim||player[k].isFlip())&&!player[k].wasLanding()){
6741 if(player[k].isFlip())player[k].jumppower=-4;
6742 player[k].targetanimation=player[k].getLanding();
6745 gLoc[0]=player[k].coords.x;
6746 gLoc[1]=player[k].coords.y;
6747 gLoc[2]=player[k].coords.z;
6748 vel[0]=player[k].velocity.x;
6749 vel[1]=player[k].velocity.y;
6750 vel[2]=player[k].velocity.z;
6751 PlaySoundEx( landsound, samp[landsound], NULL, true);
6752 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6753 OPENAL_SetVolume(channels[landsound], 128);
6754 OPENAL_SetPaused(channels[landsound], false);
6756 envsound[numenvsounds]=player[k].coords;
6757 envsoundvol[numenvsounds]=16;
6758 envsoundlife[numenvsounds]=.4;
6767 if(tempcollide&&terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]&&(/*player[k].jumptogglekeydown*/1==1||player[k].aitype!=playercontrolled))
6768 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
6769 i=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
6770 lowpoint=player[k].coords;
6772 if(objects.type[i]!=rocktype)
6773 if(player[k].SphereCheck(&lowpoint, 1.33, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
6774 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim&&player[k].onterrain)player[k].avoidcollided=1;
6775 player[k].coords=lowpoint;
6776 player[k].coords.y-=1.35;
6777 player[k].collide=1;
6779 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)){
6780 lowpoint=player[k].coords;
6781 objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]);
6782 lowpoint=player[k].coords;
6786 facing=DoRotation(facing,0,player[k].targetrotation+180,0);
6787 lowpointtarget=lowpoint+facing*1.4;
6788 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6790 lowpoint=player[k].coords;
6792 lowpointtarget=lowpoint+facing*1.4;
6794 lowpointtarget2=lowpointtarget;
6796 lowpointtarget3=lowpointtarget;
6798 lowpointtarget4=lowpointtarget;
6800 lowpointtarget5=lowpointtarget;
6802 lowpointtarget6=lowpointtarget;
6804 lowpointtarget7=lowpoint;
6806 lowpointtarget2.x+=.1;
6808 lowpointtarget3.z+=.1;
6810 lowpointtarget4.x-=.1;
6812 lowpointtarget5.z-=.1;
6814 lowpointtarget6.y+=45/13;
6815 lowpointtarget6+=facing*.6;
6816 lowpointtarget7.y+=90/13;
6817 whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]);
6818 if(objects.friction[i]>.5)
6821 if(whichhit!=-1)if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim)player[k].collided=1;
6822 if(checkcollide(lowpoint7,lowpointtarget7)==-1)
6823 if(checkcollide(lowpoint6,lowpointtarget6)==-1)
6824 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)
6826 lowpoint=player[k].coords;
6827 lowpoint.y+=(float)j/13;
6828 lowpointtarget=lowpoint+facing*1.4;
6829 if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint2,&objects.position[i],&objects.rotation[i])==-1){
6833 /*if(j>=25&&(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)){
6836 if(j<=25&&player[k].targetanimation==jumpdownanim){
6839 if(j!=100&&(/*j>25||(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim)){
6840 lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0);
6841 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)*/){
6842 lowpoint=player[k].coords;
6843 lowpoint.y+=(float)j/13;
6844 lowpointtarget=lowpoint+facing*1.3;
6845 flatfacing=player[k].coords;
6846 player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01;
6847 player[k].coords.y=lowpointtarget.y-.07;
6848 player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale;
6850 if(j>10||!player[k].isRun()){
6851 if(player[k].targetanimation==jumpdownanim||player[k].targetanimation==jumpupanim){
6852 if(k==0)OPENAL_SetPaused(channels[whooshsound], true);
6856 gLoc[0]=player[k].coords.x;
6857 gLoc[1]=player[k].coords.y;
6858 gLoc[2]=player[k].coords.z;
6859 vel[0]=player[k].velocity.x;
6860 vel[1]=player[k].velocity.y;
6861 vel[2]=player[k].velocity.z;
6862 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
6863 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
6864 OPENAL_SetVolume(channels[jumpsound], 128);
6865 OPENAL_SetPaused(channels[jumpsound], false);
6867 lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0);
6868 player[k].rotation=-asin(0-lowpointtarget.x);
6869 player[k].rotation*=360/6.28;
6870 if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation;
6871 player[k].targetrotation=player[k].rotation;
6872 player[k].lowrotation=player[k].rotation;
6874 //player[k].velocity=lowpointtarget*.03;
6875 player[k].velocity=0;
6877 if(/*(player[k].isRun()||player[k].targetanimation==sneakanim||player[k].targetanimation==walkanim)||*/player[k].targetanimation==jumpupanim){
6878 //player[k].currentanimation=climbanim;
6879 player[k].targetanimation=climbanim;
6880 player[k].jumppower=0;
6881 player[k].jumpclimb=1;
6883 player[k].transspeed=6;
6886 //player[k].currentframe=1;
6887 player[k].targetframe=1;
6889 //player[k].currentframe=0;
6890 player[k].targetframe=0;
6891 //player[k].currentanimation=hanganim;
6892 player[k].targetanimation=hanganim;
6893 player[k].jumppower=0;
6907 if(player[k].collide<=0){
6908 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()){
6909 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)){
6910 if(player[k].targetanimation==staggerbackhighanim||player[k].targetanimation==staggerbackhardanim)player[k].RagDoll(0);
6911 player[k].targetanimation=jumpdownanim;
6912 player[k].targetframe=0;
6917 gLoc[0]=player[k].coords.x;
6918 gLoc[1]=player[k].coords.y;
6919 gLoc[2]=player[k].coords.z;
6920 vel[0]=player[k].velocity.x;
6921 vel[1]=player[k].velocity.y;
6922 vel[2]=player[k].velocity.z;
6924 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
6925 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
6926 OPENAL_SetVolume(channels[whooshsound], 128);
6927 OPENAL_SetPaused(channels[whooshsound], false);
6930 player[k].velocity.y+=gravity;
6935 player[k].realoldcoords=player[k].coords;
6938 static XYZ oldviewer;
6941 player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
6942 player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
6943 player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
6944 player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
6945 player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
6946 player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
6947 player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
6948 player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
6952 player[0].forwardkeydown=0;
6953 player[0].leftkeydown=0;
6954 player[0].backkeydown=0;
6955 player[0].rightkeydown=0;
6956 player[0].jumpkeydown=0;
6957 player[0].crouchkeydown=0;
6958 player[0].drawkeydown=0;
6959 player[0].throwkeydown=0;
6962 if(!player[0].jumpkeydown)player[0].jumpclimb=0;
6965 static bool endkeydown;
6972 facing=DoRotation(facing,-rotation2,0,0);
6973 facing=DoRotation(facing,0,0-rotation,0);
6978 flatfacing=DoRotation(flatfacing,0,-rotation,0);
6980 if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
6981 if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
6982 if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
6983 if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
6984 if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
6985 if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
6986 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)
6987 ||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)
6988 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
6990 if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
6991 if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
6992 if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
6993 if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
6994 if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
6995 if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
6996 if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
6997 if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
6998 if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
6999 if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
7000 if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
7002 participantfocus[whichdialogue][indialogue]=whichend;
7003 participantlocation[whichdialogue][whichend]=player[whichend].coords;
7004 participantrotation[whichdialogue][whichend]=player[whichend].rotation;
7007 participantfocus[whichdialogue][indialogue]=-1;
7009 if(player[participantfocus[whichdialogue][indialogue]].dead){
7014 dialoguecamera[whichdialogue][indialogue]=viewer;
7015 dialoguecamerarotation[whichdialogue][indialogue]=rotation;
7016 dialoguecamerarotation2[whichdialogue][indialogue]=rotation2;
7018 if(indialogue<numdialogueboxes[whichdialogue]){
7019 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7020 static float gLoc[3];
7021 static float vel[3];
7023 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7024 temppos=temppos-viewer;
7025 Normalise(&temppos);
7030 gLoc[2]=temppos.z;vel[0]=0;
7034 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7035 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7036 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7037 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7038 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7039 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7040 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7041 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7042 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7043 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7044 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7045 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7046 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7047 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7048 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7049 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7050 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7051 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7052 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7053 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7054 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
7055 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7056 OPENAL_SetVolume(channels[whichsoundplay], 256);
7057 OPENAL_SetPaused(channels[whichsoundplay], false);
7061 for(j=0;j<numplayers;j++){
7062 participantfacing[whichdialogue][indialogue][j]=participantfacing[whichdialogue][indialogue-1][j];
7067 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)
7068 ||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)
7071 if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
7072 if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
7073 if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
7074 if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
7075 if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
7076 if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
7077 if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
7078 if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
7079 if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
7080 if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
7081 participantfacing[whichdialogue][indialogue][whichend]=facing;
7083 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)
7084 &&!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)
7085 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7088 if(indialogue>=numdialogueboxes[whichdialogue]){
7095 OPENAL_SetPaused(channels[whooshsound], true);
7096 viewer=dialoguecamera[whichdialogue][indialogue];
7097 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.1){
7098 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.1;
7100 rotation=dialoguecamerarotation[whichdialogue][indialogue];
7101 rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
7102 if(dialoguetime>0.5)
7103 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)
7104 ||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)
7105 ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
7108 if(indialogue<numdialogueboxes[whichdialogue]){
7109 if(dialogueboxsound[whichdialogue][indialogue]!=0){
7110 static float gLoc[3];
7111 static float vel[3];
7113 temppos=player[participantfocus[whichdialogue][indialogue]].coords;
7114 temppos=temppos-viewer;
7115 Normalise(&temppos);
7120 gLoc[2]=temppos.z;vel[0]=0;
7124 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
7125 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
7126 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
7127 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
7128 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
7129 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
7130 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
7131 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
7132 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
7133 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
7134 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
7135 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
7136 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
7137 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
7138 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
7139 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
7140 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
7141 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
7142 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
7143 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
7144 if(dialogueboxsound[whichdialogue][indialogue]==-6)whichsoundplay=alarmsound;
7145 if(dialogueboxsound[whichdialogue][indialogue]!=-5){
7146 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
7147 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
7148 OPENAL_SetVolume(channels[whichsoundplay], 256);
7149 OPENAL_SetPaused(channels[whichsoundplay], false);
7151 if(dialogueboxsound[whichdialogue][indialogue]==-5){
7152 hotspot[numhotspots]=player[0].coords;
7153 hotspotsize[numhotspots]=10;
7154 hotspottype[numhotspots]=-1;
7158 if(dialogueboxsound[whichdialogue][indialogue]==-6){
7162 if(player[participantfocus[whichdialogue][indialogue]].dead){
7170 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)
7171 &&!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)
7172 &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
7175 if(indialogue>=numdialogueboxes[whichdialogue]){
7179 if(dialoguetype[whichdialogue]>19&&dialoguetype[whichdialogue]<30){
7182 if(dialoguetype[whichdialogue]>29&&dialoguetype[whichdialogue]<40){
7185 if(dialoguetype[whichdialogue]>49&&dialoguetype[whichdialogue]<60){
7187 for(i=1;i<numplayers;i++){
7188 player[i].aitype = attacktypecutoff;
7195 if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
7196 else oldbuttondialogue=1;
7198 static float keyrefreshdelay=0,bigrefreshdelay=0;
7202 /*keyrefreshdelay-=multiplier;
7203 bigrefreshdelay-=multiplier;
7205 if(keyrefreshdelay<=0){
7206 static int concat[4];
7208 concat[0]=player[0].forwardkeydown;
7209 concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
7210 concat[0]=concat[0]*2+player[0].rightkeydown;
7211 concat[0]=concat[0]*2+player[0].leftkeydown;
7212 concat[0]=concat[0]*2+player[0].backkeydown;
7213 concat[0]=concat[0]*2+player[0].jumpkeydown;
7214 concat[0]=concat[0]*2+player[0].jumptogglekeydown;
7215 concat[0]=concat[0]*2+player[0].crouchkeydown;
7217 concat[1]=player[0].crouchtogglekeydown;
7218 concat[1]=concat[1]*2+player[0].drawkeydown;
7219 concat[1]=concat[1]*2+player[0].drawtogglekeydown;
7220 concat[1]=concat[1]*2+player[0].throwkeydown;
7221 concat[1]=concat[1]*2+player[0].throwtogglekeydown;
7222 concat[1]=concat[1]*2+player[0].attackkeydown;
7224 //concat[2]=(char)((int)(rotation/2)%180);
7226 //concat[3]=(char)((int)(rotation2/2)%180);
7228 chatname[0]=concat[0]-128;
7229 chatname[1]=concat[1]-128;
7230 //chatname[2]=concat[2]-128;
7231 //chatname[3]=concat[3]-128;
7233 memcpy(chatname+temppoint,&rotation,sizeof(float));
7234 temppoint+=sizeof(float);
7235 memcpy(chatname+temppoint,&rotation2,sizeof(float));
7236 temppoint+=sizeof(float);
7238 chatname[temppoint]='\0';
7240 //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
7241 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
7242 //keyrefreshdelay=.01;
7243 keyrefreshdelay=.03;
7246 if(bigrefreshdelay<=0){
7249 memcpy(chatname+temppoint,&i,sizeof(int));
7250 temppoint+=sizeof(int);
7251 memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
7252 temppoint+=sizeof(float);
7253 memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
7254 temppoint+=sizeof(float);
7255 memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
7256 temppoint+=sizeof(float);
7257 memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
7258 temppoint+=sizeof(float);
7259 memcpy(chatname+temppoint,&player[i].target,sizeof(float));
7260 temppoint+=sizeof(float);
7261 memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
7262 temppoint+=sizeof(int);
7263 memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
7264 temppoint+=sizeof(int);
7265 memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
7266 temppoint+=sizeof(float);
7267 memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
7268 temppoint+=sizeof(float);
7269 memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
7270 temppoint+=sizeof(float);
7271 memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
7272 temppoint+=sizeof(int);
7273 memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
7274 temppoint+=sizeof(int);
7275 memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
7276 temppoint+=sizeof(float);
7277 memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
7278 temppoint+=sizeof(float);
7279 memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
7280 temppoint+=sizeof(float);
7281 memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
7282 temppoint+=sizeof(int);
7283 memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
7284 temppoint+=sizeof(int);
7285 memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
7286 temppoint+=sizeof(int);
7287 memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
7288 temppoint+=sizeof(int);
7289 memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
7290 temppoint+=sizeof(int);
7291 memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
7292 temppoint+=sizeof(int);
7293 chatname[temppoint]='\0';
7295 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);
7296 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
7297 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
7299 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);
7301 //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
7302 //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
7304 //bigrefreshdelay=.02;
7309 if(!player[0].jumpkeydown){
7310 player[0].jumptogglekeydown=0;
7312 if(player[0].jumpkeydown&&player[0].targetanimation!=jumpupanim&&player[0].targetanimation!=jumpdownanim&&!player[0].isFlip())player[0].jumptogglekeydown=1;
7315 dialoguetime+=multiplier;
7316 skybox.cloudmove+=multiplier;
7317 hawkrotation+=multiplier*25;
7319 realhawkcoords.x=25;
7320 realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords;
7321 hawkcalldelay-=multiplier/2;
7323 if(hawkcalldelay<=0)
7325 static float gLoc[3];
7326 static float vel[3];
7327 gLoc[0]=realhawkcoords.x;
7328 gLoc[1]=realhawkcoords.y;
7329 gLoc[2]=realhawkcoords.z;
7333 PlaySoundEx( hawksound, samp[hawksound], NULL, true);
7334 OPENAL_3D_SetAttributes(channels[hawksound], gLoc, vel);
7335 OPENAL_SetVolume(channels[hawksound], 128);
7336 OPENAL_SetPaused(channels[hawksound], false);
7338 hawkcalldelay=16+abs(Random()%8);
7340 static float temptexdetail;
7343 if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
7344 player[0].damagetolerance=200000;
7347 player[0].permanentdamage=0;
7348 player[0].superpermanentdamage=0;
7351 whichchar = abs(Random()%7);
7352 registrationname[whichchar]+=1;
7356 if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
7358 if(environment>2)environment=0;
7359 Setenvironment(environment);
7365 if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
7369 if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
7370 cameramode=1-cameramode;
7371 cameratogglekeydown=1;
7374 if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
7375 cameratogglekeydown=0;
7378 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7379 if(player[0].num_weapons>0){
7380 if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
7381 else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
7382 else weapons.type[player[0].weaponids[0]]=sword;
7383 if(weapons.type[player[0].weaponids[0]]==sword){
7384 weapons.mass[player[0].weaponids[0]]=1.5;
7385 weapons.tipmass[player[0].weaponids[0]]=1;
7386 weapons.length[player[0].weaponids[0]]=.8;
7388 if(weapons.type[player[0].weaponids[0]]==staff){
7389 weapons.mass[player[0].weaponids[0]]=2;
7390 weapons.tipmass[player[0].weaponids[0]]=1;
7391 weapons.length[player[0].weaponids[0]]=1.5;
7394 if(weapons.type[player[0].weaponids[0]]==knife){
7395 weapons.mass[player[0].weaponids[0]]=1;
7396 weapons.tipmass[player[0].weaponids[0]]=1.2;
7397 weapons.length[player[0].weaponids[0]]=.25;
7401 /*for(i=0;i<objects.numobjects;i++){
7402 if(objects.type[i]==treeleavestype){
7403 for(j=0;j<objects.numobjects;j++){
7404 if(objects.type[j]==treetrunktype)
7405 if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
7406 objects.scale[i]=objects.scale[j];
7410 detailtogglekeydown=1;
7413 if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
7415 float closestdist=-1;
7418 for(i=1;i<numplayers;i++){
7419 distance=findDistancefast(&player[i].coords,&player[0].coords);
7420 if(closestdist==-1||distance<closestdist){
7421 closestdist=distance;
7426 if(player[closest].num_weapons)
7428 if(weapons.type[player[closest].weaponids[0]]==sword)weapons.type[player[closest].weaponids[0]]=staff;
7429 else if(weapons.type[player[closest].weaponids[0]]==staff)weapons.type[player[closest].weaponids[0]]=knife;
7430 else weapons.type[player[closest].weaponids[0]]=sword;
7431 if(weapons.type[player[closest].weaponids[0]]==sword){
7432 weapons.mass[player[closest].weaponids[0]]=1.5;
7433 weapons.tipmass[player[closest].weaponids[0]]=1;
7434 weapons.length[player[closest].weaponids[0]]=.8;
7436 if(weapons.type[player[0].weaponids[0]]==staff){
7437 weapons.mass[player[0].weaponids[0]]=2;
7438 weapons.tipmass[player[0].weaponids[0]]=1;
7439 weapons.length[player[0].weaponids[0]]=1.5;
7441 if(weapons.type[player[closest].weaponids[0]]==knife){
7442 weapons.mass[player[closest].weaponids[0]]=1;
7443 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7444 weapons.length[player[closest].weaponids[0]]=.25;
7447 if(!player[closest].num_weapons)
7449 player[closest].weaponids[0]=weapons.numweapons;
7450 weapons.owner[weapons.numweapons]=closest;
7451 weapons.type[weapons.numweapons]=knife;
7452 weapons.damage[weapons.numweapons]=0;
7453 weapons.numweapons++;
7454 player[closest].num_weapons=1;
7455 if(weapons.type[player[closest].weaponids[0]]==sword){
7456 weapons.mass[player[closest].weaponids[0]]=1.5;
7457 weapons.tipmass[player[closest].weaponids[0]]=1;
7458 weapons.length[player[closest].weaponids[0]]=.8;
7460 if(weapons.type[player[closest].weaponids[0]]==knife){
7461 weapons.mass[player[closest].weaponids[0]]=1;
7462 weapons.tipmass[player[closest].weaponids[0]]=1.2;
7463 weapons.length[player[closest].weaponids[0]]=.25;
7467 detailtogglekeydown=1;
7470 if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
7472 float closestdist=-1;
7475 for(i=1;i<numplayers;i++){
7476 distance=findDistancefast(&player[i].coords,&player[0].coords);
7477 if(closestdist==-1||distance<closestdist){
7478 closestdist=distance;
7483 player[closest].rotation+=multiplier*50;
7484 player[closest].targetrotation=player[closest].rotation;
7488 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7490 float closestdist=-1;
7493 for(i=1;i<numplayers;i++){
7494 distance=findDistancefast(&player[i].coords,&player[0].coords);
7495 if(closestdist==-1||distance<closestdist){
7496 closestdist=distance;
7500 if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
7503 player[closest].whichskin++;
7504 if(player[closest].whichskin>9)player[closest].whichskin=0;
7505 if(player[closest].whichskin>2&&player[closest].creature==wolftype)player[closest].whichskin=0;
7507 if(player[closest].creature==rabbittype){
7508 if(player[closest].whichskin==0){
7509 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7511 else if(player[closest].whichskin==1){
7512 LoadTextureSave(":Data:Textures:Fur.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7514 else if(player[closest].whichskin==2){
7515 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7517 else if(player[closest].whichskin==3){
7518 LoadTextureSave(":Data:Textures:Lynx.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7520 else if(player[closest].whichskin==4){
7521 LoadTextureSave(":Data:Textures:Otter.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7523 else if(player[closest].whichskin==5){
7524 LoadTextureSave(":Data:Textures:Opal.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7526 else if(player[closest].whichskin==6){
7527 LoadTextureSave(":Data:Textures:Sable.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7529 else if(player[closest].whichskin==7){
7530 LoadTextureSave(":Data:Textures:Chocolate.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7532 else if(player[closest].whichskin==8){
7533 LoadTextureSave(":Data:Textures:BW2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7535 else if(player[closest].whichskin==9){
7536 LoadTextureSave(":Data:Textures:WB2.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7539 if(player[closest].creature==wolftype){
7541 if(player[closest].whichskin==0){
7542 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7544 else if(player[closest].whichskin==1){
7545 LoadTextureSave(":Data:Textures:Darkwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7547 else if(player[closest].whichskin==2){
7548 LoadTextureSave(":Data:Textures:Snowwolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7553 if(player[closest].numclothes){
7554 for(i=0;i<player[closest].numclothes;i++){
7555 tintr=player[closest].clothestintr[i];
7556 tintg=player[closest].clothestintg[i];
7557 tintb=player[closest].clothestintb[i];
7558 AddClothes((char *)player[closest].clothes[i],0,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7560 player[closest].DoMipmaps(5,0,0,player[closest].skeleton.skinsize,player[closest].skeleton.skinsize);
7563 detailtogglekeydown=1;
7566 if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7568 float closestdist=-1;
7571 for(i=1;i<numplayers;i++){
7572 distance=findDistancefast(&player[i].coords,&player[0].coords);
7573 if(closestdist==-1||distance<closestdist){
7574 closestdist=distance;
7579 if(player[closest].creature==wolftype){
7580 headprop=player[closest].proportionhead.x/1.1;
7581 bodyprop=player[closest].proportionbody.x/1.1;
7582 armprop=player[closest].proportionarms.x/1.1;
7583 legprop=player[closest].proportionlegs.x/1.1;
7586 if(player[closest].creature==rabbittype){
7587 headprop=player[closest].proportionhead.x/1.2;
7588 bodyprop=player[closest].proportionbody.x/1.05;
7589 armprop=player[closest].proportionarms.x/1.00;
7590 legprop=player[closest].proportionlegs.x/1.1;
7594 if(player[closest].creature==rabbittype){
7595 player[closest].skeleton.id=closest;
7596 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);
7597 LoadTextureSave(":Data:Textures:Wolf.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[closest],&player[closest].skeleton.skinsize);
7598 player[closest].whichskin=0;
7599 player[closest].creature=wolftype;
7601 player[closest].proportionhead=1.1;
7602 player[closest].proportionbody=1.1;
7603 player[closest].proportionarms=1.1;
7604 player[closest].proportionlegs=1.1;
7605 player[closest].proportionlegs.y=1.1;
7606 player[closest].scale=.23*5*player[0].scale;
7608 player[closest].damagetolerance=300;
7612 player[closest].skeleton.id=closest;
7613 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);
7614 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[closest].skeleton.drawmodel.textureptr,1,&player[closest].skeleton.skinText[0],&player[closest].skeleton.skinsize);
7615 player[closest].whichskin=0;
7616 player[closest].creature=rabbittype;
7618 player[closest].proportionhead=1.2;
7619 player[closest].proportionbody=1.05;
7620 player[closest].proportionarms=1.00;
7621 player[closest].proportionlegs=1.1;
7622 player[closest].proportionlegs.y=1.05;
7623 player[closest].scale=.2*5*player[0].scale;
7625 player[closest].damagetolerance=200;
7628 if(player[closest].creature==wolftype){
7629 player[closest].proportionhead=1.1*headprop;
7630 player[closest].proportionbody=1.1*bodyprop;
7631 player[closest].proportionarms=1.1*armprop;
7632 player[closest].proportionlegs=1.1*legprop;
7635 if(player[closest].creature==rabbittype){
7636 player[closest].proportionhead=1.2*headprop;
7637 player[closest].proportionbody=1.05*bodyprop;
7638 player[closest].proportionarms=1.00*armprop;
7639 player[closest].proportionlegs=1.1*legprop;
7640 player[closest].proportionlegs.y=1.05*legprop;
7644 detailtogglekeydown=1;
7647 if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
7648 detailtogglekeydown=0;
7651 if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
7654 slomotogglekeydown=1;
7658 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
7660 float closestdist=-1;
7662 XYZ flatfacing2,flatvelocity2;
7665 for(i=1;i<numplayers;i++){
7666 distance=findDistancefast(&player[i].coords,&player[0].coords);
7667 if(distance<144&&!player[i].headless)
7668 if(closestdist==-1||distance<closestdist){
7669 closestdist=distance;
7671 blah = player[i].coords;
7676 XYZ headspurtdirection;
7677 int i = player[closest].skeleton.jointlabels[head];
7678 for(k=0;k<player[closest].skeleton.num_joints; k++){
7679 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7680 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7681 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;
7682 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7683 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7684 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7685 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7686 headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
7687 Normalise(&headspurtdirection);
7688 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
7689 flatvelocity2+=headspurtdirection*8;
7690 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
7692 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7702 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7703 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7704 OPENAL_SetVolume(channels[splattersound], 256);
7705 OPENAL_SetPaused(channels[splattersound], false);
7707 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7708 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7709 OPENAL_SetVolume(channels[breaksound2], 100);
7710 OPENAL_SetPaused(channels[breaksound2], false);
7712 if(player[closest].skeleton.free==2)player[closest].skeleton.free=0;
7713 player[closest].RagDoll(0);
7714 player[closest].dead=2;
7715 player[closest].headless=1;
7716 player[closest].DoBloodBig(3,165);
7721 explodetogglekeydown=1;
7724 if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
7726 float closestdist=-1;
7728 XYZ flatfacing2,flatvelocity2;
7731 for(i=1;i<numplayers;i++){
7732 distance=findDistancefast(&player[i].coords,&player[0].coords);
7734 if(closestdist==-1||distance<closestdist){
7735 closestdist=distance;
7737 blah=player[i].coords;
7751 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
7752 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
7753 OPENAL_SetVolume(channels[splattersound], 256);
7754 OPENAL_SetPaused(channels[splattersound], false);
7756 PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
7757 OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
7758 OPENAL_SetVolume(channels[breaksound2], 600);
7759 OPENAL_SetPaused(channels[breaksound2], false);
7761 for(i=0;i<player[closest].skeleton.num_joints; i++){
7762 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7763 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7764 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;
7765 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7766 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7767 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7768 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7769 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7770 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
7771 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
7774 for(i=0;i<player[closest].skeleton.num_joints; i++){
7775 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7776 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7777 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;
7778 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7779 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7780 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7781 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7782 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
7783 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
7786 for(i=0;i<player[closest].skeleton.num_joints; i++){
7787 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7788 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7789 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;
7790 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7791 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7792 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7793 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7794 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7795 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7798 for(i=0;i<player[closest].skeleton.num_joints; i++){
7799 if(!player[closest].skeleton.free)flatvelocity2=player[closest].velocity;
7800 if(player[closest].skeleton.free)flatvelocity2=player[closest].skeleton.joints[i].velocity;
7801 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;
7802 if(player[closest].skeleton.free)flatfacing2=player[closest].skeleton.joints[i].position*player[closest].scale+player[closest].coords;
7803 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
7804 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
7805 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
7806 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
7807 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
7811 for(j=0;j<numplayers; j++){
7813 if(findDistancefast(&player[j].coords,&player[closest].coords)<25){
7814 player[j].DoDamage((25-findDistancefast(&player[j].coords,&player[closest].coords))*60);
7815 if(player[j].skeleton.free==2)player[j].skeleton.free=1;
7816 player[j].skeleton.longdead=0;
7817 player[j].RagDoll(0);
7818 for(i=0;i<player[j].skeleton.num_joints; i++){
7819 temppos=player[j].skeleton.joints[i].position+player[j].coords;
7820 if(findDistancefast(&temppos,&player[closest].coords)<25){
7821 flatvelocity2=temppos-player[closest].coords;
7822 Normalise(&flatvelocity2);
7823 player[j].skeleton.joints[i].velocity+=flatvelocity2*((20-findDistancefast(&temppos,&player[closest].coords))*20);
7830 player[closest].DoDamage(10000);
7831 player[closest].RagDoll(0);
7832 player[closest].dead=2;
7833 player[closest].coords=20;
7834 player[closest].skeleton.free=2;
7840 explodetogglekeydown=1;
7843 if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
7844 explodetogglekeydown=0;
7848 if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
7850 //tfile=fopen( ":Data:Maps:mapsave", "wb" );
7851 if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
7852 else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
7853 else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
7854 else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
7855 else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
7856 else tfile=fopen( ":Data:Maps:mapsave", "wb" );
7858 fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
7859 fwrite( &player[0].rotation, 1, sizeof(float), tfile );
7860 fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
7861 fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
7862 for(j=0;j<player[0].num_weapons;j++){
7863 fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
7865 fwrite( &environment, 1, sizeof(int), tfile );
7867 fwrite( &objects.numobjects, 1, sizeof(int), tfile );
7868 fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
7869 fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
7870 fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
7871 fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
7873 fwrite( &numplayers, 1, sizeof(int), tfile );
7874 if(numplayers>1&&numplayers<maxplayers)
7875 for(i=1;i<numplayers;i++){
7876 fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
7877 fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
7878 for(j=0;j<player[i].num_weapons;j++){
7879 fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
7881 if(player[i].numwaypoints<30){
7882 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7883 fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
7884 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7885 //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
7888 player[i].numwaypoints=0;
7889 player[i].waypoint=0;
7890 fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
7891 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7892 fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
7898 slomotogglekeydown=1;
7901 if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
7902 slomotogglekeydown=0;
7906 if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
7907 player[0].onfire=1-player[0].onfire;
7908 if(player[0].onfire){
7909 player[0].CatchFire();
7911 if(!player[0].onfire){
7914 gLoc[0]=player[0].coords.x;
7915 gLoc[1]=player[0].coords.y;
7916 gLoc[2]=player[0].coords.z;
7920 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
7921 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
7922 OPENAL_SetVolume(channels[fireendsound], 256);
7923 OPENAL_SetPaused(channels[fireendsound], false);
7924 OPENAL_SetPaused(channels[stream_firesound], true);
7926 slomotogglekeydown=1;
7929 if(IsKeyDown(theKeyMap, MAC_L_KEY)){
7930 if(player[0].bleeding<=0)
7931 player[0].DoBlood(1,255);
7935 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
7937 float closestdist=-1;
7940 for(i=1;i<numplayers;i++){
7941 distance=findDistancefast(&player[i].coords,&player[0].coords);
7942 if(closestdist==-1||distance<closestdist){
7943 closestdist=distance;
7947 if(closestdist>0&&closest>=0){
7948 //player[closest]=player[numplayers-1];
7949 //player[closest].skeleton=player[numplayers-1].skeleton;
7952 drawmodetogglekeydown=1;
7955 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
7957 float closestdist=-1;
7960 for(i=1;i<max_objects;i++){
7961 distance=findDistancefast(&objects.position[i],&player[0].coords);
7962 if(closestdist==-1||distance<closestdist){
7963 closestdist=distance;
7967 if(closestdist>0&&closest>=0){
7968 objects.position[closest].y-=500;
7970 drawmodetogglekeydown=1;
7973 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
7975 //if(drawmode>2)drawmode=0;
7976 if(objects.numobjects<max_objects-1){
7978 boxcoords.x=player[0].coords.x;
7979 boxcoords.z=player[0].coords.z;
7980 boxcoords.y=player[0].coords.y-3;
7981 if(editortype==bushtype)boxcoords.y=player[0].coords.y-.5;
7982 if(editortype==firetype)boxcoords.y=player[0].coords.y-.5;
7983 //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
7984 float temprotat,temprotat2;
7985 temprotat=editorrotation;
7986 temprotat2=editorrotation2;
7987 if(temprotat<0||editortype==bushtype)temprotat=Random()%360;
7988 if(temprotat2<0)temprotat2=Random()%360;
7990 objects.MakeObject(editortype,boxcoords,(int)temprotat-((int)temprotat)%30,(int)temprotat2,editorsize);
7991 if(editortype==treetrunktype)
7992 objects.MakeObject(treeleavestype,boxcoords,Random()%360*(temprotat2<2)+(int)editorrotation-((int)editorrotation)%30,editorrotation2,editorsize);
7995 drawmodetogglekeydown=1;
7998 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
7999 if(numplayers<maxplayers-1){
8000 player[numplayers].scale=.2*5*player[0].scale;
8001 player[numplayers].creature=rabbittype;
8002 player[numplayers].howactive=editoractive;
8003 player[numplayers].skeleton.id=numplayers;
8004 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);
8006 //texsize=512*512*3/texdetail/texdetail;
8007 //if(!player[numplayers].loaded)player[numplayers].skeleton.skinText = new GLubyte[texsize];
8008 //player[numplayers].skeleton.skinText.resize(texsize);
8010 k=abs(Random()%2)+1;
8012 LoadTextureSave(":Data:Textures:Fur3.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8013 player[numplayers].whichskin=0;
8016 LoadTextureSave(":Data:Textures:Fur.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8017 player[numplayers].whichskin=1;
8020 LoadTextureSave(":Data:Textures:Fur2.jpg",&player[numplayers].skeleton.drawmodel.textureptr,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8021 player[numplayers].whichskin=2;
8024 LoadTexture(":Data:Textures:Belt.png",&player[numplayers].skeleton.drawmodelclothes.textureptr,1,1);
8025 player[numplayers].power=1;
8026 player[numplayers].speedmult=1;
8027 player[numplayers].currentanimation=bounceidleanim;
8028 player[numplayers].targetanimation=bounceidleanim;
8029 player[numplayers].currentframe=0;
8030 player[numplayers].targetframe=1;
8031 player[numplayers].target=0;
8032 player[numplayers].bled=0;
8033 player[numplayers].speed=1+(float)(Random()%100)/1000;
8035 player[numplayers].targetrotation=player[0].targetrotation;
8036 player[numplayers].rotation=player[0].rotation;
8038 player[numplayers].velocity=0;
8039 player[numplayers].coords=player[0].coords;
8040 player[numplayers].oldcoords=player[numplayers].coords;
8041 player[numplayers].realoldcoords=player[numplayers].coords;
8043 player[numplayers].id=numplayers;
8044 player[numplayers].skeleton.id=numplayers;
8045 player[numplayers].updatedelay=0;
8046 player[numplayers].normalsupdatedelay=0;
8048 player[numplayers].aitype=passivetype;
8049 player[numplayers].aitarget=0;
8051 if(player[0].creature==wolftype){
8052 headprop=player[0].proportionhead.x/1.1;
8053 bodyprop=player[0].proportionbody.x/1.1;
8054 armprop=player[0].proportionarms.x/1.1;
8055 legprop=player[0].proportionlegs.x/1.1;
8058 if(player[0].creature==rabbittype){
8059 headprop=player[0].proportionhead.x/1.2;
8060 bodyprop=player[0].proportionbody.x/1.05;
8061 armprop=player[0].proportionarms.x/1.00;
8062 legprop=player[0].proportionlegs.x/1.1;
8065 if(player[numplayers].creature==wolftype){
8066 player[numplayers].proportionhead=1.1*headprop;
8067 player[numplayers].proportionbody=1.1*bodyprop;
8068 player[numplayers].proportionarms=1.1*armprop;
8069 player[numplayers].proportionlegs=1.1*legprop;
8072 if(player[numplayers].creature==rabbittype){
8073 player[numplayers].proportionhead=1.2*headprop;
8074 player[numplayers].proportionbody=1.05*bodyprop;
8075 player[numplayers].proportionarms=1.00*armprop;
8076 player[numplayers].proportionlegs=1.1*legprop;
8077 player[numplayers].proportionlegs.y=1.05*legprop;
8080 player[numplayers].headless=0;
8081 player[numplayers].onfire=0;
8084 player[numplayers].proportionhead.z=0;
8085 player[numplayers].proportionbody.z=0;
8086 player[numplayers].proportionarms.z=0;
8087 player[numplayers].proportionlegs.z=0;
8090 player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0);
8092 player[numplayers].damagetolerance=200;
8094 player[numplayers].protectionhead=player[0].protectionhead;
8095 player[numplayers].protectionhigh=player[0].protectionhigh;
8096 player[numplayers].protectionlow=player[0].protectionlow;
8097 player[numplayers].armorhead=player[0].armorhead;
8098 player[numplayers].armorhigh=player[0].armorhigh;
8099 player[numplayers].armorlow=player[0].armorlow;
8100 player[numplayers].metalhead=player[0].metalhead;
8101 player[numplayers].metalhigh=player[0].metalhigh;
8102 player[numplayers].metallow=player[0].metallow;
8104 player[numplayers].immobile=player[0].immobile;
8106 player[numplayers].numclothes=player[0].numclothes;
8107 if(player[numplayers].numclothes)
8108 for(i=0;i<player[numplayers].numclothes;i++){
8109 strcpy(player[numplayers].clothes[i], player[0].clothes[i]);
8110 player[numplayers].clothestintr[i]=player[0].clothestintr[i];
8111 player[numplayers].clothestintg[i]=player[0].clothestintg[i];
8112 player[numplayers].clothestintb[i]=player[0].clothestintb[i];
8113 tintr=player[numplayers].clothestintr[i];
8114 tintg=player[numplayers].clothestintg[i];
8115 tintb=player[numplayers].clothestintb[i];
8116 AddClothes((char *)player[numplayers].clothes[i],0,1,&player[numplayers].skeleton.skinText[0],&player[numplayers].skeleton.skinsize);
8118 if(player[numplayers].numclothes){
8119 player[numplayers].DoMipmaps(5,0,0,player[numplayers].skeleton.skinsize,player[numplayers].skeleton.skinsize);
8122 player[numplayers].power=player[0].power;
8123 player[numplayers].speedmult=player[0].speedmult;
8125 player[numplayers].damage=0;
8126 player[numplayers].permanentdamage=0;
8127 player[numplayers].superpermanentdamage=0;
8128 player[numplayers].deathbleeding=0;
8129 player[numplayers].bleeding=0;
8130 player[numplayers].numwaypoints=0;
8131 player[numplayers].waypoint=0;
8132 player[numplayers].jumppath=0;
8133 player[numplayers].weaponstuck=-1;
8134 player[numplayers].weaponactive=-1;
8135 player[numplayers].num_weapons=0;
8136 player[numplayers].bloodloss=0;
8137 player[numplayers].dead=0;
8139 player[numplayers].loaded=1;
8143 drawmodetogglekeydown=1;
8146 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
8147 if(player[numplayers-1].numwaypoints<90){
8148 player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
8149 player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
8150 player[numplayers-1].numwaypoints++;
8152 drawmodetogglekeydown=1;
8155 if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
8156 if(numpathpoints<30){
8157 bool connected,alreadyconnected;
8160 for(i=0;i<numpathpoints;i++){
8161 if(findDistancefast(&pathpoint[i],&player[0].coords)<.5&&i!=pathpointselected&&!connected){
8163 for(j=0;j<numpathpointconnect[pathpointselected];j++){
8164 if(pathpointconnect[pathpointselected][j]==i)alreadyconnected=1;
8166 if(!alreadyconnected){
8167 numpathpointconnect[pathpointselected]++;
8169 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=i;
8175 pathpoint[numpathpoints-1]=player[0].coords;
8176 numpathpointconnect[numpathpoints-1]=0;
8177 if(numpathpoints>1&&pathpointselected!=-1){
8178 numpathpointconnect[pathpointselected]++;
8179 pathpointconnect[pathpointselected][numpathpointconnect[pathpointselected]-1]=numpathpoints-1;
8181 pathpointselected=numpathpoints-1;
8184 drawmodetogglekeydown=1;
8187 if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
8188 pathpointselected++;
8189 if(pathpointselected>=numpathpoints)pathpointselected=-1;
8190 drawmodetogglekeydown=1;
8192 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8193 pathpointselected--;
8194 if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
8195 drawmodetogglekeydown=1;
8197 if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
8198 if(pathpointselected!=-1){
8200 pathpoint[pathpointselected]=pathpoint[numpathpoints];
8201 numpathpointconnect[pathpointselected]=numpathpointconnect[numpathpoints];
8202 for(i=0;i<numpathpointconnect[pathpointselected];i++){
8203 pathpointconnect[pathpointselected][i]=pathpointconnect[numpathpoints][i];
8205 for(i=0;i<numpathpoints;i++){
8206 for(j=0;j<numpathpointconnect[i];j++){
8207 if(pathpointconnect[i][j]==pathpointselected){
8208 pathpointconnect[i][j]=pathpointconnect[i][numpathpointconnect[i]-1];
8209 numpathpointconnect[i]--;
8211 if(pathpointconnect[i][j]==numpathpoints){
8212 pathpointconnect[i][j]=pathpointselected;
8216 pathpointselected=numpathpoints-1;
8218 drawmodetogglekeydown=1;
8221 if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
8222 editorenabled=1-editorenabled;
8224 player[0].damagetolerance=100000;
8226 player[0].superpermanentdamage=0;
8227 player[0].bloodloss=0;
8228 player[0].deathbleeding=0;
8231 player[0].damagetolerance=200;
8233 player[0].permanentdamage=0;
8234 player[0].superpermanentdamage=0;
8235 player[0].bloodloss=0;
8236 player[0].deathbleeding=0;
8238 drawmodetogglekeydown=1;
8241 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8243 if(editortype==treeleavestype||editortype==10)editortype--;
8244 if(editortype<0)editortype=firetype;
8245 drawmodetogglekeydown=1;
8248 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8250 if(editortype==treeleavestype||editortype==10)editortype++;
8251 if(editortype>firetype)editortype=0;
8252 drawmodetogglekeydown=1;
8255 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8256 editorrotation-=multiplier*100;
8257 if(editorrotation<-.01)editorrotation=-.01;
8258 drawmodetogglekeydown=1;
8261 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8262 editorrotation+=multiplier*100;
8263 drawmodetogglekeydown=1;
8266 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8267 editorsize+=multiplier;
8268 drawmodetogglekeydown=1;
8271 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8272 editorsize-=multiplier;
8273 if(editorsize<.1)editorsize=.1;
8274 drawmodetogglekeydown=1;
8278 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8279 mapradius-=multiplier*10;
8282 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8283 mapradius+=multiplier*10;
8286 if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8287 mapcenter.x+=multiplier*20;
8290 if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8291 mapcenter.x-=multiplier*20;
8294 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8295 mapcenter.z+=multiplier*20;
8298 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8299 mapcenter.z-=multiplier*20;
8302 if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8303 editorrotation2+=multiplier*100;
8306 if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
8307 editorrotation2-=multiplier*100;
8308 if(editorrotation2<-.01)editorrotation2=-.01;
8310 if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
8312 float closestdist=-1;
8314 for(i=0;i<objects.numobjects;i++){
8315 distance=findDistancefast(&objects.position[i],&player[0].coords);
8316 if(closestdist==-1||distance<closestdist){
8317 closestdist=distance;
8321 if(closestdist>0&&closest>=0)objects.DeleteObject(closest);
8322 drawmodetogglekeydown=1;
8326 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)){
8327 drawmodetogglekeydown=0;
8330 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8331 //if(!player[0].skeleton.free)player[0].damage+=500;
8332 player[0].RagDoll(0);
8333 //player[0].spurt=1;
8334 //player[0].DoDamage(1000);
8338 gLoc[0]=player[0].coords.x;
8339 gLoc[1]=player[0].coords.y;
8340 gLoc[2]=player[0].coords.z;
8341 vel[0]=player[0].velocity.x;
8342 vel[1]=player[0].velocity.y;
8343 vel[2]=player[0].velocity.z;
8344 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
8345 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
8346 OPENAL_SetVolume(channels[whooshsound], 128);
8347 OPENAL_SetPaused(channels[whooshsound], false);
8348 //OPENAL_SetPaused(channels[whooshsound], true);
8350 texturesizetogglekeydown=1;
8353 if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
8356 float closestdist=-1;
8358 for(i=0;i<objects.numobjects;i++){
8359 if(objects.type[i]==treeleavestype){
8360 objects.scale[i]*=.9;
8363 texturesizetogglekeydown=1;
8366 static XYZ relative;
8367 static int randattack;
8369 static bool playerrealattackkeydown=0;
8371 if(!buttons[0])oldbutton=0;
8372 if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
8373 if(oldattackkey)player[0].attackkeydown=0;
8374 if(oldattackkey)playerrealattackkeydown=0;
8375 if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
8376 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);
8377 if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
8378 for(k=0;k<numplayers;k++){
8379 if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
8380 player[k].Reverse();
8384 if(!hostile||indialogue!=-1)player[0].attackkeydown=0;
8386 for(k=0;k<numplayers;k++){
8387 if(indialogue!=-1)player[k].attackkeydown=0;
8388 if(player[k].targetanimation!=rabbitrunninganim&&player[k].targetanimation!=wolfrunninganim){
8389 if(player[k].aitype!=playercontrolled)player[k].victim=&player[0];
8390 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)){
8391 player[k].jumppower-=2;
8393 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)){
8394 for(i=0;i<numplayers;i++){
8396 if(player[i].targetanimation==swordslashanim||player[i].targetanimation==knifeslashstartanim||player[i].targetanimation==staffhitanim||player[i].targetanimation==staffspinhitanim)
8397 if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){
8398 player[k].targetanimation=dodgebackanim;
8400 player[k].targetframe=0;
8401 rotatetarget=player[i].coords-player[k].coords;
8402 Normalise(&rotatetarget);
8403 player[k].targetrotation=-asin(0-rotatetarget.x);
8404 player[k].targetrotation*=360/6.28;
8405 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8407 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;
8410 if(player[k].targetanimation!=dodgebackanim){
8411 if(k==0)numflipped++;
8412 player[k].targetanimation=backhandspringanim;
8414 player[k].targetframe=0;
8415 player[k].targetrotation=-rotation+180;
8416 if(player[k].leftkeydown)player[k].targetrotation-=45;
8417 if(player[k].rightkeydown)player[k].targetrotation+=45;
8418 player[k].rotation=player[k].targetrotation;
8419 player[k].jumppower-=2;
8422 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())){
8423 player[k].hasvictim=0;
8425 for(i=0;i<numplayers;i++){
8427 if(!player[k].hasvictim)
8428 if((k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack!=reversal){
8429 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){
8430 player[k].victim=&player[i];
8431 player[k].hasvictim=1;
8432 if(player[k].aitype==playercontrolled){
8433 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;
8434 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;
8435 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;
8436 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;
8437 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;
8438 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;
8439 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;
8440 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;
8441 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;
8442 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;
8445 if(findDistancefast(&player[k].coords,&player[i].coords)<4.5*(player[k].scale*5)*(player[k].scale*5)){
8446 if(player[k].weaponactive==-1)randattack=abs(Random()%5);
8447 else randattack=abs(Random()%5);
8448 if(player[k].weaponactive==-1&&findDistancefast(&player[k].coords,&player[i].coords)<2.5*(player[k].scale*5)*(player[k].scale*5)){
8449 if(randattack==0&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=sweepanim;
8450 else if(randattack==1&&animation[player[i].targetanimation].height!=lowheight&&player[k].weaponactive==-1)player[k].targetanimation=upunchanim;
8451 else if(randattack==2&&animation[player[i].targetanimation].height!=lowheight)player[k].targetanimation=spinkickanim;
8452 else if(animation[player[i].targetanimation].height==lowheight)player[k].targetanimation=lowkickanim;
8454 if(player[k].weaponactive!=-1){
8455 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;
8456 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;
8457 //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;
8458 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;
8459 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;
8460 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;
8461 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;
8462 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;
8466 if(player[k].targetanimation==upunchanim&&player[k].creature==wolftype)player[k].targetanimation=wolfslapanim;
8468 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)){
8469 if(player[k].weaponactive==-1){
8470 player[i].targetanimation=sneakattackedanim;
8471 player[i].currentanimation=sneakattackedanim;
8472 player[k].currentanimation=sneakattackanim;
8473 player[k].targetanimation=sneakattackanim;
8474 player[k].oldcoords=player[k].coords;
8475 player[k].coords=player[i].coords;
8477 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==knife){
8478 player[i].targetanimation=knifesneakattackedanim;
8479 player[i].currentanimation=knifesneakattackedanim;
8480 player[k].currentanimation=knifesneakattackanim;
8481 player[k].targetanimation=knifesneakattackanim;
8482 player[i].oldcoords=player[i].coords;
8483 player[i].coords=player[k].coords;
8485 if(player[k].weaponactive!=-1&&weapons.type[player[k].weaponids[player[k].weaponactive]]==sword){
8486 player[i].targetanimation=swordsneakattackedanim;
8487 player[i].currentanimation=swordsneakattackedanim;
8488 player[k].currentanimation=swordsneakattackanim;
8489 player[k].targetanimation=swordsneakattackanim;
8490 player[i].oldcoords=player[i].coords;
8491 player[i].coords=player[k].coords;
8493 if(player[k].weaponactive==-1||weapons.type[player[k].weaponids[player[k].weaponactive]]!=staff){
8494 player[k].victim=&player[i];
8495 player[k].hasvictim=1;
8496 player[i].targettilt2=0;
8497 player[i].targetframe=1;
8498 player[i].currentframe=0;
8500 player[i].velocity=0;
8501 player[k].targettilt2=player[i].targettilt2;
8502 player[k].currentframe=player[i].currentframe;
8503 player[k].targetframe=player[i].targetframe;
8504 player[k].target=player[i].target;
8505 player[k].velocity=0;
8506 player[k].targetrotation=player[i].rotation;
8507 player[k].rotation=player[i].rotation;
8508 player[i].targetrotation=player[i].rotation;
8511 if(animation[player[k].targetanimation].attack==normalattack&&player[k].victim==&player[i]&&(!player[i].skeleton.free)){
8513 player[k].targetframe=0;
8515 //player[k].velocity=0;
8517 rotatetarget=player[i].coords-player[k].coords;
8518 Normalise(&rotatetarget);
8519 player[k].targetrotation=-asin(0-rotatetarget.x);
8520 player[k].targetrotation*=360/6.28;
8521 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8523 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8525 player[k].lastattack3=player[k].lastattack2;
8526 player[k].lastattack2=player[k].lastattack;
8527 player[k].lastattack=player[k].targetanimation;
8528 //player[k].targettilt2=0;
8532 if(player[k].targetanimation==knifefollowanim&&player[k].victim==&player[i]){
8533 rotatetarget=player[i].coords-player[k].coords;
8534 Normalise(&rotatetarget);
8535 player[k].targetrotation=-asin(0-rotatetarget.x);
8536 player[k].targetrotation*=360/6.28;
8537 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8538 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8540 player[k].victim=&player[i];
8541 player[k].hasvictim=1;
8542 player[i].targetanimation=knifefollowedanim;
8543 player[i].currentanimation=knifefollowedanim;
8544 player[i].targettilt2=0;
8545 player[i].targettilt2=player[k].targettilt2;
8546 player[i].targetframe=1;
8547 player[i].currentframe=0;
8549 player[i].velocity=0;
8550 player[k].currentanimation=knifefollowanim;
8551 player[k].targetanimation=knifefollowanim;
8552 player[k].targettilt2=player[i].targettilt2;
8553 player[k].currentframe=player[i].currentframe;
8554 player[k].targetframe=player[i].targetframe;
8555 player[k].target=player[i].target;
8556 player[k].velocity=0;
8557 player[k].oldcoords=player[k].coords;
8558 player[i].coords=player[k].coords;
8559 player[i].targetrotation=player[k].targetrotation;
8560 player[i].rotation=player[k].targetrotation;
8561 player[k].rotation=player[k].targetrotation;
8562 player[i].rotation=player[k].targetrotation;
8567 if(player[k].weaponactive!=-1){
8568 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)hasstaff=1;
8571 for(i=0;i<numplayers;i++){
8573 if((playerrealattackkeydown||player[i].dead||!hasstaff)&&(k==0||i==0)&&i!=k&&i<numplayers&&k<numplayers&&animation[player[k].targetanimation].attack==neutral&&k==0){
8574 if(!player[i].dead||!realthreat||(player[k].weaponactive==-1&&player[k].crouchkeydown))
8575 if(player[i].skeleton.free)
8576 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)))){
8577 player[k].victim=&player[i];
8578 player[k].hasvictim=1;
8579 if(player[k].weaponactive!=-1&&tutoriallevel!=1){
8580 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;
8581 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;
8582 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;
8584 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){
8585 player[k].targetanimation=killanim;
8586 for(j=0;j<terrain.numdecals;j++){
8587 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8588 terrain.DeleteDecal(j);
8591 for(l=0;l<objects.numobjects;l++){
8592 if(objects.model[l].type==decalstype)
8593 for(j=0;j<objects.model[l].numdecals;j++){
8594 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8595 objects.model[l].DeleteDecal(j);
8600 if(!player[i].dead||musictype!=2)
8601 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)){
8602 player[k].targetanimation=dropkickanim;
8603 for(j=0;j<terrain.numdecals;j++){
8604 if((terrain.decaltype[j]==blooddecal||terrain.decaltype[j]==blooddecalslow)&&terrain.decalalivetime[j]<2){
8605 terrain.DeleteDecal(j);
8608 for(l=0;l<objects.numobjects;l++){
8609 if(objects.model[l].type==decalstype)
8610 for(j=0;j<objects.model[l].numdecals;j++){
8611 if((objects.model[l].decaltype[j]==blooddecal||objects.model[l].decaltype[j]==blooddecalslow)&&objects.model[l].decalalivetime[j]<2){
8612 objects.model[l].DeleteDecal(j);
8618 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)){
8620 player[k].targetframe=0;
8622 //player[k].velocity=0;
8624 rotatetarget=player[i].coords-player[k].coords;
8625 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim||player[k].targetanimation==staffgroundsmashanim){
8626 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;
8628 Normalise(&rotatetarget);
8629 player[k].targetrotation=-asin(0-rotatetarget.x);
8630 player[k].targetrotation*=360/6.28;
8631 if(rotatetarget.z<0)player[k].targetrotation=180-player[k].targetrotation;
8633 if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){
8634 player[k].targetrotation+=(float)(abs(Random()%100)-50)/4;
8637 player[k].targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
8638 if(player[k].targetanimation==staffgroundsmashanim)player[k].targettilt2+=10;
8640 player[k].lastattack3=player[k].lastattack2;
8641 player[k].lastattack2=player[k].lastattack;
8642 player[k].lastattack=player[k].targetanimation;
8644 if(player[k].targetanimation==swordgroundstabanim){
8645 player[k].targetrotation+=30;
8647 //player[k].targettilt2=0;
8653 if(!player[k].hasvictim){
8654 for(i=0;i<numplayers;i++){
8655 if((player[k].hasvictim==0)&&i!=k&&(i==0||k==0)&&!player[i].skeleton.free){
8656 player[k].victim=&player[i];
8657 player[k].hasvictim=1;
8659 if(player[k].hasvictim&&!player[i].skeleton.free)
8660 if(findDistancefast(&player[k].coords,&player[i].coords)<findDistancefast(&player[k].coords,&player[k].victim->coords)&&i!=k&&(i==0||k==0)){
8661 player[k].victim=&player[i];
8665 if(player[k].aitype==playercontrolled)
8666 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)){
8668 player[k].targetanimation=rabbitkickanim;
8669 player[k].targetframe=0;
8672 if(animation[player[k].targetanimation].attack&&k==0){
8675 if(player[k].weaponactive!=-1){
8676 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==staff)armedstaff=1;
8679 if(player[k].weaponactive!=-1){
8680 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==sword)armedsword=1;
8683 if(player[k].weaponactive!=-1){
8684 if(weapons.type[player[k].weaponids[player[k].weaponactive]]==knife)armedknife=1;
8686 if(armedstaff)numstaffattack++;
8687 else if(armedsword)numswordattack++;
8688 else if(armedknife)numknifeattack++;
8689 else numunarmedattack++;
8696 static float collisionradius;
8698 for(k=0;k<numplayers;k++){
8699 for(i=k;i<numplayers;i++){
8702 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))
8703 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))
8704 if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
8705 if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
8706 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)
8707 if(player[i].coords.y>player[k].coords.y-3)
8708 if(player[i].coords.y<player[k].coords.y+3)
8709 if(player[i].coords.x>player[k].coords.x-3)
8710 if(player[i].coords.x<player[k].coords.x+3)
8711 if(player[i].coords.z>player[k].coords.z-3)
8712 if(player[i].coords.z<player[k].coords.z+3){
8713 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)){
8714 if(player[i].onfire||player[k].onfire){
8715 if(!player[i].onfire)player[i].CatchFire();
8716 if(!player[k].onfire)player[k].CatchFire();
8720 tempcoords1=player[i].coords;
8721 tempcoords2=player[k].coords;
8722 if(!player[i].skeleton.oldfree)tempcoords1.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[abdomen]].position.y*player[i].scale;
8723 if(!player[k].skeleton.oldfree)tempcoords2.y+=player[k].skeleton.joints[player[k].skeleton.jointlabels[abdomen]].position.y*player[k].scale;
8724 collisionradius=1.2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8725 if(player[0].hasvictim)
8726 if(player[0].targetanimation==rabbitkickanim&&(k==0||i==0)&&!player[0].victim->skeleton.free)collisionradius=3;
8727 if((!player[i].skeleton.oldfree||!player[k].skeleton.oldfree)&&(findDistancefast(&tempcoords1,&tempcoords2)<collisionradius||findDistancefast(&player[i].coords,&player[k].coords)<collisionradius)){
8729 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)){
8730 player[k].coords.y=player[i].coords.y;
8731 player[i].velocity=player[k].velocity;
8732 player[i].skeleton.free=0;
8733 player[i].rotation=0;
8734 player[i].RagDoll(0);
8735 player[i].DoDamage(20);
8736 if(k==0)camerashake+=.3;
8737 player[i].skeleton.longdead=0;
8738 player[k].lastcollide=1;
8741 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)){
8742 player[i].coords.y=player[k].coords.y;
8743 player[k].velocity=player[i].velocity;
8744 player[k].skeleton.free=0;
8745 player[k].rotation=0;
8746 player[k].RagDoll(0);
8747 player[k].DoDamage(20);
8748 if(i==0)camerashake+=.3;
8749 player[k].skeleton.longdead=0;
8750 player[i].lastcollide=1;
8753 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)){
8754 rotatetarget=player[k].velocity-player[i].velocity;
8755 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))
8756 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))){
8758 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)){
8759 static float gLoc[3];
8760 static float vel[3];
8761 gLoc[0]=player[i].coords.x;
8762 gLoc[1]=player[i].coords.y;
8763 gLoc[2]=player[i].coords.z;
8764 vel[0]=player[i].velocity.x;
8765 vel[1]=player[i].velocity.y;
8766 vel[2]=player[i].velocity.z;
8767 if(tutoriallevel!=1){
8768 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
8769 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
8770 OPENAL_SetVolume(channels[heavyimpactsound], 256);
8771 OPENAL_SetPaused(channels[heavyimpactsound], false);
8773 //player[i].velocity=player[k].velocity;
8774 //player[k].velocity=player[i].velocity;
8776 player[i].RagDoll(0);
8777 if(player[i].damage>player[i].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[i].dead){
8782 player[i].DoDamage(findLengthfast(&rotatetarget)/4);
8783 player[k].RagDoll(0);
8784 if(player[k].damage>player[k].damagetolerance-findLengthfast(&rotatetarget)/4&&!player[k].dead){
8789 player[k].DoDamage(findLengthfast(&rotatetarget)/4);
8791 //if(player[i].skeleton.oldfree){
8792 for(j=0;j<player[i].skeleton.num_joints;j++){
8793 player[i].skeleton.joints[j].velocity=player[i].skeleton.joints[j].velocity/5+player[k].velocity;
8796 //if(player[k].skeleton.oldfree){
8797 for(j=0;j<player[k].skeleton.num_joints;j++){
8798 player[k].skeleton.joints[j].velocity=player[k].skeleton.joints[j].velocity/5+player[i].velocity;
8804 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)){
8806 if(player[i].skeleton.oldfree==0&&player[k].skeleton.oldfree==0){
8807 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)){
8808 rotatetarget=player[k].coords-player[i].coords;
8809 Normalise(&rotatetarget);
8810 player[k].coords=(player[k].coords+player[i].coords)/2;
8811 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);
8812 player[k].coords+=rotatetarget*fast_sqrt(.6)/2*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5);
8813 if(player[k].howactive==typeactive||hostile)
8814 if(player[k].isIdle()){
8815 if(player[k].howactive<typesleeping){
8816 player[k].targetanimation=player[k].getStop();
8817 player[k].targetframe=0;
8820 else if(player[k].howactive==typesleeping)
8822 player[k].targetanimation=getupfromfrontanim;
8823 player[k].targetframe=0;
8826 if(!editorenabled)player[k].howactive=typeactive;
8828 if(player[i].howactive==typeactive||hostile)
8829 if(player[i].isIdle()){
8830 if(player[i].howactive<typesleeping){
8831 player[i].targetanimation=player[i].getStop();
8832 player[i].targetframe=0;
8837 player[i].targetanimation=getupfromfrontanim;
8838 player[i].targetframe=0;
8841 if(!editorenabled)player[i].howactive=typeactive;
8845 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){
8846 player[i].velocity=player[k].velocity;
8847 player[k].velocity=player[k].velocity*-.5;
8848 //player[i].velocity.y-=10;
8849 player[k].velocity.y=player[i].velocity.y;
8850 player[i].DoDamage(20);
8851 player[i].RagDoll(0);
8852 player[k].lastcollide=1;
8859 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){
8860 player[k].velocity=player[i].velocity;
8861 player[i].velocity=player[i].velocity*-.3;
8862 //player[k].velocity.y-=10;
8863 player[i].velocity.y=player[k].velocity.y;
8864 player[k].DoDamage(20);
8865 player[k].RagDoll(0);
8866 player[i].lastcollide=1;
8877 player[i].CheckKick();
8878 player[k].CheckKick();
8884 for(k=0;k<numplayers;k++){
8885 for(i=k;i<numplayers;i++){
8887 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))){
8888 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)){
8889 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)){
8890 player[i].victim=&player[k];
8891 player[i].targetanimation=jumpreversedanim;
8892 player[i].currentanimation=jumpreversedanim;
8893 player[k].currentanimation=jumpreversalanim;
8894 player[k].targetanimation=jumpreversalanim;
8895 player[i].targettilt2=0;
8896 player[i].currentframe=0;
8897 player[i].targetframe=1;
8898 player[k].currentframe=0;
8899 player[k].targetframe=1;
8900 if(player[i].coords.y<player[k].coords.y+1){
8901 player[i].targetanimation=rabbitkickreversedanim;
8902 player[i].currentanimation=rabbitkickreversedanim;
8903 player[k].currentanimation=rabbitkickreversalanim;
8904 player[k].targetanimation=rabbitkickreversalanim;
8905 player[k].currentframe=1;
8906 player[k].targetframe=2;
8907 player[i].currentframe=1;
8908 player[i].targetframe=2;
8910 player[k].targettilt2=0;
8912 player[i].velocity=0;
8913 player[k].velocity=0;
8914 player[k].oldcoords=player[k].coords;
8915 player[i].coords=player[k].coords;
8916 player[k].targetrotation=player[i].targetrotation;
8917 player[k].rotation=player[i].targetrotation;
8918 player[k].victim=&player[i];
8919 if(player[k].aitype==attacktypecutoff)player[k].stunned=.5;
8921 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)){
8922 player[k].victim=&player[i];
8923 player[k].targetanimation=jumpreversedanim;
8924 player[k].currentanimation=jumpreversedanim;
8925 player[i].currentanimation=jumpreversalanim;
8926 player[i].targetanimation=jumpreversalanim;
8927 player[k].targettilt2=0;
8928 player[i].targettilt2=0;
8929 player[k].currentframe=0;
8930 player[k].targetframe=1;
8931 player[i].currentframe=0;
8932 player[i].targetframe=1;
8933 if(player[k].coords.y<player[i].coords.y+1){
8934 player[k].targetanimation=rabbitkickreversedanim;
8935 player[k].currentanimation=rabbitkickreversedanim;
8936 player[i].currentanimation=rabbitkickreversalanim;
8937 player[i].targetanimation=rabbitkickreversalanim;
8938 player[k].currentframe=1;
8939 player[k].targetframe=2;
8940 player[i].currentframe=1;
8941 player[i].targetframe=2;
8944 player[k].velocity=0;
8945 player[i].velocity=0;
8946 player[i].oldcoords=player[i].coords;
8947 player[k].coords=player[i].coords;
8948 player[i].targetrotation=player[k].targetrotation;
8949 player[i].rotation=player[k].targetrotation;
8950 player[i].victim=&player[k];
8951 if(player[i].aitype==attacktypecutoff)player[i].stunned=.5;
8958 for(k=0;k<numplayers;k++)
8959 if(player[k].immobile&&k!=0)player[k].coords=player[k].realoldcoords;
8968 static float checkdelay;
8969 checkdelay-=multiplier;
8971 static bool checkedcoll[maxplayers][maxplayers];
8972 static bool above[maxplayers];
8974 for(i=0;i<maxplayers;i++){
8975 for(j=0;j<maxplayers;j++){
8976 checkedcoll[i][j]=0;
8980 if(numplayers>1&&checkdelay<=0){
8982 for(k=0;k<numplayers;k++){
8983 if(player[k].skeleton.free!=2)above[k]=-1;
8985 for(i=k;i<numplayers;i++){
8988 if(!checkedcoll[i][k]){
8989 checkedcoll[i][k]=1;
8990 checkedcoll[k][i]=1;
8991 if(player[i].skeleton.free&&player[k].skeleton.free)
8992 if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
8993 if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
8994 if(player[i].coords.y>player[k].coords.y-3)
8995 if(player[i].coords.y<player[k].coords.y+3)
8996 if(player[i].coords.x>player[k].coords.x-3)
8997 if(player[i].coords.x<player[k].coords.x+3)
8998 if(player[i].coords.z>player[k].coords.z-3)
8999 if(player[i].coords.z<player[k].coords.z+3)
9000 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)){
9002 if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
9014 above[moving]=stuck;
9015 for(l=0;l<player[moving].skeleton.num_joints;l++){
9016 for(m=0;m<player[stuck].skeleton.num_joints;m++){
9017 while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
9019 player[moving].skeleton.joints[l].position.y+=.003;
9020 if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
9034 if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
9035 texturesizetogglekeydown=0;
9038 for(k=0;k<numplayers;k++){
9039 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9040 if(!isnormal(player[k].coords.x)||!isnormal(player[k].coords.y)||!isnormal(player[k].coords.z)){
9041 player[k].DoDamage(1000);
9046 static bool respawnkeydown;
9047 if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
9048 targetlevel=whichlevel;
9052 if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
9053 if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
9058 if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
9060 if(targetlevel>numchallengelevels-1)targetlevel=0;
9063 slomotogglekeydown=1;
9067 if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
9069 OPENAL_SetPaused(channels[whooshsound], true);
9071 for(k=0;k<numplayers;k++){
9074 player[k].permanentdamage=0;
9075 if(player[k].skeleton.free==2)player[k].skeleton.free=1;
9076 player[k].aitype=passivetype;
9078 player[0].aitype=playercontrolled;
9082 static bool movekey;
9083 static bool connected;
9084 /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
9085 player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
9086 player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
9087 player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
9088 player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
9089 player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
9091 //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
9093 for(int i=0;i<numplayers;i++){
9094 if(!player[i].skeleton.free){
9095 oldtargetrotation=player[i].targetrotation;
9096 if(i==0&&indialogue==-1){
9097 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){
9098 if(!cameramode)player[0].targetrotation=-rotation+180;
9099 if(cameramode)player[0].targetrotation=0;
9105 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9106 if(cameramode){facing=flatfacing;}
9108 facing=DoRotation(facing,-rotation2,0,0);
9109 facing=DoRotation(facing,0,0-rotation,0);
9112 player[0].lookrotation=-rotation;
9114 player[i].targetheadrotation=rotation;
9115 player[i].targetheadrotation2=rotation2;
9117 if(i!=0&&player[i].aitype==playercontrolled&&indialogue==-1){
9118 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){
9119 player[i].targetrotation=-player[i].lookrotation+180;
9125 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
9127 facing=DoRotation(facing,-player[i].lookrotation2,0,0);
9128 facing=DoRotation(facing,0,0-player[i].lookrotation,0);
9130 player[i].targetheadrotation=player[i].lookrotation;
9131 player[i].targetheadrotation2=player[i].lookrotation2;
9134 rotatetarget=participantfacing[whichdialogue][indialogue][i];
9135 Normalise(&rotatetarget);
9136 player[i].targetheadrotation=-asin(0-rotatetarget.x);
9137 player[i].targetheadrotation*=360/6.28;
9138 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
9140 player[i].targetheadrotation*=-1;
9141 player[i].targetheadrotation+=180;
9142 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
9150 player[i].avoidsomething=0;
9152 for(j=0;j<objects.numobjects;j++){
9153 if(objects.onfire[j]){
9154 if(findDistancefast(&objects.position[j],&player[i].coords)<objects.scale[j]*objects.scale[j]*200)
9156 if(findDistancefast(&player[i].coords,&objects.position[j])<findDistancefast(&player[i].coords,&player[0].coords)){
9157 player[i].collided=0;
9158 player[i].avoidcollided=1;
9159 if(player[i].avoidsomething==0||findDistancefast(&objects.position[j],&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9160 player[i].avoidwhere=objects.position[j];
9166 //Add avoidwhere to players
9168 for(j=0;j<numplayers;j++){
9169 if(player[j].onfire){
9170 if(findDistancefast(&player[j].coords,&player[i].coords)<0.3*0.3*200)
9172 if(findDistancefast(&player[i].coords,&player[j].coords)<findDistancefast(&player[i].coords,&player[0].coords)){
9173 player[i].collided=0;
9174 player[i].avoidcollided=1;
9175 if(player[i].avoidsomething==0||findDistancefast(&player[j].coords,&player[i].coords)<findDistancefast(&player[i].coords,&player[i].avoidwhere))
9176 player[i].avoidwhere=objects.position[j];
9182 if(player[i].collided>.8)player[i].avoidcollided=0;
9183 if(player[i].aitype!=playercontrolled&&indialogue==-1){
9184 player[i].jumpclimb=0;
9186 if(editorenabled)player[i].stunned=1;
9189 //if(findDistancefastflat(&player[i].coords,&player[0].coords)<3/*&&player[0].coords.y>player[i].coords.y+.1*/)player[i].pause=1;
9190 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;
9192 /*if(player[i].aitype==passivetype&&player[i].numwaypoints<=1){
9193 player[i].forwardkeydown=0;
9194 player[i].leftkeydown=0;
9195 player[i].backkeydown=0;
9196 player[i].rightkeydown=0;
9197 player[i].crouchkeydown=0;
9198 player[i].attackkeydown=0;
9199 player[i].jumpkeydown=0;
9200 player[i].throwkeydown=0;
9203 if(player[i].aitype==pathfindtype){
9204 if(player[i].finalpathfindpoint==-1){
9205 float closestdistance;
9211 for(j=0;j<numpathpoints;j++){
9212 if(closest==-1||findDistancefast(&player[i].finalfinaltarget,&pathpoint[j])<closestdistance){
9213 closestdistance=findDistancefast(&player[i].finalfinaltarget,&pathpoint[j]);
9215 player[i].finaltarget=pathpoint[j];
9218 player[i].finalpathfindpoint=closest;
9219 for(j=0;j<numpathpoints;j++){
9220 if(numpathpointconnect[j])
9221 for(k=0;k<numpathpointconnect[j];k++){
9222 DistancePointLine(&player[i].finalfinaltarget, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9223 if(tempdist*tempdist<closestdistance){
9224 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9225 closestdistance=tempdist*tempdist;
9227 player[i].finaltarget=colpoint;
9232 player[i].finalpathfindpoint=closest;
9235 if(player[i].targetpathfindpoint==-1){
9236 float closestdistance;
9242 if(player[i].lastpathfindpoint==-1){
9243 for(j=0;j<numpathpoints;j++){
9244 if(j!=player[i].lastpathfindpoint)
9245 if(closest==-1||(findDistancefast(&player[i].coords,&pathpoint[j])<closestdistance/*&&findDistancefast(&player[i].finaltarget,&pathpoint[j])<findDistancefast(&player[i].finaltarget,&player[i].coords)*/)){
9246 closestdistance=findDistancefast(&player[i].coords,&pathpoint[j]);
9250 player[i].targetpathfindpoint=closest;
9251 for(j=0;j<numpathpoints;j++){
9252 if(j!=player[i].lastpathfindpoint)
9253 if(numpathpointconnect[j])
9254 for(k=0;k<numpathpointconnect[j];k++){
9255 DistancePointLine(&player[i].coords, &pathpoint[j], &pathpoint[pathpointconnect[j][k]], &tempdist,&colpoint );
9256 if(tempdist*tempdist<closestdistance){
9257 if(findDistance(&colpoint,&pathpoint[j])+findDistance(&colpoint,&pathpoint[pathpointconnect[j][k]])<findDistance(&pathpoint[j],&pathpoint[pathpointconnect[j][k]])+.1){
9258 //if(findDistancefast(&player[i].finaltarget,&colpoint)<findDistancefast(&player[i].finaltarget,&player[i].coords)){
9259 closestdistance=tempdist*tempdist;
9266 player[i].targetpathfindpoint=closest;
9270 for(j=0;j<numpathpoints;j++){
9271 if(j!=player[i].lastpathfindpoint&&j!=player[i].lastpathfindpoint2&&j!=player[i].lastpathfindpoint3&&j!=player[i].lastpathfindpoint4)
9274 if(numpathpointconnect[j])
9275 for(k=0;k<numpathpointconnect[j];k++){
9276 if(pathpointconnect[j][k]==player[i].lastpathfindpoint)connected=1;
9279 if(numpathpointconnect[player[i].lastpathfindpoint])
9280 for(k=0;k<numpathpointconnect[player[i].lastpathfindpoint];k++){
9281 if(pathpointconnect[player[i].lastpathfindpoint][k]==j)connected=1;
9284 tempdist=findPathDist(j,player[i].finalpathfindpoint);
9285 if(closest==-1||tempdist<closestdistance){
9286 closestdistance=tempdist;
9292 player[i].targetpathfindpoint=closest;
9295 player[i].losupdatedelay-=multiplier;
9297 rotatetarget=pathpoint[player[i].targetpathfindpoint]-player[i].coords;
9298 Normalise(&rotatetarget);
9299 player[i].targetrotation=-asin(0-rotatetarget.x);
9300 player[i].targetrotation*=360/6.28;
9301 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9302 player[i].lookrotation=player[i].targetrotation;
9303 //player[i].aiupdatedelay=.05;
9305 if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){
9306 player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9307 player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9308 player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9309 player[i].lastpathfindpoint=player[i].targetpathfindpoint;
9310 if(player[i].lastpathfindpoint2==-1)player[i].lastpathfindpoint2=player[i].lastpathfindpoint;
9311 if(player[i].lastpathfindpoint3==-1)player[i].lastpathfindpoint3=player[i].lastpathfindpoint2;
9312 if(player[i].lastpathfindpoint4==-1)player[i].lastpathfindpoint4=player[i].lastpathfindpoint3;
9313 player[i].targetpathfindpoint=-1;
9315 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){
9316 player[i].aitype=passivetype;
9319 player[i].forwardkeydown=1;
9320 player[i].leftkeydown=0;
9321 player[i].backkeydown=0;
9322 player[i].rightkeydown=0;
9323 player[i].crouchkeydown=0;
9324 player[i].attackkeydown=0;
9325 player[i].throwkeydown=0;
9327 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9329 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9330 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9332 if((tutoriallevel!=1||cananger)&&hostile&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9333 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))
9334 player[i].aitype=attacktypecutoff;
9335 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9336 player[i].aitype=attacktypecutoff;
9338 if(player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9339 player[i].losupdatedelay=.2;
9340 for(j=0;j<numplayers;j++){
9341 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9342 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9343 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9344 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9345 if(player[j].coords.y<player[i].coords.y+5||player[j].onterrain)
9346 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)){
9347 player[i].aitype=searchtype;
9348 player[i].lastchecktime=12;
9349 player[i].lastseen=player[j].coords;
9350 player[i].lastseentime=12;
9356 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9357 if(player[i].creature!=wolftype){
9358 player[i].stunned=.6;
9359 player[i].surprised=.6;
9364 if(player[i].aitype!=passivetype&&leveltime>.5){
9365 player[i].howactive=typeactive;
9368 if(player[i].aitype==passivetype){
9369 player[i].aiupdatedelay-=multiplier;
9370 player[i].losupdatedelay-=multiplier;
9371 player[i].lastseentime+=multiplier;
9372 player[i].pausetime-=multiplier;
9373 if(player[i].lastseentime>1)player[i].lastseentime=1;
9375 if(player[i].aiupdatedelay<0){
9376 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0){
9377 rotatetarget=player[i].waypoints[player[i].waypoint]-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;
9385 if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){
9386 if(player[i].waypointtype[player[i].waypoint]==wppause)player[i].pausetime=4;
9387 player[i].waypoint++;
9388 if(player[i].waypoint>player[i].numwaypoints-1)player[i].waypoint=0;
9393 if(player[i].numwaypoints>1&&player[i].howactive==typeactive&&player[i].pausetime<=0)player[i].forwardkeydown=1;
9394 else player[i].forwardkeydown=0;
9395 player[i].leftkeydown=0;
9396 player[i].backkeydown=0;
9397 player[i].rightkeydown=0;
9398 player[i].crouchkeydown=0;
9399 player[i].attackkeydown=0;
9400 player[i].throwkeydown=0;
9402 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9403 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9405 XYZ leftpos,rightpos;
9406 float leftdist,rightdist;
9407 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9408 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9409 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9410 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9411 if(leftdist<rightdist)player[i].targetrotation+=90;
9412 else player[i].targetrotation-=90;
9416 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9417 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9421 if(player[i].howactive<typesleeping)
9422 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9423 for(j=0;j<numenvsounds;j++){
9424 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9425 player[i].aitype=attacktypecutoff;
9429 if(player[i].howactive==typesleeping)
9430 if(numenvsounds>0&&(tutoriallevel!=1||cananger)&&hostile)
9431 for(j=0;j<numenvsounds;j++){
9432 if(envsoundvol[j]>14)
9433 if(findDistancefast(&player[i].coords,&envsound[j])<2*((envsoundvol[j]-14)+(envsoundvol[j]-14)*(player[i].creature==rabbittype)*3)){
9434 player[i].aitype=attacktypecutoff;
9438 if(player[i].aitype!=passivetype){
9439 if(player[i].howactive==typesleeping){
9440 player[i].targetanimation=getupfromfrontanim;
9441 player[i].targetframe=0;
9445 player[i].howactive=typeactive;
9449 if(player[i].howactive<typesleeping&&((tutoriallevel!=1||cananger)&&hostile)&&!player[0].dead&&findDistancefast(&player[i].coords,&player[0].coords)<400&&player[i].occluded<25){
9450 if(findDistancefast(&player[i].coords,&player[0].coords)<12&&animation[player[0].targetanimation].height!=lowheight&&!editorenabled)
9451 player[i].aitype=attacktypecutoff;
9452 if(findDistancefast(&player[i].coords,&player[0].coords)<30&&animation[player[0].targetanimation].height==highheight&&!editorenabled)
9453 player[i].aitype=attacktypecutoff;
9455 if(player[i].creature==wolftype){
9457 float smelldistance;
9459 for(j=0;j<numplayers;j++){
9460 if(j==0||(player[j].dead&&player[j].bloodloss>0)){
9461 if(j==0&&player[j].num_weapons>0){
9462 if(weapons.bloody[player[j].weaponids[0]])smelldistance=100;
9463 if(player[j].num_weapons==2)
9464 if(weapons.bloody[player[j].weaponids[1]])smelldistance=100;
9469 windsmell=windvector;
9470 Normalise(&windsmell);
9471 windsmell=windsmell*2+player[j].coords;
9472 if(findDistancefast(&player[i].coords,&windsmell)<smelldistance&&!editorenabled)
9473 player[i].aitype=attacktypecutoff;
9478 if(player[i].howactive<typesleeping&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2){
9479 player[i].losupdatedelay=.2;
9480 for(j=0;j<numplayers;j++){
9481 if(j==0||player[j].skeleton.free||player[j].aitype!=passivetype){
9482 if(abs(Random()%2)||animation[player[j].targetanimation].height!=lowheight||j!=0)
9483 if(findDistancefast(&player[i].coords,&player[j].coords)<400)
9484 if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0)
9485 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)){
9486 player[i].lastseentime-=.2;
9487 if(j==0&&animation[player[j].targetanimation].height==lowheight)player[i].lastseentime-=.4;
9488 else player[i].lastseentime-=.6;
9490 if(player[i].lastseentime<=0){
9491 player[i].aitype=searchtype;
9492 player[i].lastchecktime=12;
9493 player[i].lastseen=player[j].coords;
9494 player[i].lastseentime=12;
9500 if(player[i].aitype==attacktypecutoff&&musictype!=2){
9501 if(player[i].creature!=wolftype){
9502 player[i].stunned=.6;
9503 player[i].surprised=.6;
9505 if(player[i].creature==wolftype){
9506 player[i].stunned=.47;
9507 player[i].surprised=.47;
9513 if(player[i].aitype==searchtype){
9514 player[i].aiupdatedelay-=multiplier;
9515 player[i].losupdatedelay-=multiplier;
9516 if(!player[i].pause)player[i].lastseentime-=multiplier;
9517 player[i].lastchecktime-=multiplier;
9519 if(player[i].isRun()&&!player[i].onground){
9520 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9521 test2=player[i].coords+player[i].facing;
9523 test=player[i].coords+player[i].facing;
9525 j=checkcollide(test2,test,player[i].laststanding);
9526 if(j==-1)j=checkcollide(test2,test);
9528 player[i].velocity=0;
9529 player[i].targetanimation=player[i].getStop();
9530 player[i].targetframe=0;
9532 player[i].targetrotation+=180;
9533 player[i].stunned=.5;
9534 //player[i].aitype=passivetype;
9535 player[i].aitype=pathfindtype;
9536 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9537 player[i].finalpathfindpoint=-1;
9538 player[i].targetpathfindpoint=-1;
9539 player[i].lastpathfindpoint=-1;
9540 player[i].lastpathfindpoint2=-1;
9541 player[i].lastpathfindpoint3=-1;
9542 player[i].lastpathfindpoint4=-1;
9544 else player[i].laststanding=j;
9547 if(player[i].aiupdatedelay<0){
9548 rotatetarget=player[i].lastseen-player[i].coords;
9549 Normalise(&rotatetarget);
9550 player[i].targetrotation=-asin(0-rotatetarget.x);
9551 player[i].targetrotation*=360/6.28;
9552 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9553 player[i].lookrotation=player[i].targetrotation;
9554 player[i].aiupdatedelay=.05;
9555 player[i].forwardkeydown=1;
9557 if(findDistancefastflat(&player[i].coords,&player[i].lastseen)<1*(player[i].scale*5)*(player[i].scale*5)||player[i].lastchecktime<0){
9558 player[i].forwardkeydown=0;
9559 player[i].aiupdatedelay=1;
9560 player[i].lastseen.x+=(float(Random()%100)-50)/25;
9561 player[i].lastseen.z+=(float(Random()%100)-50)/25;
9562 player[i].lastchecktime=3;
9565 player[i].leftkeydown=0;
9566 player[i].backkeydown=0;
9567 player[i].rightkeydown=0;
9568 player[i].crouchkeydown=0;
9569 player[i].attackkeydown=0;
9570 player[i].throwkeydown=0;
9572 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9573 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9575 XYZ leftpos,rightpos;
9576 float leftdist,rightdist;
9577 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9578 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9579 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9580 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9581 if(leftdist<rightdist)player[i].targetrotation+=90;
9582 else player[i].targetrotation-=90;
9586 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9587 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9589 if(numenvsounds>0&&((tutoriallevel!=1||cananger)&&hostile))
9590 for(j=0;j<numenvsounds;j++){
9591 if(findDistancefast(&player[i].coords,&envsound[j])<2*(envsoundvol[j]+envsoundvol[j]*(player[i].creature==rabbittype)*3)){
9592 player[i].aitype=attacktypecutoff;
9596 if(!player[0].dead&&player[i].losupdatedelay<0&&!editorenabled&&player[i].occluded<2&&((tutoriallevel!=1||cananger)&&hostile)){
9597 player[i].losupdatedelay=.2;
9598 if(findDistancefast(&player[i].coords,&player[0].coords)<4&&animation[player[i].targetanimation].height!=lowheight)
9599 {player[i].aitype=attacktypecutoff;
9600 player[i].lastseentime=1;}
9601 if(abs(Random()%2)||animation[player[i].targetanimation].height!=lowheight)
9602 if(findDistancefast(&player[i].coords,&player[0].coords)<400)
9603 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9604 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)){
9605 player[i].aitype=attacktypecutoff;
9606 player[i].lastseentime=1;
9609 if(player[i].lastseentime<0){
9610 //player[i].aitype=passivetype;
9612 player[i].aitype=pathfindtype;
9613 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9614 player[i].finalpathfindpoint=-1;
9615 player[i].targetpathfindpoint=-1;
9616 player[i].lastpathfindpoint=-1;
9617 player[i].lastpathfindpoint2=-1;
9618 player[i].lastpathfindpoint3=-1;
9619 player[i].lastpathfindpoint4=-1;
9623 if(player[i].aitype!=gethelptype){
9624 player[i].runninghowlong=0;
9627 if(player[i].aitype==gethelptype){
9628 player[i].runninghowlong+=multiplier;
9629 player[i].aiupdatedelay-=multiplier;
9631 if(player[i].aiupdatedelay<0||player[i].ally==0){
9632 player[i].aiupdatedelay=.2;
9640 if(!player[i].ally){
9641 for(j=0;j<numplayers;j++){
9642 if(j!=i&&j!=0&&!player[j].dead&&player[j].howactive<typedead1&&!player[j].skeleton.free&&player[j].aitype==passivetype){
9643 distance=findDistancefast(&player[i].coords,&player[j].coords);
9644 if(closestdist==-1||distance<closestdist){
9645 closestdist=distance;
9651 if(closest!=-1)player[i].ally=closest;
9652 else player[i].ally=0;
9653 player[i].lastseen=player[0].coords;
9654 player[i].lastseentime=12;
9658 player[i].lastchecktime=12;
9659 //player[i].lastseentime-=.5;
9661 facing=player[i].coords;
9662 flatfacing=player[player[i].ally].coords;
9663 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9664 flatfacing.y+=player[player[i].ally].skeleton.joints[player[player[i].ally].skeleton.jointlabels[head]].position.y*player[player[i].ally].scale;
9665 if(-1!=checkcollide(facing,flatfacing))
9666 player[i].lastseentime-=.1;
9668 if(player[i].ally<=0||player[player[i].ally].skeleton.free||player[player[i].ally].aitype!=passivetype||player[i].lastseentime<=0){
9669 player[i].aitype=searchtype;
9670 player[i].lastseentime=12;
9673 if(player[i].ally>0){
9674 rotatetarget=player[player[i].ally].coords-player[i].coords;
9675 Normalise(&rotatetarget);
9676 player[i].targetrotation=-asin(0-rotatetarget.x);
9677 player[i].targetrotation*=360/6.28;
9678 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9679 player[i].lookrotation=player[i].targetrotation;
9680 player[i].aiupdatedelay=.05;
9681 player[i].forwardkeydown=1;
9683 if(findDistancefastflat(&player[i].coords,&player[player[i].ally].coords)<3){
9684 player[i].aitype=searchtype;
9685 player[i].lastseentime=12;
9686 player[player[i].ally].aitype=searchtype;
9687 if(player[player[i].ally].lastseentime<player[i].lastseentime){
9688 player[player[i].ally].lastseen=player[i].lastseen;
9689 player[player[i].ally].lastseentime=player[i].lastseentime;
9690 player[player[i].ally].lastchecktime=player[i].lastchecktime;
9694 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9695 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9697 XYZ leftpos,rightpos;
9698 float leftdist,rightdist;
9699 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9700 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9701 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9702 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9703 if(leftdist<rightdist)player[i].targetrotation+=90;
9704 else player[i].targetrotation-=90;
9709 player[i].leftkeydown=0;
9710 player[i].backkeydown=0;
9711 player[i].rightkeydown=0;
9712 player[i].crouchkeydown=0;
9713 player[i].attackkeydown=0;
9715 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9716 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9719 if(player[i].aitype==getweapontype){
9720 player[i].aiupdatedelay-=multiplier;
9721 player[i].lastchecktime-=multiplier;
9723 if(player[i].aiupdatedelay<0){
9724 player[i].aiupdatedelay=.2;
9732 if(player[i].ally<0){
9733 for(j=0;j<weapons.numweapons;j++){
9734 if(weapons.owner[j]==-1){
9735 distance=findDistancefast(&player[i].coords,&weapons.position[j]);
9736 if(closestdist==-1||distance<closestdist){
9737 closestdist=distance;
9743 if(closest!=-1)player[i].ally=closest;
9744 else player[i].ally=-1;
9747 player[i].lastseentime=12;
9749 if(!player[0].dead&&((tutoriallevel!=1||cananger)&&hostile))
9750 if(player[i].ally<0||player[i].weaponactive!=-1||player[i].lastchecktime<=0){
9751 player[i].aitype=attacktypecutoff;
9752 player[i].lastseentime=1;
9755 if(player[i].ally>=0){
9756 if(weapons.owner[player[i].ally]!=-1||findDistancefast(&player[i].coords,&weapons.position[player[i].ally])>16){
9757 player[i].aitype=attacktypecutoff;
9758 player[i].lastseentime=1;
9760 rotatetarget=weapons.position[player[i].ally]-player[i].coords;
9761 Normalise(&rotatetarget);
9762 player[i].targetrotation=-asin(0-rotatetarget.x);
9763 player[i].targetrotation*=360/6.28;
9764 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9765 player[i].lookrotation=player[i].targetrotation;
9766 player[i].aiupdatedelay=.05;
9767 player[i].forwardkeydown=1;
9770 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){
9771 if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9773 XYZ leftpos,rightpos;
9774 float leftdist,rightdist;
9775 leftpos = player[i].coords+DoRotation(player[i].facing,0,90,0);
9776 rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0);
9777 leftdist = findDistancefast(&leftpos, &player[i].avoidwhere);
9778 rightdist = findDistancefast(&rightpos, &player[i].avoidwhere);
9779 if(leftdist<rightdist)player[i].targetrotation+=90;
9780 else player[i].targetrotation-=90;
9783 /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
9784 if(abs(Random()%6)){
9785 player[i].crouchkeydown=1;
9786 if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
9787 if(player[i].isRun()){
9788 player[i].targetframe=0;
9790 player[i].targetanimation=sneakanim;
9793 else player[i].forwardkeydown=0;
9795 else player[i].crouchkeydown=0;
9797 else player[i].crouchkeydown=0;*/
9800 player[i].leftkeydown=0;
9801 player[i].backkeydown=0;
9802 player[i].rightkeydown=0;
9803 player[i].attackkeydown=0;
9804 player[i].throwkeydown=1;
9805 player[i].crouchkeydown=0;
9806 if(player[i].targetanimation!=crouchremoveknifeanim&&player[i].targetanimation!=removeknifeanim)player[i].throwtogglekeydown=0;
9807 player[i].drawkeydown=0;
9809 if(player[i].collided<1||player[i].targetanimation!=jumpupanim)player[i].jumpkeydown=0;
9810 if((player[i].collided>.8&&player[i].jumppower>=5))player[i].jumpkeydown=1;
9813 if(player[i].aitype==attacktypecutoff){
9814 player[i].aiupdatedelay-=multiplier;
9815 if(player[i].damage<player[i].damagetolerance*2/3)
9816 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)){
9817 player[i].attackkeydown=0;
9818 if(player[i].isIdle())player[i].crouchkeydown=1;
9819 if(player[0].targetanimation!=rabbitkickanim&&player[0].weaponactive!=-1){
9820 if(weapons.type[player[0].weaponids[0]]==knife){
9821 if(player[i].isIdle()||player[i].isCrouch()||player[i].isRun()||player[i].isFlip()){
9822 if(abs(Random()%2==0))player[i].targetanimation=backhandspringanim;
9823 else player[i].targetanimation=rollanim;
9825 player[i].targetframe=0;
9826 player[i].targetrotation+=90*(abs(Random()%2)*2-1);
9827 player[i].wentforweapon=0;
9829 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim){
9830 player[i].targetanimation=flipanim;
9832 player[i].targetframe=0;
9836 player[i].forwardkeydown=0;
9837 player[i].aiupdatedelay=.02;
9839 if(player[0].isFlip()&&!player[0].skeleton.free&&player[0].targetanimation!=walljumprightkickanim&&player[0].targetanimation!=walljumpleftkickanim){
9840 if(findDistancefast(&player[0].coords,&player[i].coords)<25)
9841 if((1-player[i].damage/player[i].damagetolerance)>.5)player[i].stunned=1;
9843 if(player[i].wentforweapon<3)
9844 for(j=0;j<weapons.numweapons;j++){
9845 if(player[i].creature!=wolftype)
9846 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){
9847 if(findDistancefast(&player[i].coords,&weapons.position[j])<16){
9848 player[i].wentforweapon++;
9849 player[i].lastchecktime=6;
9850 player[i].aitype=getweapontype;
9855 if(player[i].damage<player[i].damagetolerance/2)
9856 if(animation[player[i].targetanimation].height!=highheight)
9857 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)))){
9858 player[i].crouchkeydown=1;
9860 if(player[i].isRun()&&!player[i].onground){
9861 if(player[i].coords.y>terrain.getHeight(player[i].coords.x,player[i].coords.z)+10){
9862 test2=player[i].coords+player[i].facing;
9864 test=player[i].coords+player[i].facing;
9866 j=checkcollide(test2,test,player[i].laststanding);
9867 if(j==-1)j=checkcollide(test2,test);
9869 player[i].velocity=0;
9870 player[i].targetanimation=player[i].getStop();
9871 player[i].targetframe=0;
9873 player[i].targetrotation+=180;
9874 player[i].stunned=.5;
9875 //player[i].aitype=passivetype;
9876 player[i].aitype=pathfindtype;
9877 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9878 player[i].finalpathfindpoint=-1;
9879 player[i].targetpathfindpoint=-1;
9880 player[i].lastpathfindpoint=-1;
9881 player[i].lastpathfindpoint2=-1;
9882 player[i].lastpathfindpoint3=-1;
9883 player[i].lastpathfindpoint4=-1;
9885 else player[i].laststanding=j;
9888 if(player[0].coords.y>player[i].coords.y+5&&animation[player[0].targetanimation].height!=highheight&&!player[0].onterrain){
9889 player[i].aitype=pathfindtype;
9890 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9891 player[i].finalpathfindpoint=-1;
9892 player[i].targetpathfindpoint=-1;
9893 player[i].lastpathfindpoint=-1;
9894 player[i].lastpathfindpoint2=-1;
9895 player[i].lastpathfindpoint3=-1;
9896 player[i].lastpathfindpoint4=-1;
9898 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){
9899 if(player[i].weaponactive==-1&&player[i].num_weapons>0)player[i].drawkeydown=Random()%2;
9900 else player[i].drawkeydown=0;
9901 player[i].rabbitkickenabled=Random()%2;
9902 rotatetarget=player[player[i].aitarget].coords+player[player[i].aitarget].velocity;
9903 if(findDistancefast(&player[player[i].aitarget].coords,&player[i].coords)<findDistancefast(&rotatetarget,&player[i].coords))
9904 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;
9905 else rotatetarget=player[player[i].aitarget].coords-player[i].coords;
9906 Normalise(&rotatetarget);
9907 player[i].targetrotation=-asin(0-rotatetarget.x);
9908 player[i].targetrotation*=360/6.28;
9909 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
9910 player[i].lookrotation=player[i].targetrotation;
9911 player[i].aiupdatedelay=.2+abs((float)(Random()%100)/1000);
9913 oldkey=player[i].forwardkeydown;
9914 if(findDistancefast(&player[i].coords,&player[0].coords)>5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1))player[i].forwardkeydown=1;
9915 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;
9916 else if(Random()%6==0||(player[i].creature==wolftype&&Random()%3==0))player[i].forwardkeydown=1;
9917 else player[i].forwardkeydown=0;
9919 player[i].forwardkeydown=0;
9920 if(Random()%10==0)player[i].forwardkeydown=1;
9921 if(Random()%100==0){
9922 player[i].aitype=pathfindtype;
9923 player[i].finalfinaltarget=player[i].waypoints[player[i].waypoint];
9924 player[i].finalpathfindpoint=-1;
9925 player[i].targetpathfindpoint=-1;
9926 player[i].lastpathfindpoint=-1;
9927 player[i].lastpathfindpoint2=-1;
9928 player[i].lastpathfindpoint3=-1;
9929 player[i].lastpathfindpoint4=-1;
9932 player[i].leftkeydown=0;
9933 player[i].backkeydown=0;
9934 player[i].rightkeydown=0;
9935 player[i].crouchkeydown=0;
9936 player[i].throwkeydown=0;
9938 if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
9939 /*for(j=0;j<numplayers;j++){
9940 if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
9941 player[i].crouchkeydown=1;
9944 if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
9945 else player[i].attackkeydown=0;
9946 if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
9947 //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
9948 /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
9949 player[i].attackkeydown=0;
9950 if(player[i].isIdle())player[i].crouchkeydown=1;
9951 player[i].forwardkeydown=0;
9952 player[i].aiupdatedelay=.02;
9955 if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
9957 for(j=0;j<numplayers;j++){
9958 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)){
9959 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))))){
9960 if(target>=0)target=-1;
9965 if(target>=0)player[target].Reverse();
9968 if(player[i].collided<1)player[i].jumpkeydown=0;
9969 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;
9970 if(normaldotproduct(player[i].facing,player[0].coords-player[i].coords)>0)
9971 player[0].jumpkeydown=0;
9972 if(player[0].targetanimation==jumpdownanim&&findDistancefast(&player[0].coords,&player[i].coords)<40)player[i].crouchkeydown=1;
9973 if(player[i].jumpkeydown)player[i].attackkeydown=0;
9974 //if(animation[player[i].targetanimation].attack==reversed)player[i].crouchkeydown=1;
9976 if(tutoriallevel==1){
9977 if(!canattack)player[i].attackkeydown=0;
9981 facing=player[i].coords;
9982 flatfacing=player[0].coords;
9983 facing.y+=player[i].skeleton.joints[player[i].skeleton.jointlabels[head]].position.y*player[i].scale;
9984 flatfacing.y+=player[0].skeleton.joints[player[0].skeleton.jointlabels[head]].position.y*player[0].scale;
9985 if(player[i].occluded>=2)
9986 if(-1!=checkcollide(facing,flatfacing)){
9987 if(!player[i].pause)player[i].lastseentime-=.2;
9988 if(player[i].lastseentime<=0&&(player[i].creature!=wolftype||player[i].weaponstuck==-1)){
9989 player[i].aitype=searchtype;
9990 player[i].lastchecktime=12;
9991 player[i].lastseen=player[0].coords;
9992 player[i].lastseentime=12;
9995 else player[i].lastseentime=1;
9998 if(animation[player[0].targetanimation].height==highheight&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype)){
9999 if(player[0].coords.y>terrain.getHeight(player[0].coords.x,player[0].coords.z)+10){
10000 test=player[0].coords;
10002 if(-1==checkcollide(player[0].coords,test))player[i].stunned=1;
10005 // NOTE: Ask about logic of this call : NOTE
10006 if((player[i].aitype==passivetype && !(player[i].numwaypoints>1)) ||
10007 player[i].stunned>0 ||
10008 (player[i].pause && (player[i].damage > player[i].superpermanentdamage)))
10010 if(/*player[i].aitype==attacktypecutoff&&*/player[i].pause)player[i].lastseentime=1;
10011 player[i].targetrotation=player[i].rotation;
10012 player[i].forwardkeydown=0;
10013 player[i].leftkeydown=0;
10014 player[i].backkeydown=0;
10015 player[i].rightkeydown=0;
10016 player[i].jumpkeydown=0;
10017 player[i].attackkeydown=0;
10018 player[i].crouchkeydown=0;
10019 player[i].throwkeydown=0;
10026 flatfacing=DoRotation(facing,0,player[i].rotation+180,0);
10029 if(player[i].aitype==attacktypecutoff){
10030 rotatetarget=player[0].coords-player[i].coords;
10031 Normalise(&rotatetarget);
10032 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10033 player[i].targetheadrotation*=360/6.28;
10034 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10036 player[i].targetheadrotation*=-1;
10037 player[i].targetheadrotation+=180;
10038 //player[i].targetheadrotation2=0;
10039 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10041 else if(player[i].howactive>=typesleeping){
10042 player[i].targetheadrotation=player[i].targetrotation;
10043 player[i].targetheadrotation2=0;
10046 if(player[i].interestdelay<=0){
10047 player[i].interestdelay=.7+(float)(abs(Random()%100))/100;
10048 player[i].headtarget=player[i].coords;
10049 player[i].headtarget.x+=(float)(abs(Random()%200)-100)/100;
10050 player[i].headtarget.z+=(float)(abs(Random()%200)-100)/100;
10051 player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300;
10052 player[i].headtarget+=player[i].facing*1.5;
10054 rotatetarget=player[i].headtarget-player[i].coords;
10055 Normalise(&rotatetarget);
10056 player[i].targetheadrotation=-asin(0-rotatetarget.x);
10057 player[i].targetheadrotation*=360/6.28;
10058 if(rotatetarget.z<0)player[i].targetheadrotation=180-player[i].targetheadrotation;
10060 player[i].targetheadrotation*=-1;
10061 player[i].targetheadrotation+=180;
10062 player[i].targetheadrotation2=-asin(rotatetarget.y)*360/6.28;
10064 //if(whichlevel==2)player[i].jumpkeydown=0;
10066 if(animation[player[i].targetanimation].attack==reversed){
10067 //player[i].targetrotation=player[i].rotation;
10068 player[i].forwardkeydown=0;
10069 player[i].leftkeydown=0;
10070 player[i].backkeydown=0;
10071 player[i].rightkeydown=0;
10072 player[i].jumpkeydown=0;
10073 player[i].attackkeydown=0;
10074 //player[i].crouchkeydown=0;
10075 player[i].throwkeydown=0;
10078 if(indialogue!=-1){
10079 player[i].forwardkeydown=0;
10080 player[i].leftkeydown=0;
10081 player[i].backkeydown=0;
10082 player[i].rightkeydown=0;
10083 player[i].jumpkeydown=0;
10084 player[i].crouchkeydown=0;
10085 player[i].drawkeydown=0;
10086 player[i].throwkeydown=0;
10089 if(player[i].collided<-.3)player[i].collided=-.3;
10090 if(player[i].collided>1)player[i].collided=1;
10091 player[i].collided-=multiplier*4;
10092 player[i].whichdirectiondelay-=multiplier;
10093 if(player[i].avoidcollided<-.3||player[i].whichdirectiondelay<=0){
10094 player[i].avoidcollided=-.3;
10095 player[i].whichdirection=abs(Random()%2);
10096 player[i].whichdirectiondelay=.4;
10098 if(player[i].avoidcollided>1)player[i].avoidcollided=1;
10099 player[i].avoidcollided-=multiplier/4;
10100 if(!player[i].skeleton.free)player[i].stunned-=multiplier;
10101 if(!player[i].skeleton.free)player[i].surprised-=multiplier;
10102 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;
10104 if(!player[i].throwkeydown){
10105 player[i].throwtogglekeydown=0;
10107 if(player[i].throwkeydown&&!player[i].throwtogglekeydown){
10108 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)){
10109 for(j=0;j<weapons.numweapons;j++){
10110 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)
10111 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2){
10112 if(findDistancefast(&player[i].coords,&weapons.position[j])<2){
10113 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].aitype!=playercontrolled){
10114 player[i].throwtogglekeydown=1;
10115 player[i].targetanimation=crouchremoveknifeanim;
10116 player[i].target=0;
10117 player[i].targetframe=0;
10118 rotatetarget=weapons.position[j]-player[i].coords;
10119 Normalise(&rotatetarget);
10120 player[i].targetrotation=-asin(0-rotatetarget.x);
10121 player[i].targetrotation*=360/6.28;
10122 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10123 player[i].hasvictim=0;
10125 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10126 player[i].throwtogglekeydown=1;
10127 player[i].hasvictim=0;
10129 //for(i=0;i<weapons.numweapons;i++){
10130 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))
10131 if(findDistancefastflat(&player[i].coords,&weapons.position[j])<2&&player[i].weaponactive==-1){
10132 if(findDistancefast(&player[i].coords,&weapons.position[j])<1||player[i].victim){
10135 gLoc[0]=player[i].coords.x;
10136 gLoc[1]=player[i].coords.y;
10137 gLoc[2]=player[i].coords.z;
10138 vel[0]=player[i].velocity.x;
10139 vel[1]=player[i].velocity.y;
10140 vel[2]=player[i].velocity.z;
10141 if(weapons.type[j]!=staff){
10142 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10143 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10144 OPENAL_SetVolume(channels[knifedrawsound], 128);
10145 OPENAL_SetPaused(channels[knifedrawsound], false);
10148 player[i].weaponactive=0;
10149 weapons.owner[j]=player[i].id;
10150 if(player[i].num_weapons>0){
10151 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10153 player[i].num_weapons++;
10154 player[i].weaponids[0]=j;
10160 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){
10161 if(!player[i].isFlip()){
10162 player[i].throwtogglekeydown=1;
10163 player[i].targetanimation=removeknifeanim;
10164 player[i].target=0;
10165 player[i].targetframe=0;
10166 rotatetarget=weapons.position[j]-player[i].coords;
10167 Normalise(&rotatetarget);
10168 player[i].targetrotation=-asin(0-rotatetarget.x);
10169 player[i].targetrotation*=360/6.28;
10170 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10172 if(player[i].isFlip()){
10173 player[i].throwtogglekeydown=1;
10174 player[i].hasvictim=0;
10176 for(k=0;k<weapons.numweapons;k++){
10177 if(player[i].weaponactive==-1)
10178 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))
10179 if(findDistancefastflat(&player[i].coords,&weapons.position[k])<3&&player[i].weaponactive==-1){
10182 gLoc[0]=player[i].coords.x;
10183 gLoc[1]=player[i].coords.y;
10184 gLoc[2]=player[i].coords.z;
10185 vel[0]=player[i].velocity.x;
10186 vel[1]=player[i].velocity.y;
10187 vel[2]=player[i].velocity.z;
10188 if(weapons.type[k]!=staff){
10189 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10190 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10191 OPENAL_SetVolume(channels[knifedrawsound], 128);
10192 OPENAL_SetPaused(channels[knifedrawsound], false);
10195 player[i].weaponactive=0;
10196 weapons.owner[k]=player[i].id;
10197 if(player[i].num_weapons>0){
10198 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10200 player[i].num_weapons++;
10201 player[i].weaponids[0]=k;
10208 if(player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isRun()||player[i].isIdle()||player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10210 for(j=0;j<numplayers;j++){
10211 if(player[i].weaponactive==-1)
10213 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)){
10214 if(player[i].targetanimation!=rollanim&&player[i].targetanimation!=backhandspringanim){
10215 player[i].throwtogglekeydown=1;
10216 player[i].victim=&player[j];
10217 player[i].hasvictim=1;
10218 player[i].targetanimation=crouchremoveknifeanim;
10219 player[i].target=0;
10220 player[i].targetframe=0;
10221 rotatetarget=player[j].coords-player[i].coords;
10222 Normalise(&rotatetarget);
10223 player[i].targetrotation=-asin(0-rotatetarget.x);
10224 player[i].targetrotation*=360/6.28;
10225 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10227 if(player[i].targetanimation==rollanim||player[i].targetanimation==backhandspringanim){
10228 player[i].throwtogglekeydown=1;
10229 player[i].victim=&player[j];
10230 player[i].hasvictim=1;
10231 int k = player[j].weaponids[0];
10232 if(player[i].hasvictim){
10235 gLoc[0]=player[i].coords.x;
10236 gLoc[1]=player[i].coords.y;
10237 gLoc[2]=player[i].coords.z;
10238 vel[0]=player[i].velocity.x;
10239 vel[1]=player[i].velocity.y;
10240 vel[2]=player[i].velocity.z;
10243 if(player[i].victim->weaponstuck!=-1){
10244 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10249 if(weapons.type[k]!=staff){
10250 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
10251 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
10252 OPENAL_SetVolume(channels[knifedrawsound], 128);
10253 OPENAL_SetPaused(channels[knifedrawsound], false);
10257 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
10258 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
10259 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
10260 OPENAL_SetPaused(channels[fleshstabremovesound], false);
10263 player[i].weaponactive=0;
10264 if(weapons.owner[k]!=-1){
10265 if(player[i].victim->num_weapons==1)player[i].victim->num_weapons=0;
10266 else player[i].victim->num_weapons=1;
10268 player[i].victim->skeleton.longdead=0;
10269 player[i].victim->skeleton.free=1;
10270 player[i].victim->skeleton.broken=0;
10272 for(int l=0;l<player[i].victim->skeleton.num_joints;l++){
10273 player[i].victim->skeleton.joints[l].velchange=0;
10274 player[i].victim->skeleton.joints[l].locked=0;
10280 Normalise(&relative);
10281 XYZ footvel,footpoint;
10283 footpoint=weapons.position[k];
10284 if(player[i].victim->weaponstuck!=-1){
10285 if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
10286 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
10287 weapons.bloody[k]=2;
10288 weapons.blooddrip[k]=5;
10289 player[i].victim->weaponstuck=-1;
10290 player[i].victim->bloodloss+=2000;
10291 player[i].victim->DoDamage(2000);
10294 if(player[i].victim->num_weapons>0){
10295 if(player[i].victim->weaponstuck!=0&&player[i].victim->weaponstuck!=-1)player[i].victim->weaponstuck=0;
10296 if(player[i].victim->weaponids[0]==k)
10297 player[i].victim->weaponids[0]=player[i].victim->weaponids[player[i].victim->num_weapons];
10300 player[i].victim->weaponactive=-1;
10302 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
10303 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[neck]].velocity+=relative*6;
10304 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
10305 player[i].victim->skeleton.joints[player[i].victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
10307 weapons.owner[k]=i;
10308 if(player[i].num_weapons>0){
10309 player[i].weaponids[player[i].num_weapons]=player[i].weaponids[0];
10311 player[i].num_weapons++;
10312 player[i].weaponids[0]=k;
10319 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10320 if(weapons.type[player[i].weaponids[0]]==knife){
10321 if(player[i].isIdle()||player[i].isRun()||player[i].isCrouch()||player[i].targetanimation==sneakanim||player[i].isFlip())
10323 for(j=0;j<numplayers;j++){
10325 if(tutoriallevel!=1||tutorialstage==49)
10327 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)){
10328 if(!player[i].isFlip()){
10329 player[i].throwtogglekeydown=1;
10330 player[i].victim=&player[j];
10331 player[i].targetanimation=knifethrowanim;
10332 player[i].target=0;
10333 player[i].targetframe=0;
10334 rotatetarget=player[j].coords-player[i].coords;
10335 Normalise(&rotatetarget);
10336 player[i].targetrotation=-asin(0-rotatetarget.x);
10337 player[i].targetrotation*=360/6.28;
10338 if(rotatetarget.z<0)player[i].targetrotation=180-player[i].targetrotation;
10340 player[i].targettilt2=-asin(rotatetarget.y)*360/6.28;
10342 if(player[i].isFlip()){
10343 if(player[i].weaponactive!=-1){
10344 player[i].throwtogglekeydown=1;
10345 player[i].victim=&player[j];
10347 weapons.owner[player[i].weaponids[0]]=-1;
10348 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);
10351 aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0);
10353 weapons.velocity[player[i].weaponids[0]]=aim*50;
10354 weapons.tipvelocity[player[i].weaponids[0]]=aim*50;
10355 weapons.missed[player[i].weaponids[0]]=0;
10356 weapons.freetime[player[i].weaponids[0]]=0;
10357 weapons.firstfree[player[i].weaponids[0]]=1;
10358 weapons.physics[player[i].weaponids[0]]=0;
10359 player[i].num_weapons--;
10360 if(player[i].num_weapons){
10361 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10363 player[i].weaponactive=-1;
10370 if(player[i].weaponactive!=-1&&player[i].aitype==playercontrolled){
10371 if(player[i].isCrouch()||player[i].targetanimation==sneakanim)
10373 player[i].throwtogglekeydown=1;
10374 weapons.owner[player[i].weaponids[0]]=-1;
10375 weapons.velocity[player[i].weaponids[0]]=player[i].velocity*.2;
10376 if(weapons.velocity[player[i].weaponids[0]].x==0)weapons.velocity[player[i].weaponids[0]].x=.1;
10377 weapons.tipvelocity[player[i].weaponids[0]]=weapons.velocity[player[i].weaponids[0]];
10378 weapons.missed[player[i].weaponids[0]]=1;
10379 weapons.freetime[player[i].weaponids[0]]=0;
10380 weapons.firstfree[player[i].weaponids[0]]=1;
10381 weapons.physics[player[i].weaponids[0]]=1;
10382 player[i].num_weapons--;
10383 if(player[i].num_weapons){
10384 player[i].weaponids[0]=player[i].weaponids[player[i].num_weapons];
10385 if(player[i].weaponstuck==player[i].num_weapons)player[i].weaponstuck=0;
10388 player[i].weaponactive=-1;
10389 for(j=0;j<numplayers;j++){
10390 player[j].wentforweapon=0;
10397 if(i==0||!player[0].dead||player[i].weaponactive!=-1)
10398 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)){
10399 //Setenvironment(1-environment);
10402 if(player[i].weaponactive!=-1){
10403 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==staff)isgood=0;
10405 if(/*(player[i].weaponactive==-1||player[i].num_weapons==1)&&*/isgood&&player[i].creature!=wolftype){
10406 if(player[i].isIdle()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10407 player[i].targetanimation=drawrightanim;
10408 player[i].targetframe=0;
10409 player[i].target=0;
10410 player[i].drawtogglekeydown=1;
10412 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){
10413 player[i].targetanimation=drawleftanim;
10414 player[i].targetframe=0;
10415 player[i].target=0;
10416 player[i].drawtogglekeydown=1;
10418 if(player[i].isCrouch()&&player[i].num_weapons&&weapons.type[player[i].weaponids[0]]==knife){
10419 player[i].targetanimation=crouchdrawrightanim;
10420 player[i].targetframe=0;
10421 player[i].target=0;
10422 player[i].drawtogglekeydown=1;
10426 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){
10427 if(weapons.bloody[player[i].weaponids[player[i].weaponactive]]&&player[i].onterrain&&bloodtoggle&&musictype!=stream_music2){
10428 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==knife)player[i].targetanimation=crouchstabanim;
10429 if(weapons.type[player[i].weaponids[player[i].weaponactive]]==sword)player[i].targetanimation=swordgroundstabanim;
10430 player[i].targetframe=0;
10431 player[i].target=0;
10432 player[i].hasvictim=0;
10433 //player[i].attacktogglekeydown=1;
10437 if(!player[i].drawkeydown){
10438 player[i].drawtogglekeydown=0;
10443 absflatfacing.z=-1;
10445 absflatfacing=DoRotation(absflatfacing,0,-rotation,0);
10447 else absflatfacing=flatfacing;
10449 if(indialogue!=-1){
10450 player[i].forwardkeydown=0;
10451 player[i].leftkeydown=0;
10452 player[i].backkeydown=0;
10453 player[i].rightkeydown=0;
10454 player[i].jumpkeydown=0;
10455 player[i].crouchkeydown=0;
10456 player[i].drawkeydown=0;
10457 player[i].throwkeydown=0;
10461 if(!animation[player[i].targetanimation].attack&&player[i].targetanimation!=staggerbackhighanim&&player[i].targetanimation!=staggerbackhardanim&&player[i].targetanimation!=backhandspringanim&&player[i].targetanimation!=dodgebackanim){
10462 if(!player[i].forwardkeydown){
10463 player[i].forwardstogglekeydown=0;
10465 if(player[i].crouchkeydown){
10469 player[i].superruntoggle=1;
10471 for(j=0;j<numplayers;j++){
10472 if(j!=i&&!player[j].skeleton.free&&player[j].aitype==passivetype){
10473 if(findDistancefast(&player[j].coords,&player[i].coords)<16){
10474 player[i].superruntoggle=0;
10481 for(j=0;j<numplayers;j++){
10482 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].lowreversaldelay<=0){
10483 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))){
10484 if(target>=0)target=-1;
10489 if(target>=0)player[target].Reverse();
10490 player[i].lowreversaldelay=.5;
10492 if(player[i].isIdle()){
10493 player[i].targetanimation=player[i].getCrouch();
10494 player[i].target=0;
10495 player[i].targetframe=0;
10496 player[i].transspeed=10;
10498 if(player[i].isRun()||(player[i].isStop()&&(player[i].leftkeydown||player[i].rightkeydown||player[i].forwardkeydown||player[i].backkeydown))){
10499 player[i].targetanimation=rollanim;
10500 player[i].target=0;
10501 player[i].targetframe=0;
10502 player[i].transspeed=20;
10505 if(!player[i].crouchkeydown){
10507 if(!player[i].isRun()&&player[i].targetanimation!=sneakanim&&i==0)player[i].superruntoggle=0;
10509 if(player[i].isCrouch()){
10511 for(j=0;j<numplayers;j++){
10512 if(j!=i&&!player[j].skeleton.free&&player[j].victim&&player[i].highreversaldelay<=0){
10513 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==spinkickanim)&&player[i].isCrouch()){
10514 if(target>=0)target=-1;
10519 if(target>=0)player[target].Reverse();
10520 player[i].highreversaldelay=.5;
10522 if(player[i].isCrouch()){
10523 if(!player[i].wasCrouch()){
10524 player[i].currentanimation=player[i].getCrouch();
10525 player[i].currentframe=0;
10527 player[i].target=0;
10528 player[i].targetanimation=player[i].getIdle();
10529 player[i].targetframe=0;
10530 player[i].transspeed=10;
10533 if(player[i].targetanimation==sneakanim){
10534 player[i].targetanimation=player[i].getIdle();
10535 player[i].target=0;
10536 player[i].targetframe=0;
10537 player[i].transspeed=10;
10540 if(player[i].forwardkeydown){
10541 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)){
10542 if(player[i].aitype==passivetype)player[i].targetanimation=walkanim;
10543 else player[i].targetanimation=player[i].getRun();
10544 player[i].target=0;
10545 player[i].targetframe=0;
10547 if(player[i].isCrouch()){
10548 player[i].targetanimation=sneakanim;
10549 if(player[i].wasCrouch())player[i].target=0;
10550 player[i].targetframe=0;
10552 if(player[i].targetanimation==hanganim/*&&(!player[i].forwardstogglekeydown||player[i].aitype!=playercontrolled)*/){
10553 player[i].targetanimation=climbanim;
10554 player[i].target=0;
10555 player[i].targetframe=1;
10556 player[i].jumpclimb=1;
10558 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10559 player[i].velocity+=absflatfacing*5*multiplier;
10561 player[i].forwardstogglekeydown=1;
10564 if (player[i].rightkeydown){
10565 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)){
10566 player[i].targetanimation=player[i].getRun();
10567 player[i].target=0;
10568 player[i].targetframe=0;
10570 if(player[i].isCrouch()){
10571 player[i].targetanimation=sneakanim;
10572 if(player[i].wasCrouch()) player[i].target=0;
10573 player[i].targetframe=0;
10575 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10576 player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10578 player[i].targetrotation-=90;
10579 if(player[i].forwardkeydown)player[i].targetrotation+=45;
10580 if(player[i].backkeydown)player[i].targetrotation-=45;
10583 if ( player[i].leftkeydown){
10584 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)){
10585 player[i].targetanimation=player[i].getRun();
10586 player[i].target=0;
10587 player[i].targetframe=0;
10589 if(player[i].isCrouch()){
10590 player[i].targetanimation=sneakanim;
10591 if(player[i].wasCrouch())player[i].target=0;
10592 player[i].targetframe=0;
10594 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10595 player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0);
10597 player[i].targetrotation+=90;
10598 if(player[i].forwardkeydown)player[i].targetrotation-=45;
10599 if(player[i].backkeydown)player[i].targetrotation+=45;
10602 if(player[i].backkeydown){
10603 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)){
10604 player[i].targetanimation=player[i].getRun();
10605 player[i].target=0;
10606 player[i].targetframe=0;
10608 if(player[i].isCrouch()){
10609 player[i].targetanimation=sneakanim;
10610 if(player[i].wasCrouch())player[i].target=0;
10611 player[i].targetframe=0;
10613 if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){
10614 player[i].velocity-=absflatfacing*5*multiplier;
10616 if(player[i].targetanimation==hanganim){
10617 player[i].currentanimation=jumpdownanim;
10618 player[i].targetanimation=jumpdownanim;
10619 player[i].target=0;
10620 player[i].currentframe=0;
10621 player[i].targetframe=1;
10622 player[i].velocity=0;
10623 player[i].velocity.y+=gravity;
10624 player[i].coords.y-=1.4;
10625 player[i].grabdelay=1;
10627 if ( !player[i].leftkeydown&&!player[i].rightkeydown)
10628 player[i].targetrotation+=180;
10631 if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){
10632 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)){
10633 player[i].jumpstart=0;
10634 player[i].targetanimation=jumpupanim;
10635 player[i].target=0;
10636 player[i].targetframe=0;
10637 player[i].rotation=player[i].targetrotation;
10638 player[i].transspeed=20;
10639 player[i].FootLand(0,1);
10640 player[i].FootLand(1,1);
10644 flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0);
10646 if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale;
10647 if(!movekey)player[i].velocity=0;
10652 for(j=0;j<numplayers;j++){
10653 if(j!=i&&!player[j].skeleton.free&&player[j].victim){
10654 if(findDistancefast(&player[j].coords,&player[j].victim->coords)<3&&player[j].victim==&player[i]&&(player[j].targetanimation==sweepanim)){
10655 if(target>=0)target=-1;
10660 if(target>=0)player[i].velocity.y=1;
10661 else if(player[i].crouchkeydown||player[i].aitype!=playercontrolled){
10662 player[i].velocity.y=7;
10663 player[i].crouchtogglekeydown=1;
10665 else player[i].velocity.y=5;
10667 if(mousejump&&i==0&&debugmode){
10668 if(!player[i].isLanding())player[i].tempdeltav=deltav;
10669 if(player[i].tempdeltav<0)player[i].velocity.y-=(float)(player[i].tempdeltav)/multiplier/1000;
10672 player[i].coords.y+=.2;
10673 player[i].jumppower-=1;
10675 static float gLoc[3];
10676 static float vel[3];
10677 gLoc[0]=player[i].coords.x;
10678 gLoc[1]=player[i].coords.y;
10679 gLoc[2]=player[i].coords.z;
10680 vel[0]=player[i].velocity.x;
10681 vel[1]=player[i].velocity.y;
10682 vel[2]=player[i].velocity.z;
10685 PlaySoundEx( whooshsound, samp[whooshsound], NULL, true);
10686 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
10687 OPENAL_SetVolume(channels[whooshsound], 128);
10688 OPENAL_SetPaused(channels[whooshsound], false);
10691 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
10692 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
10693 OPENAL_SetVolume(channels[jumpsound], 128);
10694 OPENAL_SetPaused(channels[jumpsound], false);
10696 if((player[i].isIdle())&&player[i].jumppower>1){
10697 player[i].targetanimation=player[i].getLanding();
10698 player[i].landhard=0;
10699 player[i].target=0;
10700 player[i].targetframe=2;
10701 player[i].jumpstart=1;
10702 player[i].tempdeltav=deltav;
10704 if(player[i].targetanimation==jumpupanim&&(((!floatjump&&!editorenabled)||!debugmode)||player[i].aitype!=playercontrolled)){
10705 if(player[i].jumppower>multiplier*6){
10706 player[i].velocity.y+=multiplier*6;
10707 player[i].jumppower-=multiplier*6;
10709 if(player[i].jumppower<=multiplier*6){
10710 player[i].velocity.y+=player[i].jumppower;
10711 player[i].jumppower=0;
10714 if(((floatjump||editorenabled)&&debugmode)&&i==0)player[i].velocity.y+=multiplier*30;
10718 if(player[i].isRun()||player[i].targetanimation==walkanim){
10719 player[i].targetanimation=player[i].getStop();
10720 player[i].target=0;
10721 player[i].targetframe=0;
10723 if(player[i].targetanimation==sneakanim){
10724 player[i].targetanimation=player[i].getCrouch();
10725 if(player[i].currentanimation==sneakanim)player[i].target=0;
10726 player[i].targetframe=0;
10729 if(player[i].targetanimation==walkanim&&(player[i].aitype==attacktypecutoff||player[i].aitype==searchtype||(player[i].aitype==passivetype&&player[i].numwaypoints<=1))){
10730 player[i].targetanimation=player[i].getStop();
10731 player[i].target=0;
10732 player[i].targetframe=0;
10734 if(player[i].isRun()&&(player[i].aitype==passivetype)){
10735 player[i].targetanimation=player[i].getStop();
10736 player[i].target=0;
10737 player[i].targetframe=0;
10741 if(player[i].targetanimation==rollanim)player[i].targetrotation=oldtargetrotation;
10745 for(k=0;k<numplayers;k++){
10746 if(abs(player[k].rotation-player[k].targetrotation)>180){
10747 if(player[k].rotation>player[k].targetrotation)player[k].rotation-=360;
10748 else player[k].rotation+=360;
10751 if(abs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)){
10752 player[k].targetanimation=player[k].getStop();
10753 player[k].targetframe=0;
10754 player[k].target=0;
10757 if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim){
10758 player[k].targettilt=0;
10760 if(player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=backhandspringanim&&player[k].targetanimation!=jumpdownanim&&!player[k].isFlip()){
10761 player[k].targettilt=0;
10762 if(player[k].jumppower<0&&!player[k].jumpkeydown)player[k].jumppower=0;
10763 player[k].jumppower+=multiplier*7;
10764 if(player[k].isCrouch())player[k].jumppower+=multiplier*7;
10765 //*(1-(player[k].damage/player[k].damagetolerance))
10766 if(player[k].jumppower>5)player[k].jumppower=5;
10769 if(player[k].isRun()){
10770 player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4;
10773 if(abs(player[k].tilt-player[k].targettilt)<multiplier*150)player[k].tilt=player[k].targettilt;
10774 else if(player[k].tilt>player[k].targettilt){
10775 player[k].tilt-=multiplier*150;
10777 else if(player[k].tilt<player[k].targettilt){
10778 player[k].tilt+=multiplier*150;
10781 player[k].grabdelay-=multiplier;
10784 for(k=0;k<numplayers;k++){
10785 player[k].DoAnimations();
10786 player[k].whichpatchx=player[k].coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
10787 player[k].whichpatchz=player[k].coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
10792 player[0].righthandmorphstart=0;
10793 player[0].righthandmorphend=1;
10794 player[0].lefthandmorphstart=0;
10795 player[0].lefthandmorphend=1;
10796 player[0].headmorphstart=0;
10797 player[0].headmorphend=2;*/
10800 if(IsKeyDown( theKeyMap, MAC_P_KEY )){
10801 if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
10802 player[0].righthandmorphend=1;
10803 player[0].targetrighthandmorphness=1;
10805 if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
10806 player[0].lefthandmorphend=0;
10807 player[0].targetlefthandmorphness=1;
10809 if(player[0].headmorphend!=2)player[0].headmorphness=0;
10810 player[0].headmorphend=2;
10811 player[0].targetheadmorphness=1;
10813 if(IsKeyDown( theKeyMap, MAC_L_KEY )){
10814 if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
10815 player[0].righthandmorphend=0;
10816 player[0].targetrighthandmorphness=1;
10818 if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
10819 player[0].lefthandmorphend=1;
10820 player[0].targetlefthandmorphness=1;
10822 if(player[0].headmorphend!=0)player[0].headmorphness=0;
10823 player[0].headmorphend=0;
10824 player[0].targetheadmorphness=1;
10827 if(numenvsounds!=0)
10828 for(j=numenvsounds-1;j>=0;j--){
10829 envsoundlife[j]-=multiplier;
10830 if(envsoundlife[j]<0){
10832 envsoundlife[j]=envsoundlife[numenvsounds];
10833 envsound[j]=envsound[numenvsounds];
10836 if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
10837 if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
10839 if(tutoriallevel==1){
10856 if(tutorialstage>=51)
10857 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10858 OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
10859 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
10861 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
10862 OPENAL_SetPaused(channels[stream_music3], false);
10863 OPENAL_SetVolume(channels[stream_music3], 256);
10868 float gLoc[3]={0,0,0};
10869 float vel[3]={0,0,0};
10870 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
10871 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10872 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10873 OPENAL_SetVolume(channels[fireendsound], 256);
10874 OPENAL_SetPaused(channels[fireendsound], false);
10875 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
10883 if(tutorialstage<51)
10884 if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
10887 gLoc[0]=player[0].coords.x;
10888 gLoc[1]=player[0].coords.y;
10889 gLoc[2]=player[0].coords.z;
10893 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10894 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10895 OPENAL_SetVolume(channels[fireendsound], 256);
10896 OPENAL_SetPaused(channels[fireendsound], false);
10898 player[0].coords=(oldtemp+oldtemp2)/2;
10906 if(tutorialstage>=14&&tutorialstage<50)
10907 if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
10910 gLoc[0]=player[1].coords.x;
10911 gLoc[1]=player[1].coords.y;
10912 gLoc[2]=player[1].coords.z;
10916 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
10917 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
10918 OPENAL_SetVolume(channels[fireendsound], 256);
10919 OPENAL_SetPaused(channels[fireendsound], false);
10921 for(int i=0;i<player[1].skeleton.num_joints;i++){
10923 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10924 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10925 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;
10926 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10927 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10931 player[1].coords=(oldtemp+oldtemp2)/2;
10932 for(int i=0;i<player[1].skeleton.num_joints;i++){
10933 player[1].skeleton.joints[i].velocity=0;
10935 if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
10936 if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
10937 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;
10938 if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
10939 sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
10947 static float gLoc[3];
10951 static float vel[3];
10952 vel[0]=(viewer.x-oldviewer.x)/multiplier;
10953 vel[1]=(viewer.y-oldviewer.y)/multiplier;
10954 vel[2]=(viewer.z-oldviewer.z)/multiplier;
10956 //Set orientation with forward and up vectors
10957 static XYZ upvector;
10961 upvector=DoRotation(upvector,-rotation2+90,0,0);
10962 upvector=DoRotation(upvector,0,0-rotation,0);
10967 facing=DoRotation(facing,-rotation2,0,0);
10968 facing=DoRotation(facing,0,0-rotation,0);
10971 static float ori[6];
10972 ori[0] = -facing.x;
10974 ori[2] = -facing.z;
10975 ori[3] = -upvector.x;
10976 ori[4] = upvector.y;
10977 ori[5] = -upvector.z;
10979 OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
10986 if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
10988 freezetogglekeydown=1;
10992 void Game::TickOnce(){
10995 if(directing||indialogue==-1){
10996 rotation+=deltah*.7;
10997 if(!invertmouse)rotation2+=deltav*.7;
10998 if(invertmouse)rotation2-=deltav*.7;
10999 if(rotation2>90)rotation2=90;
11000 if(rotation2<-70)rotation2=-70;
11002 if(mainmenu)rotation+=multiplier*5;
11003 if(!mainmenu&&!indemo&&!registered){
11004 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
11005 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11006 OPENAL_SetPaused(channels[stream_music3], false);
11007 OPENAL_SetVolume(channels[stream_music3], 256);
11012 float gLoc[3]={0,0,0};
11013 float vel[3]={0,0,0};
11014 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11015 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11016 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11017 OPENAL_SetVolume(channels[fireendsound], 256);
11018 OPENAL_SetPaused(channels[fireendsound], false);
11019 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11028 if(tryquit==1&&!registered&&mainmenu!=12){
11029 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
11030 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11031 OPENAL_SetPaused(channels[stream_music3], false);
11032 OPENAL_SetVolume(channels[stream_music3], 256);
11037 float gLoc[3]={0,0,0};
11038 float vel[3]={0,0,0};
11039 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11040 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11041 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11042 OPENAL_SetVolume(channels[fireendsound], 256);
11043 OPENAL_SetPaused(channels[fireendsound], false);
11044 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11055 void Game::TickOnceAfter(){
11056 static XYZ colviewer;
11057 static XYZ coltarget;
11060 static float brotate;
11063 static float changedelay;
11064 static bool alldead;
11065 static float unseendelay;
11066 static float cameraspeed;
11070 if(environment==snowyenvironment)music1=stream_music1snow;
11071 if(environment==grassyenvironment)music1=stream_music1grass;
11072 if(environment==desertenvironment)music1=stream_music1desert;
11077 for(i=0;i<numplayers;i++){
11078 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)){
11079 musictype=stream_music2;
11083 if(player[0].dead)musictype=stream_music3;
11086 if(musictype==stream_music2){
11090 if(oldmusictype==stream_music2&&musictype!=stream_music2){
11091 unseendelay-=multiplier;
11093 musictype=stream_music2;
11099 musictype=stream_music3;
11100 musicvolume[2]=512;
11107 if(musictype!=oldmusictype&&musictype==stream_music2){
11108 static float gLoc[3];
11109 static float vel[3];
11110 gLoc[0]=cameraloc.x;
11111 gLoc[1]=cameraloc.y;
11112 gLoc[2]=cameraloc.z;
11116 PlaySoundEx( alarmsound, samp[alarmsound], NULL, true);
11117 OPENAL_SetVolume(channels[alarmsound], 512);
11118 OPENAL_SetPaused(channels[alarmsound], false);
11122 musicselected=musictype;
11124 if(musicselected==music1)musicvolume[0]+=multiplier*450;
11125 else musicvolume[0]-=multiplier*450;
11126 if(musicselected==stream_music2)musicvolume[1]+=multiplier*450;
11127 else musicvolume[1]-=multiplier*450;
11128 if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
11129 else musicvolume[2]-=multiplier*450;
11131 if(musicselected==music1)musicvolume[0]+=multiplier*100;
11132 else musicvolume[0]-=multiplier*450;
11133 if(musicselected==music2)musicvolume[1]+=multiplier*150;
11134 else if(player[0].dead)musicvolume[1]-=multiplier*450;
11135 else musicvolume[1]-=multiplier*100;
11136 if(musicselected==music3)musicvolume[2]+=multiplier*450;
11137 else musicvolume[2]-=multiplier*450;*/
11140 if(musicvolume[i]<0)musicvolume[i]=0;
11141 if(musicvolume[i]>512)musicvolume[i]=512;
11144 if(musicvolume[2]>128&&!loading&&!mainmenu)musicvolume[2]=128;
11147 if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
11148 PlayStreamEx( music1, strm[music1], NULL, true);
11149 OPENAL_SetPaused(channels[music1], false);
11151 if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
11152 PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
11153 OPENAL_SetPaused(channels[stream_music2], false);
11155 if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
11156 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11157 OPENAL_SetPaused(channels[stream_music3], false);
11162 OPENAL_SetPaused(channels[music1], true);
11163 OPENAL_SetPaused(channels[stream_music2], true);
11164 OPENAL_SetPaused(channels[stream_music3], true);
11167 oldmusicvolume[i]=0;
11173 if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
11174 OPENAL_SetPaused(channels[music1], true);
11176 if(musicvolume[1]<=0&&oldmusicvolume[1]>0){
11177 OPENAL_SetPaused(channels[stream_music2], true);
11179 if(musicvolume[2]<=0&&oldmusicvolume[2]>0){
11180 OPENAL_SetPaused(channels[stream_music3], true);
11183 if(musicvolume[0]!=oldmusicvolume[0]){
11184 OPENAL_SetVolume(channels[music1], musicvolume[0]);
11186 if(musicvolume[1]!=oldmusicvolume[1]){
11187 OPENAL_SetVolume(channels[stream_music2], musicvolume[1]);
11189 if(musicvolume[2]!=oldmusicvolume[2]){
11190 OPENAL_SetVolume(channels[stream_music3], musicvolume[2]);
11194 oldmusicvolume[i]=musicvolume[i];
11200 for(i=0;i<numhotspots;i++){
11201 if(hotspottype[i]>10&&hotspottype[i]<20){
11202 if(player[hotspottype[i]-10].dead==0){
11205 else if(killhotspot==2)
11209 if(killhotspot==2)killhotspot=0;
11214 for(i=0;i<numhotspots;i++){
11215 if(hotspottype[i]==-1){
11216 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
11223 for(i=1;i<numplayers;i++){
11224 if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
11226 if(numalarmed>maxalarmed)maxalarmed=numalarmed;
11228 if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
11229 if(player[0].dead&&changedelay<=0){
11231 targetlevel=whichlevel;
11235 for(i=1;i<numplayers;i++){
11236 if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
11240 if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
11242 targetlevel=whichlevel+1;
11243 if(targetlevel>numchallengelevels-1)targetlevel=0;
11245 if(winhotspot||windialogue){
11247 targetlevel=whichlevel+1;
11248 if(targetlevel>numchallengelevels-1)targetlevel=0;
11254 targetlevel=whichlevel+1;
11255 if(targetlevel>numchallengelevels-1)targetlevel=0;
11258 if(changedelay>0&&!player[0].dead&&!won){
11259 //high scores, awards, win
11262 accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11263 accountcampaignchoicesmade[accountactive]++;
11264 accountcampaignscore[accountactive]+=bonustotal;
11266 accountcampaigntime[accountactive]+=leveltime;
11267 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
11269 //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11275 if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
11276 if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
11278 if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
11294 if(!editorenabled&&gameon&&!mainmenu){
11295 if(changedelay!=-999)changedelay-=multiplier/7;
11296 if(player[0].dead)targetlevel=whichlevel;
11297 if(loading==2&&!campaign){
11305 float gLoc[3]={0,0,0};
11306 float vel[3]={0,0,0};
11307 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11308 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11309 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11310 OPENAL_SetVolume(channels[firestartsound], 256);
11311 OPENAL_SetPaused(channels[firestartsound], false);
11312 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11314 if(!player[0].dead&&targetlevel!=whichlevel){
11315 startbonustotal=bonustotal;
11317 if(!player[0].dead)Loadlevel(targetlevel);
11318 if(player[0].dead)Loadlevel(whichlevel);
11320 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11321 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11322 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11323 OPENAL_SetVolume(channels[fireendsound], 256);
11324 OPENAL_SetPaused(channels[fireendsound], false);
11325 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11329 if(loading==2&&targetlevel==whichlevel){
11337 float gLoc[3]={0,0,0};
11338 float vel[3]={0,0,0};
11339 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11340 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11341 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11342 OPENAL_SetVolume(channels[firestartsound], 256);
11343 OPENAL_SetPaused(channels[firestartsound], false);
11344 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11346 for(i=0;i<255;i++){
11360 strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
11361 Loadlevel(mapname);
11363 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11364 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11365 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11366 OPENAL_SetVolume(channels[fireendsound], 256);
11367 OPENAL_SetPaused(channels[fireendsound], false);
11368 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11372 if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
11373 if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
11374 if(accountprogress[accountactive]>3&&!registered){
11375 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
11376 PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
11377 OPENAL_SetPaused(channels[stream_music3], false);
11378 OPENAL_SetVolume(channels[stream_music3], 256);
11382 accountprogress[accountactive]=3;
11384 float gLoc[3]={0,0,0};
11385 float vel[3]={0,0,0};
11386 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
11387 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
11388 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
11389 OPENAL_SetVolume(channels[fireendsound], 256);
11390 OPENAL_SetPaused(channels[fireendsound], false);
11391 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
11400 if(whichlevel!=-2&&!loading&&!player[0].dead){
11404 if(player[0].dead)loading=1;
11410 if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
11411 if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
11415 else if(mainmenu==0&&winfreeze){
11416 if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
11418 else stealthloading=0;
11420 if(!stealthloading){
11421 float gLoc[3]={0,0,0};
11422 float vel[3]={0,0,0};
11423 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
11424 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
11425 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
11426 OPENAL_SetVolume(channels[firestartsound], 256);
11427 OPENAL_SetPaused(channels[firestartsound], false);
11428 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
11439 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
11440 //campaignnumlevels=0;
11441 //accountcampaignchoicesmade[accountactive]=0;
11442 ipstream.ignore(256,':');
11443 ipstream >> campaignnumlevels;
11444 for(i=0;i<campaignnumlevels;i++){
11445 ipstream.ignore(256,':');
11446 ipstream.ignore(256,':');
11447 ipstream.ignore(256,' ');
11448 ipstream >> campaignmapname[i];
11449 ipstream.ignore(256,':');
11450 ipstream >> campaigndescription[i];
11451 for(j=0;j<256;j++){
11452 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
11454 ipstream.ignore(256,':');
11455 ipstream >> campaignchoosenext[i];
11456 ipstream.ignore(256,':');
11457 ipstream >> campaignnumnext[i];
11458 if(campaignnumnext[i])
11459 for(j=0;j<campaignnumnext[i];j++){
11460 ipstream.ignore(256,':');
11461 ipstream >> campaignnextlevel[i][j];
11462 campaignnextlevel[i][j]-=1;
11464 ipstream.ignore(256,':');
11465 ipstream >> campaignlocationx[i];
11466 ipstream.ignore(256,':');
11467 ipstream >> campaignlocationy[i];
11471 for(i=0;i<campaignnumlevels;i++){
11473 levelhighlight[i]=0;
11477 for(i=0;i<campaignnumlevels;i++){
11479 levelhighlight[i]=0;
11484 if(accountcampaignchoicesmade[accountactive])
11485 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
11486 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
11487 levelvisible[levelorder[i+1]]=1;
11489 int whichlevelstart;
11490 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
11491 if(whichlevelstart<0){
11492 campaignchoicenum=1;
11493 campaignchoicewhich[0]=0;
11497 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
11498 if(campaignchoicenum)
11499 for(i=0;i<campaignchoicenum;i++){
11500 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
11501 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11502 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
11509 //if(firstload)TickOnceAfter();
11510 if(!firstload)LoadStuff();
11512 for(i=0;i<255;i++){
11527 //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
11528 //accountcampaignchoicesmade[accountactive]++;
11531 strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
11535 Loadlevel(mapname);
11539 OPENAL_SetPaused(channels[stream_music3], true);
11544 if(loading==3)loading=0;
11548 oldmusictype=musictype;
11554 facing=DoRotation(facing,-rotation2,0,0);
11555 facing=DoRotation(facing,0,0-rotation,0);
11556 viewerfacing=facing;
11560 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;
11561 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;
11563 if(player[0].skeleton.free){
11564 for(i=0;i<player[0].skeleton.num_joints;i++){
11565 if(player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y>target.y)
11566 target.y=player[0].skeleton.joints[i].position.y*player[0].scale+player[0].coords.y;
11570 if(player[0].skeleton.free!=2&&!autocam){
11572 if(findLengthfast(&player[0].velocity)>400){
11573 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11575 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11576 coltarget=target-cameraloc;
11577 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11579 Normalise(&coltarget);
11580 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11581 else cameraloc=cameraloc+coltarget*multiplier*8;
11583 if(editorenabled)cameraloc=target;
11584 cameradist+=multiplier*5;
11585 if(cameradist>2.3)cameradist=2.3;
11586 viewer=cameraloc-facing*cameradist;
11588 coltarget=cameraloc;
11589 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11590 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11591 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11592 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11594 coltarget=cameraloc;
11595 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11597 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11598 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11599 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11601 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11605 cameradist=findDistance(&viewer,&target);
11606 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11607 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11609 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11610 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11613 if(player[0].skeleton.free!=2&&autocam){
11615 if(findLengthfast(&player[0].velocity)>400){
11616 cameraspeed=20+(findLength(&player[0].velocity)-20)*.96;
11618 if(player[0].skeleton.free==0&&player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim)target.y+=1.4;
11619 cameradist+=multiplier*5;
11620 if(cameradist>3.3)cameradist=3.3;
11621 coltarget=target-cameraloc;
11622 if(findLengthfast(&coltarget)<multiplier*multiplier*400)cameraloc=target;
11623 else if(findLengthfast(&coltarget)>1)
11625 Normalise(&coltarget);
11626 if(player[0].targetanimation!=hanganim&&player[0].targetanimation!=climbanim&&player[0].currentanimation!=climbanim&&player[0].currentoffset.x==0)cameraloc=cameraloc+coltarget*multiplier*cameraspeed;
11627 else cameraloc=cameraloc+coltarget*multiplier*8;
11629 if(editorenabled)cameraloc=target;
11632 coltarget=cameraloc;
11633 objects.SphereCheckPossible(&colviewer, findDistance(&colviewer,&coltarget));
11634 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11635 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11636 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11638 coltarget=cameraloc;
11639 if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col;
11641 if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
11642 for(j=0;j<terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz];j++){
11643 i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
11645 if(objects.model[i].SphereCheck(&colviewer,.15,&col,&objects.position[i],&objects.rotation[i])!=-1){
11649 cameradist=findDistance(&viewer,&target);
11650 if(viewer.y<terrain.getHeight(viewer.x,viewer.z)+.6){
11651 viewer.y=terrain.getHeight(viewer.x,viewer.z)+.6;
11653 if(cameraloc.y<terrain.getHeight(cameraloc.x,cameraloc.z)){
11654 cameraloc.y=terrain.getHeight(cameraloc.x,cameraloc.z);
11657 if(camerashake>.8)camerashake=.8;
11658 //if(woozy>10)woozy=10;
11659 //woozy+=multiplier;
11661 if(player[0].dead)camerashake=0;
11662 if(player[0].dead)woozy=0;
11663 camerashake-=multiplier*2;
11664 blackout-=multiplier*2;
11665 //if(player[0].isCrouch())woozy-=multiplier*8;
11666 if(camerashake<0)camerashake=0;
11667 if(blackout<0)blackout=0;
11668 //if(woozy<0)woozy=0;
11670 viewer.x+=(float)(Random()%100)*.0005*camerashake;
11671 viewer.y+=(float)(Random()%100)*.0005*camerashake;
11672 viewer.z+=(float)(Random()%100)*.0005*camerashake;