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 tintr, tintg, tintb;
65 extern float slomospeed;
66 extern bool gamestarted;
68 extern int numdialogues;
69 extern int numdialogueboxes[20];
70 extern int dialoguetype[20];
71 extern int dialogueboxlocation[20][20];
72 extern float dialogueboxcolor[20][20][3];
73 extern int dialogueboxsound[20][20];
74 extern char dialoguetext[20][20][128];
75 extern char dialoguename[20][20][64];
76 extern XYZ dialoguecamera[20][20];
77 extern float dialoguecamerayaw[20][20];
78 extern float dialoguecamerapitch[20][20];
79 extern int indialogue;
80 extern int whichdialogue;
81 extern float dialoguetime;
83 extern float accountcampaignhighscore[10];
84 extern float accountcampaignfasttime[10];
85 extern float accountcampaignscore[10];
86 extern float accountcampaigntime[10];
88 extern int accountcampaignchoicesmade[10];
89 extern int accountcampaignchoices[10][5000];
91 void LOG(const std::string &fmt, ...)
93 // !!! FIXME: write me.
100 if (Game::endgame == 2) {
101 Game::accountactive->endGame();
105 Account::saveFile(":Data:Users", Game::accountactive);
109 LOG("Shutting down sound system...");
111 OPENAL_StopSound(OPENAL_ALL);
113 // this is causing problems on Linux, but we'll force an _exit() a little
114 // later in the shutdown process. --ryan.
117 for (int i = 0; i < sounds_count; ++i) {
118 OPENAL_Sample_Free(samp[i]);
128 skybox = new SkyBox();
131 void Game::deleteGame()
137 terraintexture.destroy();
138 terraintexture2.destroy();
139 cursortexture.destroy();
140 Maparrowtexture.destroy();
141 Mapboxtexture.destroy();
142 Mapcircletexture.destroy();
143 hawktexture.destroy();
144 loadscreentexture.destroy();
146 for (int i = 0; i < 10; i++)
147 Mainmenuitems[i].destroy();
149 glDeleteTextures(1, &screentexture);
150 glDeleteTextures(1, &screentexture2);
157 void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize)
161 LOG(std::string("Loading (S)...") + fileName);
164 float temptexdetail = texdetail;
169 load_image(ConvertFileName(fileName), texture);
170 texdetail = temptexdetail;
172 int bytesPerPixel = texture.bpp / 8;
175 for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
176 if ((i + 1) % 4 || bytesPerPixel == 3) {
177 array[tempnum] = texture.data[i];
185 //***************> ResizeGLScene() <******/
186 GLvoid Game::ReSizeGLScene(float fov, float pnear)
188 if (screenheight == 0) {
192 glViewport(0, 0, screenwidth, screenheight);
194 glMatrixMode(GL_PROJECTION);
197 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
199 glMatrixMode(GL_MODELVIEW);
203 void Game::LoadingScreen()
205 static float loadprogress;
206 static AbsoluteTime frametime = {0, 0};
207 AbsoluteTime currTime = UpTime ();
208 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
210 if (0 > deltaTime) // if negative microseconds
211 deltaTime /= -1000000.0;
212 else // else milliseconds
215 multiplier = deltaTime;
216 if (multiplier < .001)
220 if (multiplier > .05) {
221 frametime = currTime; // reset for next time interval
225 glClearColor(0, 0, 0, 1);
226 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
229 loadtime += multiplier * 4;
231 loadprogress = loadtime;
232 if (loadprogress > 100)
237 glEnable(GL_TEXTURE_2D);
238 loadscreentexture.bind();
239 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
240 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
241 glDisable(GL_DEPTH_TEST);
242 glDisable(GL_CULL_FACE);
243 glDisable(GL_LIGHTING);
245 glMatrixMode(GL_PROJECTION);
248 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
249 glMatrixMode(GL_MODELVIEW);
252 glTranslatef(screenwidth / 2, screenheight / 2, 0);
253 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
254 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
256 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
259 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
260 glVertex3f(-1, -1, 0.0f);
261 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
262 glVertex3f(1, -1, 0.0f);
263 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
264 glVertex3f(1, 1, 0.0f);
265 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
266 glVertex3f(-1, 1, 0.0f);
272 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
273 glVertex3f(-1, -1, 0.0f);
274 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
275 glVertex3f(1, -1, 0.0f);
276 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
277 glVertex3f(1, 1, 0.0f);
278 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
279 glVertex3f(-1, 1, 0.0f);
282 glDisable(GL_TEXTURE_2D);
283 glMatrixMode(GL_PROJECTION);
285 glMatrixMode(GL_MODELVIEW);
290 glEnable(GL_TEXTURE_2D);
291 loadscreentexture.bind();
292 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
293 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
294 glDisable(GL_DEPTH_TEST);
295 glDisable(GL_CULL_FACE);
296 glDisable(GL_LIGHTING);
298 glMatrixMode(GL_PROJECTION);
301 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
302 glMatrixMode(GL_MODELVIEW);
305 glTranslatef(screenwidth / 2, screenheight / 2, 0);
306 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
307 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
309 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
312 glTexCoord2f(0 + .5, 0 + .5);
313 glVertex3f(-1, -1, 0.0f);
314 glTexCoord2f(1 + .5, 0 + .5);
315 glVertex3f(1, -1, 0.0f);
316 glTexCoord2f(1 + .5, 1 + .5);
317 glVertex3f(1, 1, 0.0f);
318 glTexCoord2f(0 + .5, 1 + .5);
319 glVertex3f(-1, 1, 0.0f);
322 glDisable(GL_TEXTURE_2D);
323 glMatrixMode(GL_PROJECTION);
325 glMatrixMode(GL_MODELVIEW);
330 glEnable(GL_TEXTURE_2D);
331 loadscreentexture.bind();
332 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
333 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
334 glDisable(GL_DEPTH_TEST);
335 glDisable(GL_CULL_FACE);
336 glDisable(GL_LIGHTING);
338 glMatrixMode(GL_PROJECTION);
341 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
342 glMatrixMode(GL_MODELVIEW);
345 glTranslatef(screenwidth / 2, screenheight / 2, 0);
346 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
347 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
349 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
352 glTexCoord2f(0 + .2, 0 + .8);
353 glVertex3f(-1, -1, 0.0f);
354 glTexCoord2f(1 + .2, 0 + .8);
355 glVertex3f(1, -1, 0.0f);
356 glTexCoord2f(1 + .2, 1 + .8);
357 glVertex3f(1, 1, 0.0f);
358 glTexCoord2f(0 + .2, 1 + .8);
359 glVertex3f(-1, 1, 0.0f);
362 glDisable(GL_TEXTURE_2D);
363 glMatrixMode(GL_PROJECTION);
365 glMatrixMode(GL_MODELVIEW);
372 if (flashamount > 0) {
376 flashamount -= multiplier;
380 glDisable(GL_DEPTH_TEST);
381 glDisable(GL_CULL_FACE);
382 glDisable(GL_LIGHTING);
383 glDisable(GL_TEXTURE_2D);
385 glMatrixMode(GL_PROJECTION);
388 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
389 glMatrixMode(GL_MODELVIEW);
392 glScalef(screenwidth, screenheight, 1);
393 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
395 glColor4f(flashr, flashg, flashb, flashamount);
397 glVertex3f(0, 0, 0.0f);
398 glVertex3f(256, 0, 0.0f);
399 glVertex3f(256, 256, 0.0f);
400 glVertex3f(0, 256, 0.0f);
402 glMatrixMode(GL_PROJECTION);
404 glMatrixMode(GL_MODELVIEW);
406 glEnable(GL_DEPTH_TEST);
407 glEnable(GL_CULL_FACE);
416 void FadeLoadingScreen(float howmuch)
418 static float loadprogress;
422 glClearColor(0, 0, 0, 1);
423 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
425 loadprogress = howmuch;
429 glDisable(GL_TEXTURE_2D);
430 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
431 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
432 glDisable(GL_DEPTH_TEST);
433 glDisable(GL_CULL_FACE);
434 glDisable(GL_LIGHTING);
436 glMatrixMode(GL_PROJECTION);
439 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
440 glMatrixMode(GL_MODELVIEW);
443 glTranslatef(screenwidth / 2, screenheight / 2, 0);
444 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
445 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
447 glColor4f(loadprogress / 100, 0, 0, 1);
451 glVertex3f(-1, -1, 0.0f);
453 glVertex3f(1, -1, 0.0f);
455 glVertex3f(1, 1, 0.0f);
457 glVertex3f(-1, 1, 0.0f);
460 glDisable(GL_TEXTURE_2D);
461 glMatrixMode(GL_PROJECTION);
463 glMatrixMode(GL_MODELVIEW);
472 extern bool cmdline(const char *cmd);
474 void Game::InitGame()
478 numchallengelevels = 14;
480 accountactive = Account::loadFile(":Data:Users");
486 whichjointstartarray[0] = righthip;
487 whichjointendarray[0] = rightfoot;
489 whichjointstartarray[1] = righthip;
490 whichjointendarray[1] = rightankle;
492 whichjointstartarray[2] = righthip;
493 whichjointendarray[2] = rightknee;
495 whichjointstartarray[3] = rightknee;
496 whichjointendarray[3] = rightankle;
498 whichjointstartarray[4] = rightankle;
499 whichjointendarray[4] = rightfoot;
501 whichjointstartarray[5] = lefthip;
502 whichjointendarray[5] = leftfoot;
504 whichjointstartarray[6] = lefthip;
505 whichjointendarray[6] = leftankle;
507 whichjointstartarray[7] = lefthip;
508 whichjointendarray[7] = leftknee;
510 whichjointstartarray[8] = leftknee;
511 whichjointendarray[8] = leftankle;
513 whichjointstartarray[9] = leftankle;
514 whichjointendarray[9] = leftfoot;
516 whichjointstartarray[10] = abdomen;
517 whichjointendarray[10] = rightshoulder;
519 whichjointstartarray[11] = abdomen;
520 whichjointendarray[11] = rightelbow;
522 whichjointstartarray[12] = abdomen;
523 whichjointendarray[12] = rightwrist;
525 whichjointstartarray[13] = abdomen;
526 whichjointendarray[13] = righthand;
528 whichjointstartarray[14] = rightshoulder;
529 whichjointendarray[14] = rightelbow;
531 whichjointstartarray[15] = rightelbow;
532 whichjointendarray[15] = rightwrist;
534 whichjointstartarray[16] = rightwrist;
535 whichjointendarray[16] = righthand;
537 whichjointstartarray[17] = abdomen;
538 whichjointendarray[17] = leftshoulder;
540 whichjointstartarray[18] = abdomen;
541 whichjointendarray[18] = leftelbow;
543 whichjointstartarray[19] = abdomen;
544 whichjointendarray[19] = leftwrist;
546 whichjointstartarray[20] = abdomen;
547 whichjointendarray[20] = lefthand;
549 whichjointstartarray[21] = leftshoulder;
550 whichjointendarray[21] = leftelbow;
552 whichjointstartarray[22] = leftelbow;
553 whichjointendarray[22] = leftwrist;
555 whichjointstartarray[23] = leftwrist;
556 whichjointendarray[23] = lefthand;
558 whichjointstartarray[24] = abdomen;
559 whichjointendarray[24] = neck;
561 whichjointstartarray[25] = neck;
562 whichjointendarray[25] = head;
564 FadeLoadingScreen(0);
568 int temptexdetail = texdetail;
570 text->LoadFontTexture(":Data:Textures:Font.png");
572 texdetail = temptexdetail;
574 FadeLoadingScreen(10);
586 LOG("Initializing sound system...");
589 unsigned char rc = 0;
590 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
591 if (cmdline("forceoss")) // ...but let user override that.
592 output = OPENAL_OUTPUT_OSS;
593 else if (cmdline("nosound"))
594 output = OPENAL_OUTPUT_NOSOUND;
596 OPENAL_SetOutput(output);
597 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
598 // if we tried ALSA and failed, fall back to OSS.
599 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
601 output = OPENAL_OUTPUT_OSS;
602 OPENAL_SetOutput(output);
603 rc = OPENAL_Init(44100, 32, 0);
609 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
610 OPENAL_SetOutput(output);
611 rc = OPENAL_Init(44100, 32, 0);
614 OPENAL_Init(44100, 32, 0);
617 OPENAL_SetSFXMasterVolume((int)(volume * 255));
621 emit_stream_np(stream_menutheme);
623 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
625 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
626 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
627 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
629 temptexdetail = texdetail;
632 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
633 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
634 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
635 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
636 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
637 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
638 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
640 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
641 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
642 texdetail = temptexdetail;
644 FadeLoadingScreen(95);
654 newscreenwidth = screenwidth;
655 newscreenheight = screenheight;
661 void Game::LoadScreenTexture()
663 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
665 if (!Game::screentexture)
666 glGenTextures( 1, &Game::screentexture );
667 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
670 glEnable(GL_TEXTURE_2D);
671 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
672 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
673 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
675 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
678 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
679 void Game::LoadStuff()
681 static float temptexdetail;
682 static float viewdistdetail;
692 for (auto p:Person::players) {
693 p->skeleton.drawmodel.textureptr.destroy();
696 i = abs(Random() % 4);
697 visibleloading = 0; //don't use loadscreentexture yet
698 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
701 temptexdetail = texdetail;
703 text->LoadFontTexture(":Data:Textures:Font.png");
705 texdetail = temptexdetail;
710 viewdistance = 50 * megascale * viewdistdetail;
722 realtexdetail = texdetail;
724 LOG("Loading weapon data...");
726 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
727 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
728 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
729 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
730 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
731 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
732 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
734 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
735 Weapon::throwingknifemodel.Scale(.001, .001, .001);
736 Weapon::throwingknifemodel.Rotate(90, 0, 0);
737 Weapon::throwingknifemodel.Rotate(0, 90, 0);
738 Weapon::throwingknifemodel.flat = 0;
739 Weapon::throwingknifemodel.CalculateNormals(1);
741 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
742 Weapon::swordmodel.Scale(.001, .001, .001);
743 Weapon::swordmodel.Rotate(90, 0, 0);
744 Weapon::swordmodel.Rotate(0, 90, 0);
745 Weapon::swordmodel.Rotate(0, 0, 90);
746 Weapon::swordmodel.flat = 1;
747 Weapon::swordmodel.CalculateNormals(1);
749 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
750 Weapon::staffmodel.Scale(.005, .005, .005);
751 Weapon::staffmodel.Rotate(90, 0, 0);
752 Weapon::staffmodel.Rotate(0, 90, 0);
753 Weapon::staffmodel.Rotate(0, 0, 90);
754 Weapon::staffmodel.flat = 1;
755 Weapon::staffmodel.CalculateNormals(1);
757 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
758 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
759 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
760 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
763 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
764 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
765 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
768 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
769 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
770 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
771 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
772 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
773 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
774 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
775 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
776 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
777 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
778 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
782 ReSizeGLScene(90, .01);
794 //Set up distant light
795 light.color[0] = .95;
796 light.color[1] = .95;
798 light.ambient[0] = .2;
799 light.ambient[1] = .2;
800 light.ambient[2] = .24;
801 light.location.x = 1;
802 light.location.y = 1;
803 light.location.z = -.2;
804 Normalise(&light.location);
814 texscale = .2 / megascale / viewdistdetail;
815 terrain.scale = 3 * megascale * viewdistdetail;
817 viewer.x = terrain.size / 2 * terrain.scale;
818 viewer.z = terrain.size / 2 * terrain.scale;
820 hawk.load((char *)":Data:Models:hawk.solid", 1);
821 hawk.Scale(.03, .03, .03);
822 hawk.Rotate(90, 1, 1);
823 hawk.CalculateNormals(0);
824 hawk.ScaleNormals(-1, -1, -1);
825 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
826 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
827 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
829 eye.load((char *)":Data:Models:eye.solid", 1);
830 eye.Scale(.03, .03, .03);
831 eye.CalculateNormals(0);
833 cornea.load((char *)":Data:Models:cornea.solid", 1);
834 cornea.Scale(.03, .03, .03);
835 cornea.CalculateNormals(0);
837 iris.load((char *)":Data:Models:iris.solid", 1);
838 iris.Scale(.03, .03, .03);
839 iris.CalculateNormals(0);
841 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
842 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
852 //Fix knife stab, too lazy to do it manually
856 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
857 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
858 animation[knifesneakattackanim].position[i][j] += moveamount;
864 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
865 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
866 animation[knifesneakattackedanim].position[i][j] += moveamount;
872 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
873 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
874 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
875 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
876 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
878 animation[dead1anim].speed[0] = 0.001;
879 animation[dead2anim].speed[0] = 0.001;
880 animation[dead3anim].speed[0] = 0.001;
881 animation[dead4anim].speed[0] = 0.001;
883 animation[dead1anim].speed[1] = 0.001;
884 animation[dead2anim].speed[1] = 0.001;
885 animation[dead3anim].speed[1] = 0.001;
886 animation[dead4anim].speed[1] = 0.001;
888 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
889 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
890 animation[swordsneakattackanim].position[i][j] += moveamount;
894 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
895 animation[swordsneakattackanim].weapontarget[j] += moveamount;
900 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
901 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
902 animation[swordsneakattackedanim].position[i][j] += moveamount;
907 temptexdetail = texdetail;
909 texdetail = temptexdetail;
913 if (!screentexture) {
917 if (targetlevel != 7) {
918 emit_sound_at(fireendsound);