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.
23 #include "openal_wrapper.h"
24 #include "Animation.h"
27 extern float screenwidth, screenheight;
28 extern float viewdistance;
30 extern XYZ lightlocation;
31 extern float fadestart;
32 extern float texscale;
35 extern Skeleton testskeleton;
37 extern Terrain terrain;
38 //extern Sprites sprites;
39 extern int kTextureSize;
40 extern float texdetail;
41 extern float realtexdetail;
43 extern Objects objects;
45 extern bool cellophane;
46 extern GLubyte bloodText[512 * 512 * 3];
47 extern GLubyte wolfbloodText[512 * 512 * 3];
48 extern bool ismotionblur;
49 extern bool trilinear;
51 extern bool musictoggle;
52 extern int environment;
53 extern bool ambientsound;
54 extern float multiplier;
55 extern int netdatanew;
57 extern bool stillloading;
58 extern TGAImageRec texture;
62 extern bool visibleloading;
63 extern float flashamount, flashr, flashg, flashb;
64 extern int flashdelay;
65 extern int whichjointstartarray[26];
66 extern int whichjointendarray[26];
67 extern int difficulty;
68 extern float tintr, tintg, tintb;
69 extern float slomospeed;
70 extern bool gamestarted;
72 extern int numdialogues;
73 extern int numdialogueboxes[20];
74 extern int dialoguetype[20];
75 extern int dialogueboxlocation[20][20];
76 extern float dialogueboxcolor[20][20][3];
77 extern int dialogueboxsound[20][20];
78 extern char dialoguetext[20][20][128];
79 extern char dialoguename[20][20][64];
80 extern XYZ dialoguecamera[20][20];
81 extern float dialoguecamerayaw[20][20];
82 extern float dialoguecamerapitch[20][20];
83 extern int indialogue;
84 extern int whichdialogue;
85 extern float dialoguetime;
87 extern float accountcampaignhighscore[10];
88 extern float accountcampaignfasttime[10];
89 extern float accountcampaignscore[10];
90 extern float accountcampaigntime[10];
92 extern int accountcampaignchoicesmade[10];
93 extern int accountcampaignchoices[10][5000];
95 void LOG(const std::string &fmt, ...)
97 // !!! FIXME: write me.
104 if (Game::endgame == 2) {
105 Game::accountactive->endGame();
109 Account::saveFile(":Data:Users", Game::accountactive);
113 LOG("Shutting down sound system...");
115 OPENAL_StopSound(OPENAL_ALL);
117 // this is causing problems on Linux, but we'll force an _exit() a little
118 // later in the shutdown process. --ryan.
121 for (int i = 0; i < sounds_count; ++i) {
122 OPENAL_Sample_Free(samp[i]);
136 skybox = new SkyBox();
139 void Game::deleteGame()
145 terraintexture.destroy();
146 terraintexture2.destroy();
147 cursortexture.destroy();
148 Maparrowtexture.destroy();
149 Mapboxtexture.destroy();
150 Mapcircletexture.destroy();
151 hawktexture.destroy();
152 loadscreentexture.destroy();
154 for (int i = 0; i < 10; i++)
155 Mainmenuitems[i].destroy();
157 glDeleteTextures(1, &screentexture);
158 glDeleteTextures(1, &screentexture2);
165 void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize)
172 LOG(std::string("Loading (S)...") + fileName);
175 float temptexdetail = texdetail;
177 //upload_image( fileName );
178 //LoadTGA( fileName );
180 // Converting file to something os specific
181 char * fixedFN = ConvertFileName(fileName);
184 unsigned char fileNamep[256];
185 CopyCStringToPascal(fixedFN, fileNamep);
187 upload_image( fileNamep , 0);
188 texdetail = temptexdetail;
192 bytesPerPixel = texture.bpp / 8;
195 for (i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
196 if ((i + 1) % 4 || bytesPerPixel == 3) {
197 array[tempnum] = texture.data[i];
206 //***************> ResizeGLScene() <******/
207 GLvoid Game::ReSizeGLScene(float fov, float pnear)
209 if (screenheight == 0) {
213 glViewport(0, 0, screenwidth, screenheight);
215 glMatrixMode(GL_PROJECTION);
218 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
220 glMatrixMode(GL_MODELVIEW);
224 void Game::LoadingScreen()
226 static float loadprogress;
227 //~ static AbsoluteTime time = {0, 0};
228 static AbsoluteTime frametime = {0, 0};
229 AbsoluteTime currTime = UpTime ();
230 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
232 if (0 > deltaTime) // if negative microseconds
233 deltaTime /= -1000000.0;
234 else // else milliseconds
237 multiplier = deltaTime;
238 if (multiplier < .001)
242 if (multiplier > .05) {
243 frametime = currTime; // reset for next time interval
247 glClearColor(0, 0, 0, 1);
248 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
251 loadtime += multiplier * 4;
253 loadprogress = loadtime;
254 if (loadprogress > 100)
257 //loadprogress=abs(Random()%100);
261 glEnable(GL_TEXTURE_2D);
262 loadscreentexture.bind();
263 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
264 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
265 glDisable(GL_DEPTH_TEST);
266 glDisable(GL_CULL_FACE);
267 glDisable(GL_LIGHTING);
269 glMatrixMode(GL_PROJECTION);
272 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
273 glMatrixMode(GL_MODELVIEW);
276 glTranslatef(screenwidth / 2, screenheight / 2, 0);
277 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
278 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
280 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
282 //glScalef(.25,.25,.25);
284 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
285 glVertex3f(-1, -1, 0.0f);
286 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
287 glVertex3f(1, -1, 0.0f);
288 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
289 glVertex3f(1, 1, 0.0f);
290 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
291 glVertex3f(-1, 1, 0.0f);
296 //glScalef(.25,.25,.25);
298 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
299 glVertex3f(-1, -1, 0.0f);
300 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
301 glVertex3f(1, -1, 0.0f);
302 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
303 glVertex3f(1, 1, 0.0f);
304 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
305 glVertex3f(-1, 1, 0.0f);
308 glDisable(GL_TEXTURE_2D);
309 glMatrixMode(GL_PROJECTION);
311 glMatrixMode(GL_MODELVIEW);
316 glEnable(GL_TEXTURE_2D);
317 loadscreentexture.bind();
318 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
319 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
320 glDisable(GL_DEPTH_TEST);
321 glDisable(GL_CULL_FACE);
322 glDisable(GL_LIGHTING);
324 glMatrixMode(GL_PROJECTION);
327 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
328 glMatrixMode(GL_MODELVIEW);
331 glTranslatef(screenwidth / 2, screenheight / 2, 0);
332 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
333 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
335 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
336 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
338 //glScalef(.25,.25,.25);
340 glTexCoord2f(0 + .5, 0 + .5);
341 glVertex3f(-1, -1, 0.0f);
342 glTexCoord2f(1 + .5, 0 + .5);
343 glVertex3f(1, -1, 0.0f);
344 glTexCoord2f(1 + .5, 1 + .5);
345 glVertex3f(1, 1, 0.0f);
346 glTexCoord2f(0 + .5, 1 + .5);
347 glVertex3f(-1, 1, 0.0f);
350 glDisable(GL_TEXTURE_2D);
351 glMatrixMode(GL_PROJECTION);
353 glMatrixMode(GL_MODELVIEW);
358 glEnable(GL_TEXTURE_2D);
359 loadscreentexture.bind();
360 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
361 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
362 glDisable(GL_DEPTH_TEST);
363 glDisable(GL_CULL_FACE);
364 glDisable(GL_LIGHTING);
366 glMatrixMode(GL_PROJECTION);
369 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
370 glMatrixMode(GL_MODELVIEW);
373 glTranslatef(screenwidth / 2, screenheight / 2, 0);
374 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
375 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
377 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
379 //glScalef(.25,.25,.25);
381 glTexCoord2f(0 + .2, 0 + .8);
382 glVertex3f(-1, -1, 0.0f);
383 glTexCoord2f(1 + .2, 0 + .8);
384 glVertex3f(1, -1, 0.0f);
385 glTexCoord2f(1 + .2, 1 + .8);
386 glVertex3f(1, 1, 0.0f);
387 glTexCoord2f(0 + .2, 1 + .8);
388 glVertex3f(-1, 1, 0.0f);
391 glDisable(GL_TEXTURE_2D);
392 glMatrixMode(GL_PROJECTION);
394 glMatrixMode(GL_MODELVIEW);
401 if (flashamount > 0) {
405 flashamount -= multiplier;
409 glDisable(GL_DEPTH_TEST);
410 glDisable(GL_CULL_FACE);
411 glDisable(GL_LIGHTING);
412 glDisable(GL_TEXTURE_2D);
414 glMatrixMode(GL_PROJECTION);
417 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
418 glMatrixMode(GL_MODELVIEW);
421 glScalef(screenwidth, screenheight, 1);
422 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
424 glColor4f(flashr, flashg, flashb, flashamount);
426 glVertex3f(0, 0, 0.0f);
427 glVertex3f(256, 0, 0.0f);
428 glVertex3f(256, 256, 0.0f);
429 glVertex3f(0, 256, 0.0f);
431 glMatrixMode(GL_PROJECTION);
433 glMatrixMode(GL_MODELVIEW);
435 glEnable(GL_DEPTH_TEST);
436 glEnable(GL_CULL_FACE);
445 void FadeLoadingScreen(float howmuch)
447 static float loadprogress;
451 glClearColor(0, 0, 0, 1);
452 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
454 loadprogress = howmuch;
456 //loadprogress=abs(Random()%100);
460 //glEnable(GL_TEXTURE_2D);
461 glDisable(GL_TEXTURE_2D);
462 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
463 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
464 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
465 glDisable(GL_DEPTH_TEST);
466 glDisable(GL_CULL_FACE);
467 glDisable(GL_LIGHTING);
469 glMatrixMode(GL_PROJECTION);
472 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
473 glMatrixMode(GL_MODELVIEW);
476 glTranslatef(screenwidth / 2, screenheight / 2, 0);
477 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
478 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
480 glColor4f(loadprogress / 100, 0, 0, 1);
482 //glScalef(.25,.25,.25);
485 glVertex3f(-1, -1, 0.0f);
487 glVertex3f(1, -1, 0.0f);
489 glVertex3f(1, 1, 0.0f);
491 glVertex3f(-1, 1, 0.0f);
494 glDisable(GL_TEXTURE_2D);
495 glMatrixMode(GL_PROJECTION);
497 glMatrixMode(GL_MODELVIEW);
506 extern bool cmdline(const char *cmd);
508 void Game::InitGame()
511 ProcessSerialNumber PSN;
512 ProcessInfoRec pinfo;
515 /* set up process serial number */
516 PSN.highLongOfPSN = 0;
517 PSN.lowLongOfPSN = kCurrentProcess;
518 /* set up info block */
519 pinfo.processInfoLength = sizeof(pinfo);
520 pinfo.processName = NULL;
521 pinfo.processAppSpec = &pspec;
522 /* grab the vrefnum and directory */
523 err = GetProcessInformation(&PSN, &pinfo);
525 vRefNum = pspec.vRefNum;
532 numchallengelevels = 14;
534 accountactive = Account::loadFile(":Data:Users");
540 whichjointstartarray[0] = righthip;
541 whichjointendarray[0] = rightfoot;
543 whichjointstartarray[1] = righthip;
544 whichjointendarray[1] = rightankle;
546 whichjointstartarray[2] = righthip;
547 whichjointendarray[2] = rightknee;
549 whichjointstartarray[3] = rightknee;
550 whichjointendarray[3] = rightankle;
552 whichjointstartarray[4] = rightankle;
553 whichjointendarray[4] = rightfoot;
555 whichjointstartarray[5] = lefthip;
556 whichjointendarray[5] = leftfoot;
558 whichjointstartarray[6] = lefthip;
559 whichjointendarray[6] = leftankle;
561 whichjointstartarray[7] = lefthip;
562 whichjointendarray[7] = leftknee;
564 whichjointstartarray[8] = leftknee;
565 whichjointendarray[8] = leftankle;
567 whichjointstartarray[9] = leftankle;
568 whichjointendarray[9] = leftfoot;
570 whichjointstartarray[10] = abdomen;
571 whichjointendarray[10] = rightshoulder;
573 whichjointstartarray[11] = abdomen;
574 whichjointendarray[11] = rightelbow;
576 whichjointstartarray[12] = abdomen;
577 whichjointendarray[12] = rightwrist;
579 whichjointstartarray[13] = abdomen;
580 whichjointendarray[13] = righthand;
582 whichjointstartarray[14] = rightshoulder;
583 whichjointendarray[14] = rightelbow;
585 whichjointstartarray[15] = rightelbow;
586 whichjointendarray[15] = rightwrist;
588 whichjointstartarray[16] = rightwrist;
589 whichjointendarray[16] = righthand;
591 whichjointstartarray[17] = abdomen;
592 whichjointendarray[17] = leftshoulder;
594 whichjointstartarray[18] = abdomen;
595 whichjointendarray[18] = leftelbow;
597 whichjointstartarray[19] = abdomen;
598 whichjointendarray[19] = leftwrist;
600 whichjointstartarray[20] = abdomen;
601 whichjointendarray[20] = lefthand;
603 whichjointstartarray[21] = leftshoulder;
604 whichjointendarray[21] = leftelbow;
606 whichjointstartarray[22] = leftelbow;
607 whichjointendarray[22] = leftwrist;
609 whichjointstartarray[23] = leftwrist;
610 whichjointendarray[23] = lefthand;
612 whichjointstartarray[24] = abdomen;
613 whichjointendarray[24] = neck;
615 whichjointstartarray[25] = neck;
616 whichjointendarray[25] = head;
618 FadeLoadingScreen(0);
622 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
624 int temptexdetail = texdetail;
626 text->LoadFontTexture(":Data:Textures:Font.png");
628 texdetail = temptexdetail;
630 FadeLoadingScreen(10);
642 LOG("Initializing sound system...");
647 unsigned char rc = 0;
648 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
649 if (cmdline("forceoss")) // ...but let user override that.
650 output = OPENAL_OUTPUT_OSS;
651 else if (cmdline("nosound"))
652 output = OPENAL_OUTPUT_NOSOUND;
654 OPENAL_SetOutput(output);
655 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
656 // if we tried ALSA and failed, fall back to OSS.
657 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
659 output = OPENAL_OUTPUT_OSS;
660 OPENAL_SetOutput(output);
661 rc = OPENAL_Init(44100, 32, 0);
667 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
668 OPENAL_SetOutput(output);
669 rc = OPENAL_Init(44100, 32, 0);
672 OPENAL_Init(44100, 32, 0);
675 OPENAL_SetSFXMasterVolume((int)(volume * 255));
679 emit_stream_np(stream_menutheme);
681 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
683 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
684 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
685 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
687 temptexdetail = texdetail;
690 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
691 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
692 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
693 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
694 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
695 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
696 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
698 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
699 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
700 texdetail = temptexdetail;
702 FadeLoadingScreen(95);
712 newscreenwidth = screenwidth;
713 newscreenheight = screenheight;
719 void Game::LoadScreenTexture()
721 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
723 if (!Game::screentexture)
724 glGenTextures( 1, &Game::screentexture );
725 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
728 glEnable(GL_TEXTURE_2D);
729 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
730 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
731 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
733 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
736 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
737 void Game::LoadStuff()
739 static float temptexdetail;
740 static float viewdistdetail;
750 for (auto p:Person::players) {
751 p->skeleton.drawmodel.textureptr.destroy();
754 i = abs(Random() % 4);
755 visibleloading = 0; //don't use loadscreentexture yet
756 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
759 temptexdetail = texdetail;
761 text->LoadFontTexture(":Data:Textures:Font.png");
763 texdetail = temptexdetail;
768 viewdistance = 50 * megascale * viewdistdetail;
780 realtexdetail = texdetail;
782 LOG("Loading weapon data...");
784 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
785 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
786 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
787 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
788 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
789 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
790 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
792 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
793 Weapon::throwingknifemodel.Scale(.001, .001, .001);
794 //Weapon::throwingknifemodel.Rotate(0,0,-90);
795 Weapon::throwingknifemodel.Rotate(90, 0, 0);
796 Weapon::throwingknifemodel.Rotate(0, 90, 0);
797 Weapon::throwingknifemodel.flat = 0;
798 Weapon::throwingknifemodel.CalculateNormals(1);
799 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
801 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
802 Weapon::swordmodel.Scale(.001, .001, .001);
803 //Weapon::swordmodel.Rotate(0,0,-90);
804 Weapon::swordmodel.Rotate(90, 0, 0);
805 Weapon::swordmodel.Rotate(0, 90, 0);
806 Weapon::swordmodel.Rotate(0, 0, 90);
807 Weapon::swordmodel.flat = 1;
808 Weapon::swordmodel.CalculateNormals(1);
809 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
811 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
812 Weapon::staffmodel.Scale(.005, .005, .005);
813 //Weapon::staffmodel.Rotate(0,0,-90);
814 Weapon::staffmodel.Rotate(90, 0, 0);
815 Weapon::staffmodel.Rotate(0, 90, 0);
816 Weapon::staffmodel.Rotate(0, 0, 90);
817 Weapon::staffmodel.flat = 1;
818 Weapon::staffmodel.CalculateNormals(1);
819 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
821 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
822 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
823 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
824 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
827 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
828 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
829 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
832 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
833 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
834 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
835 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
836 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
837 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
838 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
839 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
840 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
841 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
842 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
846 ReSizeGLScene(90, .01);
858 //Set up distant light
859 light.color[0] = .95;
860 light.color[1] = .95;
862 light.ambient[0] = .2;
863 light.ambient[1] = .2;
864 light.ambient[2] = .24;
865 light.location.x = 1;
866 light.location.y = 1;
867 light.location.z = -.2;
868 Normalise(&light.location);
878 texscale = .2 / megascale / viewdistdetail;
879 terrain.scale = 3 * megascale * viewdistdetail;
881 viewer.x = terrain.size / 2 * terrain.scale;
882 viewer.z = terrain.size / 2 * terrain.scale;
884 hawk.load((char *)":Data:Models:hawk.solid", 1);
885 hawk.Scale(.03, .03, .03);
886 hawk.Rotate(90, 1, 1);
887 hawk.CalculateNormals(0);
888 hawk.ScaleNormals(-1, -1, -1);
889 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
890 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
891 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
893 eye.load((char *)":Data:Models:eye.solid", 1);
894 eye.Scale(.03, .03, .03);
895 eye.CalculateNormals(0);
897 cornea.load((char *)":Data:Models:cornea.solid", 1);
898 cornea.Scale(.03, .03, .03);
899 cornea.CalculateNormals(0);
901 iris.load((char *)":Data:Models:iris.solid", 1);
902 iris.Scale(.03, .03, .03);
903 iris.CalculateNormals(0);
905 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
906 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
916 //Fix knife stab, too lazy to do it manually
920 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
921 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
922 animation[knifesneakattackanim].position[i][j] += moveamount;
928 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
929 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
930 animation[knifesneakattackedanim].position[i][j] += moveamount;
936 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
937 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
938 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
939 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
940 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
942 animation[dead1anim].speed[0] = 0.001;
943 animation[dead2anim].speed[0] = 0.001;
944 animation[dead3anim].speed[0] = 0.001;
945 animation[dead4anim].speed[0] = 0.001;
947 animation[dead1anim].speed[1] = 0.001;
948 animation[dead2anim].speed[1] = 0.001;
949 animation[dead3anim].speed[1] = 0.001;
950 animation[dead4anim].speed[1] = 0.001;
952 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
953 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
954 animation[swordsneakattackanim].position[i][j] += moveamount;
958 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
959 animation[swordsneakattackanim].weapontarget[j] += moveamount;
964 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
965 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
966 animation[swordsneakattackedanim].position[i][j] += moveamount;
971 temptexdetail = texdetail;
973 texdetail = temptexdetail;
977 if (!screentexture) {
981 if (targetlevel != 7) {
982 emit_sound_at(fireendsound);