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 ImageRec 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;
174 upload_image(ConvertFileName(fileName));
175 texdetail = temptexdetail;
177 int bytesPerPixel = texture.bpp / 8;
180 for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
181 if ((i + 1) % 4 || bytesPerPixel == 3) {
182 array[tempnum] = texture.data[i];
190 //***************> ResizeGLScene() <******/
191 GLvoid Game::ReSizeGLScene(float fov, float pnear)
193 if (screenheight == 0) {
197 glViewport(0, 0, screenwidth, screenheight);
199 glMatrixMode(GL_PROJECTION);
202 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
204 glMatrixMode(GL_MODELVIEW);
208 void Game::LoadingScreen()
210 static float loadprogress;
211 static AbsoluteTime frametime = {0, 0};
212 AbsoluteTime currTime = UpTime ();
213 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
215 if (0 > deltaTime) // if negative microseconds
216 deltaTime /= -1000000.0;
217 else // else milliseconds
220 multiplier = deltaTime;
221 if (multiplier < .001)
225 if (multiplier > .05) {
226 frametime = currTime; // reset for next time interval
230 glClearColor(0, 0, 0, 1);
231 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
234 loadtime += multiplier * 4;
236 loadprogress = loadtime;
237 if (loadprogress > 100)
242 glEnable(GL_TEXTURE_2D);
243 loadscreentexture.bind();
244 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
245 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
246 glDisable(GL_DEPTH_TEST);
247 glDisable(GL_CULL_FACE);
248 glDisable(GL_LIGHTING);
250 glMatrixMode(GL_PROJECTION);
253 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
254 glMatrixMode(GL_MODELVIEW);
257 glTranslatef(screenwidth / 2, screenheight / 2, 0);
258 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
259 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
261 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
264 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
265 glVertex3f(-1, -1, 0.0f);
266 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
267 glVertex3f(1, -1, 0.0f);
268 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
269 glVertex3f(1, 1, 0.0f);
270 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
271 glVertex3f(-1, 1, 0.0f);
277 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
278 glVertex3f(-1, -1, 0.0f);
279 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
280 glVertex3f(1, -1, 0.0f);
281 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
282 glVertex3f(1, 1, 0.0f);
283 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
284 glVertex3f(-1, 1, 0.0f);
287 glDisable(GL_TEXTURE_2D);
288 glMatrixMode(GL_PROJECTION);
290 glMatrixMode(GL_MODELVIEW);
295 glEnable(GL_TEXTURE_2D);
296 loadscreentexture.bind();
297 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
298 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
299 glDisable(GL_DEPTH_TEST);
300 glDisable(GL_CULL_FACE);
301 glDisable(GL_LIGHTING);
303 glMatrixMode(GL_PROJECTION);
306 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
307 glMatrixMode(GL_MODELVIEW);
310 glTranslatef(screenwidth / 2, screenheight / 2, 0);
311 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
312 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
314 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
317 glTexCoord2f(0 + .5, 0 + .5);
318 glVertex3f(-1, -1, 0.0f);
319 glTexCoord2f(1 + .5, 0 + .5);
320 glVertex3f(1, -1, 0.0f);
321 glTexCoord2f(1 + .5, 1 + .5);
322 glVertex3f(1, 1, 0.0f);
323 glTexCoord2f(0 + .5, 1 + .5);
324 glVertex3f(-1, 1, 0.0f);
327 glDisable(GL_TEXTURE_2D);
328 glMatrixMode(GL_PROJECTION);
330 glMatrixMode(GL_MODELVIEW);
335 glEnable(GL_TEXTURE_2D);
336 loadscreentexture.bind();
337 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
338 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
339 glDisable(GL_DEPTH_TEST);
340 glDisable(GL_CULL_FACE);
341 glDisable(GL_LIGHTING);
343 glMatrixMode(GL_PROJECTION);
346 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
347 glMatrixMode(GL_MODELVIEW);
350 glTranslatef(screenwidth / 2, screenheight / 2, 0);
351 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
352 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
354 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
357 glTexCoord2f(0 + .2, 0 + .8);
358 glVertex3f(-1, -1, 0.0f);
359 glTexCoord2f(1 + .2, 0 + .8);
360 glVertex3f(1, -1, 0.0f);
361 glTexCoord2f(1 + .2, 1 + .8);
362 glVertex3f(1, 1, 0.0f);
363 glTexCoord2f(0 + .2, 1 + .8);
364 glVertex3f(-1, 1, 0.0f);
367 glDisable(GL_TEXTURE_2D);
368 glMatrixMode(GL_PROJECTION);
370 glMatrixMode(GL_MODELVIEW);
377 if (flashamount > 0) {
381 flashamount -= multiplier;
385 glDisable(GL_DEPTH_TEST);
386 glDisable(GL_CULL_FACE);
387 glDisable(GL_LIGHTING);
388 glDisable(GL_TEXTURE_2D);
390 glMatrixMode(GL_PROJECTION);
393 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
394 glMatrixMode(GL_MODELVIEW);
397 glScalef(screenwidth, screenheight, 1);
398 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
400 glColor4f(flashr, flashg, flashb, flashamount);
402 glVertex3f(0, 0, 0.0f);
403 glVertex3f(256, 0, 0.0f);
404 glVertex3f(256, 256, 0.0f);
405 glVertex3f(0, 256, 0.0f);
407 glMatrixMode(GL_PROJECTION);
409 glMatrixMode(GL_MODELVIEW);
411 glEnable(GL_DEPTH_TEST);
412 glEnable(GL_CULL_FACE);
421 void FadeLoadingScreen(float howmuch)
423 static float loadprogress;
427 glClearColor(0, 0, 0, 1);
428 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
430 loadprogress = howmuch;
434 glDisable(GL_TEXTURE_2D);
435 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
436 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
437 glDisable(GL_DEPTH_TEST);
438 glDisable(GL_CULL_FACE);
439 glDisable(GL_LIGHTING);
441 glMatrixMode(GL_PROJECTION);
444 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
445 glMatrixMode(GL_MODELVIEW);
448 glTranslatef(screenwidth / 2, screenheight / 2, 0);
449 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
450 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
452 glColor4f(loadprogress / 100, 0, 0, 1);
456 glVertex3f(-1, -1, 0.0f);
458 glVertex3f(1, -1, 0.0f);
460 glVertex3f(1, 1, 0.0f);
462 glVertex3f(-1, 1, 0.0f);
465 glDisable(GL_TEXTURE_2D);
466 glMatrixMode(GL_PROJECTION);
468 glMatrixMode(GL_MODELVIEW);
477 extern bool cmdline(const char *cmd);
479 void Game::InitGame()
483 numchallengelevels = 14;
485 accountactive = Account::loadFile(":Data:Users");
491 whichjointstartarray[0] = righthip;
492 whichjointendarray[0] = rightfoot;
494 whichjointstartarray[1] = righthip;
495 whichjointendarray[1] = rightankle;
497 whichjointstartarray[2] = righthip;
498 whichjointendarray[2] = rightknee;
500 whichjointstartarray[3] = rightknee;
501 whichjointendarray[3] = rightankle;
503 whichjointstartarray[4] = rightankle;
504 whichjointendarray[4] = rightfoot;
506 whichjointstartarray[5] = lefthip;
507 whichjointendarray[5] = leftfoot;
509 whichjointstartarray[6] = lefthip;
510 whichjointendarray[6] = leftankle;
512 whichjointstartarray[7] = lefthip;
513 whichjointendarray[7] = leftknee;
515 whichjointstartarray[8] = leftknee;
516 whichjointendarray[8] = leftankle;
518 whichjointstartarray[9] = leftankle;
519 whichjointendarray[9] = leftfoot;
521 whichjointstartarray[10] = abdomen;
522 whichjointendarray[10] = rightshoulder;
524 whichjointstartarray[11] = abdomen;
525 whichjointendarray[11] = rightelbow;
527 whichjointstartarray[12] = abdomen;
528 whichjointendarray[12] = rightwrist;
530 whichjointstartarray[13] = abdomen;
531 whichjointendarray[13] = righthand;
533 whichjointstartarray[14] = rightshoulder;
534 whichjointendarray[14] = rightelbow;
536 whichjointstartarray[15] = rightelbow;
537 whichjointendarray[15] = rightwrist;
539 whichjointstartarray[16] = rightwrist;
540 whichjointendarray[16] = righthand;
542 whichjointstartarray[17] = abdomen;
543 whichjointendarray[17] = leftshoulder;
545 whichjointstartarray[18] = abdomen;
546 whichjointendarray[18] = leftelbow;
548 whichjointstartarray[19] = abdomen;
549 whichjointendarray[19] = leftwrist;
551 whichjointstartarray[20] = abdomen;
552 whichjointendarray[20] = lefthand;
554 whichjointstartarray[21] = leftshoulder;
555 whichjointendarray[21] = leftelbow;
557 whichjointstartarray[22] = leftelbow;
558 whichjointendarray[22] = leftwrist;
560 whichjointstartarray[23] = leftwrist;
561 whichjointendarray[23] = lefthand;
563 whichjointstartarray[24] = abdomen;
564 whichjointendarray[24] = neck;
566 whichjointstartarray[25] = neck;
567 whichjointendarray[25] = head;
569 FadeLoadingScreen(0);
573 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
575 int temptexdetail = texdetail;
577 text->LoadFontTexture(":Data:Textures:Font.png");
579 texdetail = temptexdetail;
581 FadeLoadingScreen(10);
593 LOG("Initializing sound system...");
596 unsigned char rc = 0;
597 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
598 if (cmdline("forceoss")) // ...but let user override that.
599 output = OPENAL_OUTPUT_OSS;
600 else if (cmdline("nosound"))
601 output = OPENAL_OUTPUT_NOSOUND;
603 OPENAL_SetOutput(output);
604 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
605 // if we tried ALSA and failed, fall back to OSS.
606 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
608 output = OPENAL_OUTPUT_OSS;
609 OPENAL_SetOutput(output);
610 rc = OPENAL_Init(44100, 32, 0);
616 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
617 OPENAL_SetOutput(output);
618 rc = OPENAL_Init(44100, 32, 0);
621 OPENAL_Init(44100, 32, 0);
624 OPENAL_SetSFXMasterVolume((int)(volume * 255));
628 emit_stream_np(stream_menutheme);
630 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
632 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
633 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
634 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
636 temptexdetail = texdetail;
639 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
640 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
641 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
642 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
643 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
644 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
645 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
647 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
648 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
649 texdetail = temptexdetail;
651 FadeLoadingScreen(95);
661 newscreenwidth = screenwidth;
662 newscreenheight = screenheight;
668 void Game::LoadScreenTexture()
670 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
672 if (!Game::screentexture)
673 glGenTextures( 1, &Game::screentexture );
674 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
677 glEnable(GL_TEXTURE_2D);
678 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
679 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
680 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
682 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
685 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
686 void Game::LoadStuff()
688 static float temptexdetail;
689 static float viewdistdetail;
699 for (auto p:Person::players) {
700 p->skeleton.drawmodel.textureptr.destroy();
703 i = abs(Random() % 4);
704 visibleloading = 0; //don't use loadscreentexture yet
705 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
708 temptexdetail = texdetail;
710 text->LoadFontTexture(":Data:Textures:Font.png");
712 texdetail = temptexdetail;
717 viewdistance = 50 * megascale * viewdistdetail;
729 realtexdetail = texdetail;
731 LOG("Loading weapon data...");
733 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
734 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
735 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
736 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
737 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
738 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
739 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
741 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
742 Weapon::throwingknifemodel.Scale(.001, .001, .001);
743 //Weapon::throwingknifemodel.Rotate(0,0,-90);
744 Weapon::throwingknifemodel.Rotate(90, 0, 0);
745 Weapon::throwingknifemodel.Rotate(0, 90, 0);
746 Weapon::throwingknifemodel.flat = 0;
747 Weapon::throwingknifemodel.CalculateNormals(1);
748 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
750 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
751 Weapon::swordmodel.Scale(.001, .001, .001);
752 //Weapon::swordmodel.Rotate(0,0,-90);
753 Weapon::swordmodel.Rotate(90, 0, 0);
754 Weapon::swordmodel.Rotate(0, 90, 0);
755 Weapon::swordmodel.Rotate(0, 0, 90);
756 Weapon::swordmodel.flat = 1;
757 Weapon::swordmodel.CalculateNormals(1);
758 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
760 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
761 Weapon::staffmodel.Scale(.005, .005, .005);
762 //Weapon::staffmodel.Rotate(0,0,-90);
763 Weapon::staffmodel.Rotate(90, 0, 0);
764 Weapon::staffmodel.Rotate(0, 90, 0);
765 Weapon::staffmodel.Rotate(0, 0, 90);
766 Weapon::staffmodel.flat = 1;
767 Weapon::staffmodel.CalculateNormals(1);
768 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
770 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
771 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
772 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
773 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
776 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
777 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
778 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
781 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
782 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
783 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
784 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
785 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
786 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
787 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
788 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
789 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
790 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
791 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
795 ReSizeGLScene(90, .01);
807 //Set up distant light
808 light.color[0] = .95;
809 light.color[1] = .95;
811 light.ambient[0] = .2;
812 light.ambient[1] = .2;
813 light.ambient[2] = .24;
814 light.location.x = 1;
815 light.location.y = 1;
816 light.location.z = -.2;
817 Normalise(&light.location);
827 texscale = .2 / megascale / viewdistdetail;
828 terrain.scale = 3 * megascale * viewdistdetail;
830 viewer.x = terrain.size / 2 * terrain.scale;
831 viewer.z = terrain.size / 2 * terrain.scale;
833 hawk.load((char *)":Data:Models:hawk.solid", 1);
834 hawk.Scale(.03, .03, .03);
835 hawk.Rotate(90, 1, 1);
836 hawk.CalculateNormals(0);
837 hawk.ScaleNormals(-1, -1, -1);
838 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
839 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
840 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
842 eye.load((char *)":Data:Models:eye.solid", 1);
843 eye.Scale(.03, .03, .03);
844 eye.CalculateNormals(0);
846 cornea.load((char *)":Data:Models:cornea.solid", 1);
847 cornea.Scale(.03, .03, .03);
848 cornea.CalculateNormals(0);
850 iris.load((char *)":Data:Models:iris.solid", 1);
851 iris.Scale(.03, .03, .03);
852 iris.CalculateNormals(0);
854 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
855 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
865 //Fix knife stab, too lazy to do it manually
869 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
870 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
871 animation[knifesneakattackanim].position[i][j] += moveamount;
877 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
878 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
879 animation[knifesneakattackedanim].position[i][j] += moveamount;
885 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
886 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
887 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
888 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
889 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
891 animation[dead1anim].speed[0] = 0.001;
892 animation[dead2anim].speed[0] = 0.001;
893 animation[dead3anim].speed[0] = 0.001;
894 animation[dead4anim].speed[0] = 0.001;
896 animation[dead1anim].speed[1] = 0.001;
897 animation[dead2anim].speed[1] = 0.001;
898 animation[dead3anim].speed[1] = 0.001;
899 animation[dead4anim].speed[1] = 0.001;
901 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
902 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
903 animation[swordsneakattackanim].position[i][j] += moveamount;
907 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
908 animation[swordsneakattackanim].weapontarget[j] += moveamount;
913 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
914 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
915 animation[swordsneakattackedanim].position[i][j] += moveamount;
920 temptexdetail = texdetail;
922 texdetail = temptexdetail;
926 if (!screentexture) {
930 if (targetlevel != 7) {
931 emit_sound_at(fireendsound);