2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
22 #include "openal_wrapper.h"
23 #include "Animation.h"
26 extern float screenwidth, screenheight;
27 extern float viewdistance;
29 extern XYZ lightlocation;
30 extern float fadestart;
31 extern float texscale;
34 extern Skeleton testskeleton;
36 extern Terrain terrain;
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;
48 extern bool musictoggle;
49 extern int environment;
50 extern bool ambientsound;
51 extern float multiplier;
52 extern int netdatanew;
54 extern bool stillloading;
55 extern ImageRec texture;
59 extern bool visibleloading;
60 extern float flashamount, flashr, flashg, flashb;
61 extern int flashdelay;
62 extern int whichjointstartarray[26];
63 extern int whichjointendarray[26];
64 extern int difficulty;
65 extern float tintr, tintg, tintb;
66 extern float slomospeed;
67 extern bool gamestarted;
69 extern int numdialogues;
70 extern int numdialogueboxes[20];
71 extern int dialoguetype[20];
72 extern int dialogueboxlocation[20][20];
73 extern float dialogueboxcolor[20][20][3];
74 extern int dialogueboxsound[20][20];
75 extern char dialoguetext[20][20][128];
76 extern char dialoguename[20][20][64];
77 extern XYZ dialoguecamera[20][20];
78 extern float dialoguecamerayaw[20][20];
79 extern float dialoguecamerapitch[20][20];
80 extern int indialogue;
81 extern int whichdialogue;
82 extern float dialoguetime;
84 extern float accountcampaignhighscore[10];
85 extern float accountcampaignfasttime[10];
86 extern float accountcampaignscore[10];
87 extern float accountcampaigntime[10];
89 extern int accountcampaignchoicesmade[10];
90 extern int accountcampaignchoices[10][5000];
92 void LOG(const std::string &fmt, ...)
94 // !!! FIXME: write me.
101 if (Game::endgame == 2) {
102 Game::accountactive->endGame();
106 Account::saveFile(":Data:Users", Game::accountactive);
110 LOG("Shutting down sound system...");
112 OPENAL_StopSound(OPENAL_ALL);
114 // this is causing problems on Linux, but we'll force an _exit() a little
115 // later in the shutdown process. --ryan.
118 for (int i = 0; i < sounds_count; ++i) {
119 OPENAL_Sample_Free(samp[i]);
133 skybox = new SkyBox();
136 void Game::deleteGame()
142 terraintexture.destroy();
143 terraintexture2.destroy();
144 cursortexture.destroy();
145 Maparrowtexture.destroy();
146 Mapboxtexture.destroy();
147 Mapcircletexture.destroy();
148 hawktexture.destroy();
149 loadscreentexture.destroy();
151 for (int i = 0; i < 10; i++)
152 Mainmenuitems[i].destroy();
154 glDeleteTextures(1, &screentexture);
155 glDeleteTextures(1, &screentexture2);
162 void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize)
166 LOG(std::string("Loading (S)...") + fileName);
169 float temptexdetail = texdetail;
173 upload_image(ConvertFileName(fileName));
174 texdetail = temptexdetail;
176 int bytesPerPixel = texture.bpp / 8;
179 for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
180 if ((i + 1) % 4 || bytesPerPixel == 3) {
181 array[tempnum] = texture.data[i];
189 //***************> ResizeGLScene() <******/
190 GLvoid Game::ReSizeGLScene(float fov, float pnear)
192 if (screenheight == 0) {
196 glViewport(0, 0, screenwidth, screenheight);
198 glMatrixMode(GL_PROJECTION);
201 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
203 glMatrixMode(GL_MODELVIEW);
207 void Game::LoadingScreen()
209 static float loadprogress;
210 static AbsoluteTime frametime = {0, 0};
211 AbsoluteTime currTime = UpTime ();
212 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
214 if (0 > deltaTime) // if negative microseconds
215 deltaTime /= -1000000.0;
216 else // else milliseconds
219 multiplier = deltaTime;
220 if (multiplier < .001)
224 if (multiplier > .05) {
225 frametime = currTime; // reset for next time interval
229 glClearColor(0, 0, 0, 1);
230 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
233 loadtime += multiplier * 4;
235 loadprogress = loadtime;
236 if (loadprogress > 100)
241 glEnable(GL_TEXTURE_2D);
242 loadscreentexture.bind();
243 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
244 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
245 glDisable(GL_DEPTH_TEST);
246 glDisable(GL_CULL_FACE);
247 glDisable(GL_LIGHTING);
249 glMatrixMode(GL_PROJECTION);
252 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
253 glMatrixMode(GL_MODELVIEW);
256 glTranslatef(screenwidth / 2, screenheight / 2, 0);
257 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
258 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
260 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
263 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
264 glVertex3f(-1, -1, 0.0f);
265 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
266 glVertex3f(1, -1, 0.0f);
267 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
268 glVertex3f(1, 1, 0.0f);
269 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
270 glVertex3f(-1, 1, 0.0f);
276 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
277 glVertex3f(-1, -1, 0.0f);
278 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
279 glVertex3f(1, -1, 0.0f);
280 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
281 glVertex3f(1, 1, 0.0f);
282 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
283 glVertex3f(-1, 1, 0.0f);
286 glDisable(GL_TEXTURE_2D);
287 glMatrixMode(GL_PROJECTION);
289 glMatrixMode(GL_MODELVIEW);
294 glEnable(GL_TEXTURE_2D);
295 loadscreentexture.bind();
296 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
297 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
298 glDisable(GL_DEPTH_TEST);
299 glDisable(GL_CULL_FACE);
300 glDisable(GL_LIGHTING);
302 glMatrixMode(GL_PROJECTION);
305 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
306 glMatrixMode(GL_MODELVIEW);
309 glTranslatef(screenwidth / 2, screenheight / 2, 0);
310 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
311 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
313 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
316 glTexCoord2f(0 + .5, 0 + .5);
317 glVertex3f(-1, -1, 0.0f);
318 glTexCoord2f(1 + .5, 0 + .5);
319 glVertex3f(1, -1, 0.0f);
320 glTexCoord2f(1 + .5, 1 + .5);
321 glVertex3f(1, 1, 0.0f);
322 glTexCoord2f(0 + .5, 1 + .5);
323 glVertex3f(-1, 1, 0.0f);
326 glDisable(GL_TEXTURE_2D);
327 glMatrixMode(GL_PROJECTION);
329 glMatrixMode(GL_MODELVIEW);
334 glEnable(GL_TEXTURE_2D);
335 loadscreentexture.bind();
336 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
337 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
338 glDisable(GL_DEPTH_TEST);
339 glDisable(GL_CULL_FACE);
340 glDisable(GL_LIGHTING);
342 glMatrixMode(GL_PROJECTION);
345 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
346 glMatrixMode(GL_MODELVIEW);
349 glTranslatef(screenwidth / 2, screenheight / 2, 0);
350 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
351 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
353 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
356 glTexCoord2f(0 + .2, 0 + .8);
357 glVertex3f(-1, -1, 0.0f);
358 glTexCoord2f(1 + .2, 0 + .8);
359 glVertex3f(1, -1, 0.0f);
360 glTexCoord2f(1 + .2, 1 + .8);
361 glVertex3f(1, 1, 0.0f);
362 glTexCoord2f(0 + .2, 1 + .8);
363 glVertex3f(-1, 1, 0.0f);
366 glDisable(GL_TEXTURE_2D);
367 glMatrixMode(GL_PROJECTION);
369 glMatrixMode(GL_MODELVIEW);
376 if (flashamount > 0) {
380 flashamount -= multiplier;
384 glDisable(GL_DEPTH_TEST);
385 glDisable(GL_CULL_FACE);
386 glDisable(GL_LIGHTING);
387 glDisable(GL_TEXTURE_2D);
389 glMatrixMode(GL_PROJECTION);
392 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
393 glMatrixMode(GL_MODELVIEW);
396 glScalef(screenwidth, screenheight, 1);
397 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
399 glColor4f(flashr, flashg, flashb, flashamount);
401 glVertex3f(0, 0, 0.0f);
402 glVertex3f(256, 0, 0.0f);
403 glVertex3f(256, 256, 0.0f);
404 glVertex3f(0, 256, 0.0f);
406 glMatrixMode(GL_PROJECTION);
408 glMatrixMode(GL_MODELVIEW);
410 glEnable(GL_DEPTH_TEST);
411 glEnable(GL_CULL_FACE);
420 void FadeLoadingScreen(float howmuch)
422 static float loadprogress;
426 glClearColor(0, 0, 0, 1);
427 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
429 loadprogress = howmuch;
433 glDisable(GL_TEXTURE_2D);
434 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
435 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
436 glDisable(GL_DEPTH_TEST);
437 glDisable(GL_CULL_FACE);
438 glDisable(GL_LIGHTING);
440 glMatrixMode(GL_PROJECTION);
443 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
444 glMatrixMode(GL_MODELVIEW);
447 glTranslatef(screenwidth / 2, screenheight / 2, 0);
448 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
449 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
451 glColor4f(loadprogress / 100, 0, 0, 1);
455 glVertex3f(-1, -1, 0.0f);
457 glVertex3f(1, -1, 0.0f);
459 glVertex3f(1, 1, 0.0f);
461 glVertex3f(-1, 1, 0.0f);
464 glDisable(GL_TEXTURE_2D);
465 glMatrixMode(GL_PROJECTION);
467 glMatrixMode(GL_MODELVIEW);
476 extern bool cmdline(const char *cmd);
478 void Game::InitGame()
482 numchallengelevels = 14;
484 accountactive = Account::loadFile(":Data:Users");
490 whichjointstartarray[0] = righthip;
491 whichjointendarray[0] = rightfoot;
493 whichjointstartarray[1] = righthip;
494 whichjointendarray[1] = rightankle;
496 whichjointstartarray[2] = righthip;
497 whichjointendarray[2] = rightknee;
499 whichjointstartarray[3] = rightknee;
500 whichjointendarray[3] = rightankle;
502 whichjointstartarray[4] = rightankle;
503 whichjointendarray[4] = rightfoot;
505 whichjointstartarray[5] = lefthip;
506 whichjointendarray[5] = leftfoot;
508 whichjointstartarray[6] = lefthip;
509 whichjointendarray[6] = leftankle;
511 whichjointstartarray[7] = lefthip;
512 whichjointendarray[7] = leftknee;
514 whichjointstartarray[8] = leftknee;
515 whichjointendarray[8] = leftankle;
517 whichjointstartarray[9] = leftankle;
518 whichjointendarray[9] = leftfoot;
520 whichjointstartarray[10] = abdomen;
521 whichjointendarray[10] = rightshoulder;
523 whichjointstartarray[11] = abdomen;
524 whichjointendarray[11] = rightelbow;
526 whichjointstartarray[12] = abdomen;
527 whichjointendarray[12] = rightwrist;
529 whichjointstartarray[13] = abdomen;
530 whichjointendarray[13] = righthand;
532 whichjointstartarray[14] = rightshoulder;
533 whichjointendarray[14] = rightelbow;
535 whichjointstartarray[15] = rightelbow;
536 whichjointendarray[15] = rightwrist;
538 whichjointstartarray[16] = rightwrist;
539 whichjointendarray[16] = righthand;
541 whichjointstartarray[17] = abdomen;
542 whichjointendarray[17] = leftshoulder;
544 whichjointstartarray[18] = abdomen;
545 whichjointendarray[18] = leftelbow;
547 whichjointstartarray[19] = abdomen;
548 whichjointendarray[19] = leftwrist;
550 whichjointstartarray[20] = abdomen;
551 whichjointendarray[20] = lefthand;
553 whichjointstartarray[21] = leftshoulder;
554 whichjointendarray[21] = leftelbow;
556 whichjointstartarray[22] = leftelbow;
557 whichjointendarray[22] = leftwrist;
559 whichjointstartarray[23] = leftwrist;
560 whichjointendarray[23] = lefthand;
562 whichjointstartarray[24] = abdomen;
563 whichjointendarray[24] = neck;
565 whichjointstartarray[25] = neck;
566 whichjointendarray[25] = head;
568 FadeLoadingScreen(0);
572 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
574 int temptexdetail = texdetail;
576 text->LoadFontTexture(":Data:Textures:Font.png");
578 texdetail = temptexdetail;
580 FadeLoadingScreen(10);
592 LOG("Initializing sound system...");
595 unsigned char rc = 0;
596 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
597 if (cmdline("forceoss")) // ...but let user override that.
598 output = OPENAL_OUTPUT_OSS;
599 else if (cmdline("nosound"))
600 output = OPENAL_OUTPUT_NOSOUND;
602 OPENAL_SetOutput(output);
603 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
604 // if we tried ALSA and failed, fall back to OSS.
605 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
607 output = OPENAL_OUTPUT_OSS;
608 OPENAL_SetOutput(output);
609 rc = OPENAL_Init(44100, 32, 0);
615 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
616 OPENAL_SetOutput(output);
617 rc = OPENAL_Init(44100, 32, 0);
620 OPENAL_Init(44100, 32, 0);
623 OPENAL_SetSFXMasterVolume((int)(volume * 255));
627 emit_stream_np(stream_menutheme);
629 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
631 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
632 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
633 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
635 temptexdetail = texdetail;
638 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
639 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
640 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
641 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
642 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
643 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
644 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
646 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
647 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
648 texdetail = temptexdetail;
650 FadeLoadingScreen(95);
660 newscreenwidth = screenwidth;
661 newscreenheight = screenheight;
667 void Game::LoadScreenTexture()
669 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
671 if (!Game::screentexture)
672 glGenTextures( 1, &Game::screentexture );
673 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
676 glEnable(GL_TEXTURE_2D);
677 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
678 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
679 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
681 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
684 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
685 void Game::LoadStuff()
687 static float temptexdetail;
688 static float viewdistdetail;
698 for (auto p:Person::players) {
699 p->skeleton.drawmodel.textureptr.destroy();
702 i = abs(Random() % 4);
703 visibleloading = 0; //don't use loadscreentexture yet
704 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
707 temptexdetail = texdetail;
709 text->LoadFontTexture(":Data:Textures:Font.png");
711 texdetail = temptexdetail;
716 viewdistance = 50 * megascale * viewdistdetail;
728 realtexdetail = texdetail;
730 LOG("Loading weapon data...");
732 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
733 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
734 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
735 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
736 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
737 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
738 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
740 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
741 Weapon::throwingknifemodel.Scale(.001, .001, .001);
742 Weapon::throwingknifemodel.Rotate(90, 0, 0);
743 Weapon::throwingknifemodel.Rotate(0, 90, 0);
744 Weapon::throwingknifemodel.flat = 0;
745 Weapon::throwingknifemodel.CalculateNormals(1);
747 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
748 Weapon::swordmodel.Scale(.001, .001, .001);
749 Weapon::swordmodel.Rotate(90, 0, 0);
750 Weapon::swordmodel.Rotate(0, 90, 0);
751 Weapon::swordmodel.Rotate(0, 0, 90);
752 Weapon::swordmodel.flat = 1;
753 Weapon::swordmodel.CalculateNormals(1);
755 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
756 Weapon::staffmodel.Scale(.005, .005, .005);
757 Weapon::staffmodel.Rotate(90, 0, 0);
758 Weapon::staffmodel.Rotate(0, 90, 0);
759 Weapon::staffmodel.Rotate(0, 0, 90);
760 Weapon::staffmodel.flat = 1;
761 Weapon::staffmodel.CalculateNormals(1);
763 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
764 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
765 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
766 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
769 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
770 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
771 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
774 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
775 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
776 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
777 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
778 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
779 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
780 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
781 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
782 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
783 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
784 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
788 ReSizeGLScene(90, .01);
800 //Set up distant light
801 light.color[0] = .95;
802 light.color[1] = .95;
804 light.ambient[0] = .2;
805 light.ambient[1] = .2;
806 light.ambient[2] = .24;
807 light.location.x = 1;
808 light.location.y = 1;
809 light.location.z = -.2;
810 Normalise(&light.location);
820 texscale = .2 / megascale / viewdistdetail;
821 terrain.scale = 3 * megascale * viewdistdetail;
823 viewer.x = terrain.size / 2 * terrain.scale;
824 viewer.z = terrain.size / 2 * terrain.scale;
826 hawk.load((char *)":Data:Models:hawk.solid", 1);
827 hawk.Scale(.03, .03, .03);
828 hawk.Rotate(90, 1, 1);
829 hawk.CalculateNormals(0);
830 hawk.ScaleNormals(-1, -1, -1);
831 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
832 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
833 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
835 eye.load((char *)":Data:Models:eye.solid", 1);
836 eye.Scale(.03, .03, .03);
837 eye.CalculateNormals(0);
839 cornea.load((char *)":Data:Models:cornea.solid", 1);
840 cornea.Scale(.03, .03, .03);
841 cornea.CalculateNormals(0);
843 iris.load((char *)":Data:Models:iris.solid", 1);
844 iris.Scale(.03, .03, .03);
845 iris.CalculateNormals(0);
847 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
848 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
858 //Fix knife stab, too lazy to do it manually
862 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
863 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
864 animation[knifesneakattackanim].position[i][j] += moveamount;
870 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
871 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
872 animation[knifesneakattackedanim].position[i][j] += moveamount;
878 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
879 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
880 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
881 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
882 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
884 animation[dead1anim].speed[0] = 0.001;
885 animation[dead2anim].speed[0] = 0.001;
886 animation[dead3anim].speed[0] = 0.001;
887 animation[dead4anim].speed[0] = 0.001;
889 animation[dead1anim].speed[1] = 0.001;
890 animation[dead2anim].speed[1] = 0.001;
891 animation[dead3anim].speed[1] = 0.001;
892 animation[dead4anim].speed[1] = 0.001;
894 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
895 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
896 animation[swordsneakattackanim].position[i][j] += moveamount;
900 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
901 animation[swordsneakattackanim].weapontarget[j] += moveamount;
906 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
907 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
908 animation[swordsneakattackedanim].position[i][j] += moveamount;
913 temptexdetail = texdetail;
915 texdetail = temptexdetail;
919 if (!screentexture) {
923 if (targetlevel != 7) {
924 emit_sound_at(fireendsound);