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);
470 void Game::InitGame()
474 numchallengelevels = 14;
476 accountactive = Account::loadFile(":Data:Users");
478 whichjointstartarray[0] = righthip;
479 whichjointendarray[0] = rightfoot;
481 whichjointstartarray[1] = righthip;
482 whichjointendarray[1] = rightankle;
484 whichjointstartarray[2] = righthip;
485 whichjointendarray[2] = rightknee;
487 whichjointstartarray[3] = rightknee;
488 whichjointendarray[3] = rightankle;
490 whichjointstartarray[4] = rightankle;
491 whichjointendarray[4] = rightfoot;
493 whichjointstartarray[5] = lefthip;
494 whichjointendarray[5] = leftfoot;
496 whichjointstartarray[6] = lefthip;
497 whichjointendarray[6] = leftankle;
499 whichjointstartarray[7] = lefthip;
500 whichjointendarray[7] = leftknee;
502 whichjointstartarray[8] = leftknee;
503 whichjointendarray[8] = leftankle;
505 whichjointstartarray[9] = leftankle;
506 whichjointendarray[9] = leftfoot;
508 whichjointstartarray[10] = abdomen;
509 whichjointendarray[10] = rightshoulder;
511 whichjointstartarray[11] = abdomen;
512 whichjointendarray[11] = rightelbow;
514 whichjointstartarray[12] = abdomen;
515 whichjointendarray[12] = rightwrist;
517 whichjointstartarray[13] = abdomen;
518 whichjointendarray[13] = righthand;
520 whichjointstartarray[14] = rightshoulder;
521 whichjointendarray[14] = rightelbow;
523 whichjointstartarray[15] = rightelbow;
524 whichjointendarray[15] = rightwrist;
526 whichjointstartarray[16] = rightwrist;
527 whichjointendarray[16] = righthand;
529 whichjointstartarray[17] = abdomen;
530 whichjointendarray[17] = leftshoulder;
532 whichjointstartarray[18] = abdomen;
533 whichjointendarray[18] = leftelbow;
535 whichjointstartarray[19] = abdomen;
536 whichjointendarray[19] = leftwrist;
538 whichjointstartarray[20] = abdomen;
539 whichjointendarray[20] = lefthand;
541 whichjointstartarray[21] = leftshoulder;
542 whichjointendarray[21] = leftelbow;
544 whichjointstartarray[22] = leftelbow;
545 whichjointendarray[22] = leftwrist;
547 whichjointstartarray[23] = leftwrist;
548 whichjointendarray[23] = lefthand;
550 whichjointstartarray[24] = abdomen;
551 whichjointendarray[24] = neck;
553 whichjointstartarray[25] = neck;
554 whichjointendarray[25] = head;
556 FadeLoadingScreen(0);
560 int temptexdetail = texdetail;
562 text->LoadFontTexture(":Data:Textures:Font.png");
564 texdetail = temptexdetail;
566 FadeLoadingScreen(10);
578 LOG("Initializing sound system...");
581 unsigned char rc = 0;
582 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
583 if (commandLineOptions[SOUND]) {
584 output = commandLineOptions[SOUND].last()->type(); // ...but let user override that.
587 OPENAL_SetOutput(output);
588 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
589 // if we tried ALSA and failed, fall back to OSS.
590 if ( (output == OPENAL_OUTPUT_ALSA) && (commandLineOptions[SOUND].last()->type() != OPENAL_OUTPUT_ALSA) ) {
592 output = OPENAL_OUTPUT_OSS;
593 OPENAL_SetOutput(output);
594 rc = OPENAL_Init(44100, 32, 0);
600 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
601 OPENAL_SetOutput(output);
602 rc = OPENAL_Init(44100, 32, 0);
605 OPENAL_Init(44100, 32, 0);
608 OPENAL_SetSFXMasterVolume((int)(volume * 255));
612 emit_stream_np(stream_menutheme);
614 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
616 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
617 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
618 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
620 temptexdetail = texdetail;
623 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
624 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
625 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
626 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
627 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
628 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
629 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
631 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
632 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
633 texdetail = temptexdetail;
635 FadeLoadingScreen(95);
645 newscreenwidth = screenwidth;
646 newscreenheight = screenheight;
652 void Game::LoadScreenTexture()
654 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
656 if (!Game::screentexture)
657 glGenTextures( 1, &Game::screentexture );
658 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
661 glEnable(GL_TEXTURE_2D);
662 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
663 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
664 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
666 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
669 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
670 void Game::LoadStuff()
672 static float temptexdetail;
673 static float viewdistdetail;
683 for (auto p:Person::players) {
684 p->skeleton.drawmodel.textureptr.destroy();
687 i = abs(Random() % 4);
688 visibleloading = 0; //don't use loadscreentexture yet
689 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
692 temptexdetail = texdetail;
694 text->LoadFontTexture(":Data:Textures:Font.png");
696 texdetail = temptexdetail;
701 viewdistance = 50 * megascale * viewdistdetail;
713 realtexdetail = texdetail;
715 LOG("Loading weapon data...");
717 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
718 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
719 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
720 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
721 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
722 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
723 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
725 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
726 Weapon::throwingknifemodel.Scale(.001, .001, .001);
727 Weapon::throwingknifemodel.Rotate(90, 0, 0);
728 Weapon::throwingknifemodel.Rotate(0, 90, 0);
729 Weapon::throwingknifemodel.flat = 0;
730 Weapon::throwingknifemodel.CalculateNormals(1);
732 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
733 Weapon::swordmodel.Scale(.001, .001, .001);
734 Weapon::swordmodel.Rotate(90, 0, 0);
735 Weapon::swordmodel.Rotate(0, 90, 0);
736 Weapon::swordmodel.Rotate(0, 0, 90);
737 Weapon::swordmodel.flat = 1;
738 Weapon::swordmodel.CalculateNormals(1);
740 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
741 Weapon::staffmodel.Scale(.005, .005, .005);
742 Weapon::staffmodel.Rotate(90, 0, 0);
743 Weapon::staffmodel.Rotate(0, 90, 0);
744 Weapon::staffmodel.Rotate(0, 0, 90);
745 Weapon::staffmodel.flat = 1;
746 Weapon::staffmodel.CalculateNormals(1);
748 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
749 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
750 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
751 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
754 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
755 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
756 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
759 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
760 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
761 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
762 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
763 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
764 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
765 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
766 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
767 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
768 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
769 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
773 ReSizeGLScene(90, .01);
785 //Set up distant light
786 light.color[0] = .95;
787 light.color[1] = .95;
789 light.ambient[0] = .2;
790 light.ambient[1] = .2;
791 light.ambient[2] = .24;
792 light.location.x = 1;
793 light.location.y = 1;
794 light.location.z = -.2;
795 Normalise(&light.location);
805 texscale = .2 / megascale / viewdistdetail;
806 terrain.scale = 3 * megascale * viewdistdetail;
808 viewer.x = terrain.size / 2 * terrain.scale;
809 viewer.z = terrain.size / 2 * terrain.scale;
811 hawk.load((char *)":Data:Models:hawk.solid", 1);
812 hawk.Scale(.03, .03, .03);
813 hawk.Rotate(90, 1, 1);
814 hawk.CalculateNormals(0);
815 hawk.ScaleNormals(-1, -1, -1);
816 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
817 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
818 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
820 eye.load((char *)":Data:Models:eye.solid", 1);
821 eye.Scale(.03, .03, .03);
822 eye.CalculateNormals(0);
824 cornea.load((char *)":Data:Models:cornea.solid", 1);
825 cornea.Scale(.03, .03, .03);
826 cornea.CalculateNormals(0);
828 iris.load((char *)":Data:Models:iris.solid", 1);
829 iris.Scale(.03, .03, .03);
830 iris.CalculateNormals(0);
832 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
833 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
843 //Fix knife stab, too lazy to do it manually
847 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
848 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
849 animation[knifesneakattackanim].position[i][j] += moveamount;
855 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
856 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
857 animation[knifesneakattackedanim].position[i][j] += moveamount;
863 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
864 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
865 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
866 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
867 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
869 animation[dead1anim].speed[0] = 0.001;
870 animation[dead2anim].speed[0] = 0.001;
871 animation[dead3anim].speed[0] = 0.001;
872 animation[dead4anim].speed[0] = 0.001;
874 animation[dead1anim].speed[1] = 0.001;
875 animation[dead2anim].speed[1] = 0.001;
876 animation[dead3anim].speed[1] = 0.001;
877 animation[dead4anim].speed[1] = 0.001;
879 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
880 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
881 animation[swordsneakattackanim].position[i][j] += moveamount;
885 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
886 animation[swordsneakattackanim].weapontarget[j] += moveamount;
891 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
892 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
893 animation[swordsneakattackedanim].position[i][j] += moveamount;
898 temptexdetail = texdetail;
900 texdetail = temptexdetail;
904 if (!screentexture) {
908 if (targetlevel != 7) {
909 emit_sound_at(fireendsound);