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;
58 extern bool visibleloading;
59 extern float flashamount, flashr, flashg, flashb;
60 extern int flashdelay;
61 extern int whichjointstartarray[26];
62 extern int whichjointendarray[26];
63 extern int difficulty;
64 extern float slomospeed;
65 extern bool gamestarted;
67 extern int numdialogues;
68 extern int numdialogueboxes[20];
69 extern int dialoguetype[20];
70 extern int dialogueboxlocation[20][20];
71 extern float dialogueboxcolor[20][20][3];
72 extern int dialogueboxsound[20][20];
73 extern char dialoguetext[20][20][128];
74 extern char dialoguename[20][20][64];
75 extern XYZ dialoguecamera[20][20];
76 extern float dialoguecamerayaw[20][20];
77 extern float dialoguecamerapitch[20][20];
78 extern int indialogue;
79 extern int whichdialogue;
80 extern float dialoguetime;
82 extern float accountcampaignhighscore[10];
83 extern float accountcampaignfasttime[10];
84 extern float accountcampaignscore[10];
85 extern float accountcampaigntime[10];
87 extern int accountcampaignchoicesmade[10];
88 extern int accountcampaignchoices[10][5000];
90 void LOG(const std::string &fmt, ...)
92 // !!! FIXME: write me.
99 if (Game::endgame == 2) {
100 Game::accountactive->endGame();
104 Account::saveFile(":Data:Users", Game::accountactive);
108 LOG("Shutting down sound system...");
110 OPENAL_StopSound(OPENAL_ALL);
112 // this is causing problems on Linux, but we'll force an _exit() a little
113 // later in the shutdown process. --ryan.
116 for (int i = 0; i < sounds_count; ++i) {
117 OPENAL_Sample_Free(samp[i]);
127 skybox = new SkyBox();
130 void Game::deleteGame()
136 terraintexture.destroy();
137 terraintexture2.destroy();
138 cursortexture.destroy();
139 Maparrowtexture.destroy();
140 Mapboxtexture.destroy();
141 Mapcircletexture.destroy();
142 hawktexture.destroy();
143 loadscreentexture.destroy();
145 for (int i = 0; i < 10; i++)
146 Mainmenuitems[i].destroy();
148 glDeleteTextures(1, &screentexture);
149 glDeleteTextures(1, &screentexture2);
156 void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize)
160 LOG(std::string("Loading (S)...") + fileName);
163 float temptexdetail = texdetail;
168 load_image(ConvertFileName(fileName), texture);
169 texdetail = temptexdetail;
171 int bytesPerPixel = texture.bpp / 8;
174 for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
175 if ((i + 1) % 4 || bytesPerPixel == 3) {
176 array[tempnum] = texture.data[i];
184 //***************> ResizeGLScene() <******/
185 GLvoid Game::ReSizeGLScene(float fov, float pnear)
187 if (screenheight == 0) {
191 glViewport(0, 0, screenwidth, screenheight);
193 glMatrixMode(GL_PROJECTION);
196 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
198 glMatrixMode(GL_MODELVIEW);
202 void Game::LoadingScreen()
204 static float loadprogress;
205 static AbsoluteTime frametime = {0, 0};
206 AbsoluteTime currTime = UpTime ();
207 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
209 if (0 > deltaTime) // if negative microseconds
210 deltaTime /= -1000000.0;
211 else // else milliseconds
214 multiplier = deltaTime;
215 if (multiplier < .001)
219 if (multiplier > .05) {
220 frametime = currTime; // reset for next time interval
224 glClearColor(0, 0, 0, 1);
225 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
228 loadtime += multiplier * 4;
230 loadprogress = loadtime;
231 if (loadprogress > 100)
236 glEnable(GL_TEXTURE_2D);
237 loadscreentexture.bind();
238 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
239 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
240 glDisable(GL_DEPTH_TEST);
241 glDisable(GL_CULL_FACE);
242 glDisable(GL_LIGHTING);
244 glMatrixMode(GL_PROJECTION);
247 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
248 glMatrixMode(GL_MODELVIEW);
251 glTranslatef(screenwidth / 2, screenheight / 2, 0);
252 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
253 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
255 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
258 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
259 glVertex3f(-1, -1, 0.0f);
260 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
261 glVertex3f(1, -1, 0.0f);
262 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
263 glVertex3f(1, 1, 0.0f);
264 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
265 glVertex3f(-1, 1, 0.0f);
271 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
272 glVertex3f(-1, -1, 0.0f);
273 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
274 glVertex3f(1, -1, 0.0f);
275 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
276 glVertex3f(1, 1, 0.0f);
277 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
278 glVertex3f(-1, 1, 0.0f);
281 glDisable(GL_TEXTURE_2D);
282 glMatrixMode(GL_PROJECTION);
284 glMatrixMode(GL_MODELVIEW);
289 glEnable(GL_TEXTURE_2D);
290 loadscreentexture.bind();
291 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
292 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
293 glDisable(GL_DEPTH_TEST);
294 glDisable(GL_CULL_FACE);
295 glDisable(GL_LIGHTING);
297 glMatrixMode(GL_PROJECTION);
300 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
301 glMatrixMode(GL_MODELVIEW);
304 glTranslatef(screenwidth / 2, screenheight / 2, 0);
305 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
306 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
308 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
311 glTexCoord2f(0 + .5, 0 + .5);
312 glVertex3f(-1, -1, 0.0f);
313 glTexCoord2f(1 + .5, 0 + .5);
314 glVertex3f(1, -1, 0.0f);
315 glTexCoord2f(1 + .5, 1 + .5);
316 glVertex3f(1, 1, 0.0f);
317 glTexCoord2f(0 + .5, 1 + .5);
318 glVertex3f(-1, 1, 0.0f);
321 glDisable(GL_TEXTURE_2D);
322 glMatrixMode(GL_PROJECTION);
324 glMatrixMode(GL_MODELVIEW);
329 glEnable(GL_TEXTURE_2D);
330 loadscreentexture.bind();
331 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
332 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
333 glDisable(GL_DEPTH_TEST);
334 glDisable(GL_CULL_FACE);
335 glDisable(GL_LIGHTING);
337 glMatrixMode(GL_PROJECTION);
340 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
341 glMatrixMode(GL_MODELVIEW);
344 glTranslatef(screenwidth / 2, screenheight / 2, 0);
345 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
346 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
348 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
351 glTexCoord2f(0 + .2, 0 + .8);
352 glVertex3f(-1, -1, 0.0f);
353 glTexCoord2f(1 + .2, 0 + .8);
354 glVertex3f(1, -1, 0.0f);
355 glTexCoord2f(1 + .2, 1 + .8);
356 glVertex3f(1, 1, 0.0f);
357 glTexCoord2f(0 + .2, 1 + .8);
358 glVertex3f(-1, 1, 0.0f);
361 glDisable(GL_TEXTURE_2D);
362 glMatrixMode(GL_PROJECTION);
364 glMatrixMode(GL_MODELVIEW);
371 if (flashamount > 0) {
375 flashamount -= multiplier;
379 glDisable(GL_DEPTH_TEST);
380 glDisable(GL_CULL_FACE);
381 glDisable(GL_LIGHTING);
382 glDisable(GL_TEXTURE_2D);
384 glMatrixMode(GL_PROJECTION);
387 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
388 glMatrixMode(GL_MODELVIEW);
391 glScalef(screenwidth, screenheight, 1);
392 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
394 glColor4f(flashr, flashg, flashb, flashamount);
396 glVertex3f(0, 0, 0.0f);
397 glVertex3f(256, 0, 0.0f);
398 glVertex3f(256, 256, 0.0f);
399 glVertex3f(0, 256, 0.0f);
401 glMatrixMode(GL_PROJECTION);
403 glMatrixMode(GL_MODELVIEW);
405 glEnable(GL_DEPTH_TEST);
406 glEnable(GL_CULL_FACE);
415 void FadeLoadingScreen(float howmuch)
417 static float loadprogress;
421 glClearColor(0, 0, 0, 1);
422 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
424 loadprogress = howmuch;
428 glDisable(GL_TEXTURE_2D);
429 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
430 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
431 glDisable(GL_DEPTH_TEST);
432 glDisable(GL_CULL_FACE);
433 glDisable(GL_LIGHTING);
435 glMatrixMode(GL_PROJECTION);
438 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
439 glMatrixMode(GL_MODELVIEW);
442 glTranslatef(screenwidth / 2, screenheight / 2, 0);
443 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
444 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
446 glColor4f(loadprogress / 100, 0, 0, 1);
450 glVertex3f(-1, -1, 0.0f);
452 glVertex3f(1, -1, 0.0f);
454 glVertex3f(1, 1, 0.0f);
456 glVertex3f(-1, 1, 0.0f);
459 glDisable(GL_TEXTURE_2D);
460 glMatrixMode(GL_PROJECTION);
462 glMatrixMode(GL_MODELVIEW);
471 extern bool cmdline(const char *cmd);
473 void Game::InitGame()
477 numchallengelevels = 14;
479 accountactive = Account::loadFile(":Data:Users");
481 whichjointstartarray[0] = righthip;
482 whichjointendarray[0] = rightfoot;
484 whichjointstartarray[1] = righthip;
485 whichjointendarray[1] = rightankle;
487 whichjointstartarray[2] = righthip;
488 whichjointendarray[2] = rightknee;
490 whichjointstartarray[3] = rightknee;
491 whichjointendarray[3] = rightankle;
493 whichjointstartarray[4] = rightankle;
494 whichjointendarray[4] = rightfoot;
496 whichjointstartarray[5] = lefthip;
497 whichjointendarray[5] = leftfoot;
499 whichjointstartarray[6] = lefthip;
500 whichjointendarray[6] = leftankle;
502 whichjointstartarray[7] = lefthip;
503 whichjointendarray[7] = leftknee;
505 whichjointstartarray[8] = leftknee;
506 whichjointendarray[8] = leftankle;
508 whichjointstartarray[9] = leftankle;
509 whichjointendarray[9] = leftfoot;
511 whichjointstartarray[10] = abdomen;
512 whichjointendarray[10] = rightshoulder;
514 whichjointstartarray[11] = abdomen;
515 whichjointendarray[11] = rightelbow;
517 whichjointstartarray[12] = abdomen;
518 whichjointendarray[12] = rightwrist;
520 whichjointstartarray[13] = abdomen;
521 whichjointendarray[13] = righthand;
523 whichjointstartarray[14] = rightshoulder;
524 whichjointendarray[14] = rightelbow;
526 whichjointstartarray[15] = rightelbow;
527 whichjointendarray[15] = rightwrist;
529 whichjointstartarray[16] = rightwrist;
530 whichjointendarray[16] = righthand;
532 whichjointstartarray[17] = abdomen;
533 whichjointendarray[17] = leftshoulder;
535 whichjointstartarray[18] = abdomen;
536 whichjointendarray[18] = leftelbow;
538 whichjointstartarray[19] = abdomen;
539 whichjointendarray[19] = leftwrist;
541 whichjointstartarray[20] = abdomen;
542 whichjointendarray[20] = lefthand;
544 whichjointstartarray[21] = leftshoulder;
545 whichjointendarray[21] = leftelbow;
547 whichjointstartarray[22] = leftelbow;
548 whichjointendarray[22] = leftwrist;
550 whichjointstartarray[23] = leftwrist;
551 whichjointendarray[23] = lefthand;
553 whichjointstartarray[24] = abdomen;
554 whichjointendarray[24] = neck;
556 whichjointstartarray[25] = neck;
557 whichjointendarray[25] = head;
559 FadeLoadingScreen(0);
563 int temptexdetail = texdetail;
565 text->LoadFontTexture(":Data:Textures:Font.png");
567 texdetail = temptexdetail;
569 FadeLoadingScreen(10);
581 LOG("Initializing sound system...");
584 unsigned char rc = 0;
585 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
586 if (cmdline("forceoss")) // ...but let user override that.
587 output = OPENAL_OUTPUT_OSS;
588 else if (cmdline("nosound"))
589 output = OPENAL_OUTPUT_NOSOUND;
591 OPENAL_SetOutput(output);
592 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
593 // if we tried ALSA and failed, fall back to OSS.
594 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
596 output = OPENAL_OUTPUT_OSS;
597 OPENAL_SetOutput(output);
598 rc = OPENAL_Init(44100, 32, 0);
604 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
605 OPENAL_SetOutput(output);
606 rc = OPENAL_Init(44100, 32, 0);
609 OPENAL_Init(44100, 32, 0);
612 OPENAL_SetSFXMasterVolume((int)(volume * 255));
616 emit_stream_np(stream_menutheme);
618 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
620 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
621 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
622 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
624 temptexdetail = texdetail;
627 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
628 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
629 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
630 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
631 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
632 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
633 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
635 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
636 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
637 texdetail = temptexdetail;
639 FadeLoadingScreen(95);
649 newscreenwidth = screenwidth;
650 newscreenheight = screenheight;
656 void Game::LoadScreenTexture()
658 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
660 if (!Game::screentexture)
661 glGenTextures( 1, &Game::screentexture );
662 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
665 glEnable(GL_TEXTURE_2D);
666 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
667 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
668 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
670 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
673 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
674 void Game::LoadStuff()
676 static float temptexdetail;
677 static float viewdistdetail;
687 for (auto p:Person::players) {
688 p->skeleton.drawmodel.textureptr.destroy();
691 i = abs(Random() % 4);
692 visibleloading = 0; //don't use loadscreentexture yet
693 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
696 temptexdetail = texdetail;
698 text->LoadFontTexture(":Data:Textures:Font.png");
700 texdetail = temptexdetail;
705 viewdistance = 50 * megascale * viewdistdetail;
717 realtexdetail = texdetail;
719 LOG("Loading weapon data...");
721 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
722 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
723 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
724 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
725 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
726 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
727 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
729 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
730 Weapon::throwingknifemodel.Scale(.001, .001, .001);
731 Weapon::throwingknifemodel.Rotate(90, 0, 0);
732 Weapon::throwingknifemodel.Rotate(0, 90, 0);
733 Weapon::throwingknifemodel.flat = 0;
734 Weapon::throwingknifemodel.CalculateNormals(1);
736 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
737 Weapon::swordmodel.Scale(.001, .001, .001);
738 Weapon::swordmodel.Rotate(90, 0, 0);
739 Weapon::swordmodel.Rotate(0, 90, 0);
740 Weapon::swordmodel.Rotate(0, 0, 90);
741 Weapon::swordmodel.flat = 1;
742 Weapon::swordmodel.CalculateNormals(1);
744 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
745 Weapon::staffmodel.Scale(.005, .005, .005);
746 Weapon::staffmodel.Rotate(90, 0, 0);
747 Weapon::staffmodel.Rotate(0, 90, 0);
748 Weapon::staffmodel.Rotate(0, 0, 90);
749 Weapon::staffmodel.flat = 1;
750 Weapon::staffmodel.CalculateNormals(1);
752 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
753 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
754 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
755 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
758 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
759 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
760 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
763 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
764 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
765 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
766 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
767 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
768 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
769 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
770 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
771 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
772 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
773 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
777 ReSizeGLScene(90, .01);
789 //Set up distant light
790 light.color[0] = .95;
791 light.color[1] = .95;
793 light.ambient[0] = .2;
794 light.ambient[1] = .2;
795 light.ambient[2] = .24;
796 light.location.x = 1;
797 light.location.y = 1;
798 light.location.z = -.2;
799 Normalise(&light.location);
809 texscale = .2 / megascale / viewdistdetail;
810 terrain.scale = 3 * megascale * viewdistdetail;
812 viewer.x = terrain.size / 2 * terrain.scale;
813 viewer.z = terrain.size / 2 * terrain.scale;
815 hawk.load((char *)":Data:Models:hawk.solid", 1);
816 hawk.Scale(.03, .03, .03);
817 hawk.Rotate(90, 1, 1);
818 hawk.CalculateNormals(0);
819 hawk.ScaleNormals(-1, -1, -1);
820 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
821 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
822 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
824 eye.load((char *)":Data:Models:eye.solid", 1);
825 eye.Scale(.03, .03, .03);
826 eye.CalculateNormals(0);
828 cornea.load((char *)":Data:Models:cornea.solid", 1);
829 cornea.Scale(.03, .03, .03);
830 cornea.CalculateNormals(0);
832 iris.load((char *)":Data:Models:iris.solid", 1);
833 iris.Scale(.03, .03, .03);
834 iris.CalculateNormals(0);
836 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
837 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
847 //Fix knife stab, too lazy to do it manually
851 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
852 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
853 animation[knifesneakattackanim].position[i][j] += moveamount;
859 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
860 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
861 animation[knifesneakattackedanim].position[i][j] += moveamount;
867 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
868 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
869 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
870 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
871 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
873 animation[dead1anim].speed[0] = 0.001;
874 animation[dead2anim].speed[0] = 0.001;
875 animation[dead3anim].speed[0] = 0.001;
876 animation[dead4anim].speed[0] = 0.001;
878 animation[dead1anim].speed[1] = 0.001;
879 animation[dead2anim].speed[1] = 0.001;
880 animation[dead3anim].speed[1] = 0.001;
881 animation[dead4anim].speed[1] = 0.001;
883 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
884 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
885 animation[swordsneakattackanim].position[i][j] += moveamount;
889 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
890 animation[swordsneakattackanim].weapontarget[j] += moveamount;
895 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
896 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
897 animation[swordsneakattackedanim].position[i][j] += moveamount;
902 temptexdetail = texdetail;
904 texdetail = temptexdetail;
908 if (!screentexture) {
912 if (targetlevel != 7) {
913 emit_sound_at(fireendsound);