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 modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru 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. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
21 #include "openal_wrapper.h"
22 #include "Animation.h"
25 extern float screenwidth, screenheight;
26 extern float viewdistance;
28 extern XYZ lightlocation;
29 extern float fadestart;
30 extern float texscale;
33 extern Skeleton testskeleton;
35 extern Terrain terrain;
36 //extern Sprites sprites;
37 extern int kTextureSize;
38 extern float texdetail;
39 extern float realtexdetail;
41 extern Objects objects;
43 extern bool cellophane;
44 extern GLubyte bloodText[512 * 512 * 3];
45 extern GLubyte wolfbloodText[512 * 512 * 3];
46 extern bool ismotionblur;
47 extern bool trilinear;
49 extern bool musictoggle;
50 extern int environment;
51 extern bool ambientsound;
52 extern float multiplier;
53 extern int netdatanew;
55 extern bool stillloading;
56 extern TGAImageRec texture;
60 extern bool visibleloading;
61 extern float flashamount, flashr, flashg, flashb;
62 extern int flashdelay;
63 extern int whichjointstartarray[26];
64 extern int whichjointendarray[26];
65 extern int difficulty;
66 extern float tintr, tintg, tintb;
67 extern float slomospeed;
68 extern bool gamestarted;
70 extern int numdialogues;
71 extern int numdialogueboxes[20];
72 extern int dialoguetype[20];
73 extern int dialogueboxlocation[20][20];
74 extern float dialogueboxcolor[20][20][3];
75 extern int dialogueboxsound[20][20];
76 extern char dialoguetext[20][20][128];
77 extern char dialoguename[20][20][64];
78 extern XYZ dialoguecamera[20][20];
79 extern float dialoguecamerayaw[20][20];
80 extern float dialoguecamerapitch[20][20];
81 extern int indialogue;
82 extern int whichdialogue;
83 extern float dialoguetime;
85 extern float accountcampaignhighscore[10];
86 extern float accountcampaignfasttime[10];
87 extern float accountcampaignscore[10];
88 extern float accountcampaigntime[10];
90 extern int accountcampaignchoicesmade[10];
91 extern int accountcampaignchoices[10][5000];
93 void LOG(const std::string &fmt, ...)
95 // !!! FIXME: write me.
102 if (Game::endgame == 2) {
103 Game::accountactive->endGame();
107 Account::saveFile(":Data:Users", Game::accountactive);
111 LOG("Shutting down sound system...");
113 OPENAL_StopSound(OPENAL_ALL);
115 // this is causing problems on Linux, but we'll force an _exit() a little
116 // later in the shutdown process. --ryan.
119 for (int i = 0; i < sounds_count; ++i) {
120 OPENAL_Sample_Free(samp[i]);
134 skybox = new SkyBox();
137 void Game::deleteGame()
143 terraintexture.destroy();
144 terraintexture2.destroy();
145 cursortexture.destroy();
146 Maparrowtexture.destroy();
147 Mapboxtexture.destroy();
148 Mapcircletexture.destroy();
149 hawktexture.destroy();
150 loadscreentexture.destroy();
152 for (int i = 0; i < 10; i++)
153 Mainmenuitems[i].destroy();
155 glDeleteTextures(1, &screentexture);
156 glDeleteTextures(1, &screentexture2);
163 void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize)
167 LOG(std::string("Loading (S)...") + fileName);
170 float temptexdetail = texdetail;
173 // Converting file to something os specific
174 char * fixedFN = ConvertFileName(fileName);
177 unsigned char fileNamep[256];
178 CopyCStringToPascal(fixedFN, fileNamep);
180 upload_image( fileNamep , 0);
181 texdetail = temptexdetail;
183 int bytesPerPixel = texture.bpp / 8;
186 for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
187 if ((i + 1) % 4 || bytesPerPixel == 3) {
188 array[tempnum] = texture.data[i];
196 //***************> ResizeGLScene() <******/
197 GLvoid Game::ReSizeGLScene(float fov, float pnear)
199 if (screenheight == 0) {
203 glViewport(0, 0, screenwidth, screenheight);
205 glMatrixMode(GL_PROJECTION);
208 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
210 glMatrixMode(GL_MODELVIEW);
214 void Game::LoadingScreen()
216 static float loadprogress;
217 static AbsoluteTime frametime = {0, 0};
218 AbsoluteTime currTime = UpTime ();
219 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
221 if (0 > deltaTime) // if negative microseconds
222 deltaTime /= -1000000.0;
223 else // else milliseconds
226 multiplier = deltaTime;
227 if (multiplier < .001)
231 if (multiplier > .05) {
232 frametime = currTime; // reset for next time interval
236 glClearColor(0, 0, 0, 1);
237 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
240 loadtime += multiplier * 4;
242 loadprogress = loadtime;
243 if (loadprogress > 100)
248 glEnable(GL_TEXTURE_2D);
249 loadscreentexture.bind();
250 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
251 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
252 glDisable(GL_DEPTH_TEST);
253 glDisable(GL_CULL_FACE);
254 glDisable(GL_LIGHTING);
256 glMatrixMode(GL_PROJECTION);
259 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
260 glMatrixMode(GL_MODELVIEW);
263 glTranslatef(screenwidth / 2, screenheight / 2, 0);
264 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
265 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
267 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
270 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
271 glVertex3f(-1, -1, 0.0f);
272 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
273 glVertex3f(1, -1, 0.0f);
274 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
275 glVertex3f(1, 1, 0.0f);
276 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
277 glVertex3f(-1, 1, 0.0f);
283 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
284 glVertex3f(-1, -1, 0.0f);
285 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
286 glVertex3f(1, -1, 0.0f);
287 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
288 glVertex3f(1, 1, 0.0f);
289 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
290 glVertex3f(-1, 1, 0.0f);
293 glDisable(GL_TEXTURE_2D);
294 glMatrixMode(GL_PROJECTION);
296 glMatrixMode(GL_MODELVIEW);
301 glEnable(GL_TEXTURE_2D);
302 loadscreentexture.bind();
303 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
304 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
305 glDisable(GL_DEPTH_TEST);
306 glDisable(GL_CULL_FACE);
307 glDisable(GL_LIGHTING);
309 glMatrixMode(GL_PROJECTION);
312 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
313 glMatrixMode(GL_MODELVIEW);
316 glTranslatef(screenwidth / 2, screenheight / 2, 0);
317 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
318 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
320 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
323 glTexCoord2f(0 + .5, 0 + .5);
324 glVertex3f(-1, -1, 0.0f);
325 glTexCoord2f(1 + .5, 0 + .5);
326 glVertex3f(1, -1, 0.0f);
327 glTexCoord2f(1 + .5, 1 + .5);
328 glVertex3f(1, 1, 0.0f);
329 glTexCoord2f(0 + .5, 1 + .5);
330 glVertex3f(-1, 1, 0.0f);
333 glDisable(GL_TEXTURE_2D);
334 glMatrixMode(GL_PROJECTION);
336 glMatrixMode(GL_MODELVIEW);
341 glEnable(GL_TEXTURE_2D);
342 loadscreentexture.bind();
343 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
344 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
345 glDisable(GL_DEPTH_TEST);
346 glDisable(GL_CULL_FACE);
347 glDisable(GL_LIGHTING);
349 glMatrixMode(GL_PROJECTION);
352 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
353 glMatrixMode(GL_MODELVIEW);
356 glTranslatef(screenwidth / 2, screenheight / 2, 0);
357 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
358 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
360 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
363 glTexCoord2f(0 + .2, 0 + .8);
364 glVertex3f(-1, -1, 0.0f);
365 glTexCoord2f(1 + .2, 0 + .8);
366 glVertex3f(1, -1, 0.0f);
367 glTexCoord2f(1 + .2, 1 + .8);
368 glVertex3f(1, 1, 0.0f);
369 glTexCoord2f(0 + .2, 1 + .8);
370 glVertex3f(-1, 1, 0.0f);
373 glDisable(GL_TEXTURE_2D);
374 glMatrixMode(GL_PROJECTION);
376 glMatrixMode(GL_MODELVIEW);
383 if (flashamount > 0) {
387 flashamount -= multiplier;
391 glDisable(GL_DEPTH_TEST);
392 glDisable(GL_CULL_FACE);
393 glDisable(GL_LIGHTING);
394 glDisable(GL_TEXTURE_2D);
396 glMatrixMode(GL_PROJECTION);
399 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
400 glMatrixMode(GL_MODELVIEW);
403 glScalef(screenwidth, screenheight, 1);
404 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
406 glColor4f(flashr, flashg, flashb, flashamount);
408 glVertex3f(0, 0, 0.0f);
409 glVertex3f(256, 0, 0.0f);
410 glVertex3f(256, 256, 0.0f);
411 glVertex3f(0, 256, 0.0f);
413 glMatrixMode(GL_PROJECTION);
415 glMatrixMode(GL_MODELVIEW);
417 glEnable(GL_DEPTH_TEST);
418 glEnable(GL_CULL_FACE);
427 void FadeLoadingScreen(float howmuch)
429 static float loadprogress;
433 glClearColor(0, 0, 0, 1);
434 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
436 loadprogress = howmuch;
440 glDisable(GL_TEXTURE_2D);
441 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
442 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
443 glDisable(GL_DEPTH_TEST);
444 glDisable(GL_CULL_FACE);
445 glDisable(GL_LIGHTING);
447 glMatrixMode(GL_PROJECTION);
450 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
451 glMatrixMode(GL_MODELVIEW);
454 glTranslatef(screenwidth / 2, screenheight / 2, 0);
455 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
456 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
458 glColor4f(loadprogress / 100, 0, 0, 1);
462 glVertex3f(-1, -1, 0.0f);
464 glVertex3f(1, -1, 0.0f);
466 glVertex3f(1, 1, 0.0f);
468 glVertex3f(-1, 1, 0.0f);
471 glDisable(GL_TEXTURE_2D);
472 glMatrixMode(GL_PROJECTION);
474 glMatrixMode(GL_MODELVIEW);
483 extern bool cmdline(const char *cmd);
485 void Game::InitGame()
489 numchallengelevels = 14;
491 accountactive = Account::loadFile(":Data:Users");
497 whichjointstartarray[0] = righthip;
498 whichjointendarray[0] = rightfoot;
500 whichjointstartarray[1] = righthip;
501 whichjointendarray[1] = rightankle;
503 whichjointstartarray[2] = righthip;
504 whichjointendarray[2] = rightknee;
506 whichjointstartarray[3] = rightknee;
507 whichjointendarray[3] = rightankle;
509 whichjointstartarray[4] = rightankle;
510 whichjointendarray[4] = rightfoot;
512 whichjointstartarray[5] = lefthip;
513 whichjointendarray[5] = leftfoot;
515 whichjointstartarray[6] = lefthip;
516 whichjointendarray[6] = leftankle;
518 whichjointstartarray[7] = lefthip;
519 whichjointendarray[7] = leftknee;
521 whichjointstartarray[8] = leftknee;
522 whichjointendarray[8] = leftankle;
524 whichjointstartarray[9] = leftankle;
525 whichjointendarray[9] = leftfoot;
527 whichjointstartarray[10] = abdomen;
528 whichjointendarray[10] = rightshoulder;
530 whichjointstartarray[11] = abdomen;
531 whichjointendarray[11] = rightelbow;
533 whichjointstartarray[12] = abdomen;
534 whichjointendarray[12] = rightwrist;
536 whichjointstartarray[13] = abdomen;
537 whichjointendarray[13] = righthand;
539 whichjointstartarray[14] = rightshoulder;
540 whichjointendarray[14] = rightelbow;
542 whichjointstartarray[15] = rightelbow;
543 whichjointendarray[15] = rightwrist;
545 whichjointstartarray[16] = rightwrist;
546 whichjointendarray[16] = righthand;
548 whichjointstartarray[17] = abdomen;
549 whichjointendarray[17] = leftshoulder;
551 whichjointstartarray[18] = abdomen;
552 whichjointendarray[18] = leftelbow;
554 whichjointstartarray[19] = abdomen;
555 whichjointendarray[19] = leftwrist;
557 whichjointstartarray[20] = abdomen;
558 whichjointendarray[20] = lefthand;
560 whichjointstartarray[21] = leftshoulder;
561 whichjointendarray[21] = leftelbow;
563 whichjointstartarray[22] = leftelbow;
564 whichjointendarray[22] = leftwrist;
566 whichjointstartarray[23] = leftwrist;
567 whichjointendarray[23] = lefthand;
569 whichjointstartarray[24] = abdomen;
570 whichjointendarray[24] = neck;
572 whichjointstartarray[25] = neck;
573 whichjointendarray[25] = head;
575 FadeLoadingScreen(0);
579 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
581 int temptexdetail = texdetail;
583 text->LoadFontTexture(":Data:Textures:Font.png");
585 texdetail = temptexdetail;
587 FadeLoadingScreen(10);
599 LOG("Initializing sound system...");
602 unsigned char rc = 0;
603 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
604 if (cmdline("forceoss")) // ...but let user override that.
605 output = OPENAL_OUTPUT_OSS;
606 else if (cmdline("nosound"))
607 output = OPENAL_OUTPUT_NOSOUND;
609 OPENAL_SetOutput(output);
610 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
611 // if we tried ALSA and failed, fall back to OSS.
612 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
614 output = OPENAL_OUTPUT_OSS;
615 OPENAL_SetOutput(output);
616 rc = OPENAL_Init(44100, 32, 0);
622 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
623 OPENAL_SetOutput(output);
624 rc = OPENAL_Init(44100, 32, 0);
627 OPENAL_Init(44100, 32, 0);
630 OPENAL_SetSFXMasterVolume((int)(volume * 255));
634 emit_stream_np(stream_menutheme);
636 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
638 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
639 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
640 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
642 temptexdetail = texdetail;
645 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
646 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
647 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
648 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
649 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
650 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
651 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
653 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
654 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
655 texdetail = temptexdetail;
657 FadeLoadingScreen(95);
667 newscreenwidth = screenwidth;
668 newscreenheight = screenheight;
674 void Game::LoadScreenTexture()
676 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
678 if (!Game::screentexture)
679 glGenTextures( 1, &Game::screentexture );
680 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
683 glEnable(GL_TEXTURE_2D);
684 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
685 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
686 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
688 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
691 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
692 void Game::LoadStuff()
694 static float temptexdetail;
695 static float viewdistdetail;
705 for (auto p:Person::players) {
706 p->skeleton.drawmodel.textureptr.destroy();
709 i = abs(Random() % 4);
710 visibleloading = 0; //don't use loadscreentexture yet
711 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
714 temptexdetail = texdetail;
716 text->LoadFontTexture(":Data:Textures:Font.png");
718 texdetail = temptexdetail;
723 viewdistance = 50 * megascale * viewdistdetail;
735 realtexdetail = texdetail;
737 LOG("Loading weapon data...");
739 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
740 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
741 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
742 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
743 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
744 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
745 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
747 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
748 Weapon::throwingknifemodel.Scale(.001, .001, .001);
749 //Weapon::throwingknifemodel.Rotate(0,0,-90);
750 Weapon::throwingknifemodel.Rotate(90, 0, 0);
751 Weapon::throwingknifemodel.Rotate(0, 90, 0);
752 Weapon::throwingknifemodel.flat = 0;
753 Weapon::throwingknifemodel.CalculateNormals(1);
754 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
756 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
757 Weapon::swordmodel.Scale(.001, .001, .001);
758 //Weapon::swordmodel.Rotate(0,0,-90);
759 Weapon::swordmodel.Rotate(90, 0, 0);
760 Weapon::swordmodel.Rotate(0, 90, 0);
761 Weapon::swordmodel.Rotate(0, 0, 90);
762 Weapon::swordmodel.flat = 1;
763 Weapon::swordmodel.CalculateNormals(1);
764 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
766 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
767 Weapon::staffmodel.Scale(.005, .005, .005);
768 //Weapon::staffmodel.Rotate(0,0,-90);
769 Weapon::staffmodel.Rotate(90, 0, 0);
770 Weapon::staffmodel.Rotate(0, 90, 0);
771 Weapon::staffmodel.Rotate(0, 0, 90);
772 Weapon::staffmodel.flat = 1;
773 Weapon::staffmodel.CalculateNormals(1);
774 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
776 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
777 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
778 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
779 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
782 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
783 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
784 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
787 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
788 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
789 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
790 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
791 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
792 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
793 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
794 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
795 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
796 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
797 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
801 ReSizeGLScene(90, .01);
813 //Set up distant light
814 light.color[0] = .95;
815 light.color[1] = .95;
817 light.ambient[0] = .2;
818 light.ambient[1] = .2;
819 light.ambient[2] = .24;
820 light.location.x = 1;
821 light.location.y = 1;
822 light.location.z = -.2;
823 Normalise(&light.location);
833 texscale = .2 / megascale / viewdistdetail;
834 terrain.scale = 3 * megascale * viewdistdetail;
836 viewer.x = terrain.size / 2 * terrain.scale;
837 viewer.z = terrain.size / 2 * terrain.scale;
839 hawk.load((char *)":Data:Models:hawk.solid", 1);
840 hawk.Scale(.03, .03, .03);
841 hawk.Rotate(90, 1, 1);
842 hawk.CalculateNormals(0);
843 hawk.ScaleNormals(-1, -1, -1);
844 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
845 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
846 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
848 eye.load((char *)":Data:Models:eye.solid", 1);
849 eye.Scale(.03, .03, .03);
850 eye.CalculateNormals(0);
852 cornea.load((char *)":Data:Models:cornea.solid", 1);
853 cornea.Scale(.03, .03, .03);
854 cornea.CalculateNormals(0);
856 iris.load((char *)":Data:Models:iris.solid", 1);
857 iris.Scale(.03, .03, .03);
858 iris.CalculateNormals(0);
860 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
861 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
871 //Fix knife stab, too lazy to do it manually
875 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
876 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
877 animation[knifesneakattackanim].position[i][j] += moveamount;
883 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
884 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
885 animation[knifesneakattackedanim].position[i][j] += moveamount;
891 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
892 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
893 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
894 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
895 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
897 animation[dead1anim].speed[0] = 0.001;
898 animation[dead2anim].speed[0] = 0.001;
899 animation[dead3anim].speed[0] = 0.001;
900 animation[dead4anim].speed[0] = 0.001;
902 animation[dead1anim].speed[1] = 0.001;
903 animation[dead2anim].speed[1] = 0.001;
904 animation[dead3anim].speed[1] = 0.001;
905 animation[dead4anim].speed[1] = 0.001;
907 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
908 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
909 animation[swordsneakattackanim].position[i][j] += moveamount;
913 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
914 animation[swordsneakattackanim].weapontarget[j] += moveamount;
919 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
920 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
921 animation[swordsneakattackedanim].position[i][j] += moveamount;
926 temptexdetail = texdetail;
928 texdetail = temptexdetail;
932 if (!screentexture) {
936 if (targetlevel != 7) {
937 emit_sound_at(fireendsound);