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
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program 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.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
25 extern float screenwidth,screenheight;
26 extern float viewdistance;
28 extern XYZ lightlocation;
29 extern float lightambient[3],lightbrightness[3];
30 extern float fadestart;
31 extern float texscale;
34 extern Animation animation[animation_count];
35 extern Skeleton testskeleton;
37 extern OPENAL_SAMPLE *samp[100];
38 extern int channels[100];
39 extern Terrain terrain;
40 extern Sprites sprites;
41 extern int kTextureSize;
42 extern float texdetail;
43 extern float realtexdetail;
44 extern float terraindetail;
46 extern Objects objects;
48 extern bool cellophane;
49 extern GLubyte bloodText[512*512*3];
50 extern GLubyte wolfbloodText[512*512*3];
51 extern bool ismotionblur;
52 extern bool trilinear;
54 extern bool musictoggle;
55 extern Weapons weapons;
56 extern Person player[maxplayers];
57 extern int numplayers;
58 extern int environment;
59 extern bool ambientsound;
60 extern float multiplier;
61 extern int netdatanew;
63 extern bool stillloading;
64 extern TGAImageRec texture;
68 extern int oldmainmenu;
69 extern bool visibleloading;
70 extern int loadscreencolor;
71 extern float flashamount,flashr,flashg,flashb;
72 extern int flashdelay;
73 extern int whichjointstartarray[26];
74 extern int whichjointendarray[26];
75 extern int difficulty;
76 extern float tintr,tintg,tintb;
77 extern float slomospeed;
78 extern char mapname[256];
79 extern bool gamestarted;
81 extern int numdialogues;
82 extern int numdialogueboxes[20];
83 extern int dialoguetype[20];
84 extern int dialogueboxlocation[20][20];
85 extern float dialogueboxcolor[20][20][3];
86 extern int dialogueboxsound[20][20];
87 extern char dialoguetext[20][20][128];
88 extern char dialoguename[20][20][64];
89 extern XYZ dialoguecamera[20][20];
90 extern float dialoguecamerarotation[20][20];
91 extern float dialoguecamerarotation2[20][20];
92 extern int indialogue;
93 extern int whichdialogue;
94 extern float dialoguetime;
96 extern float accountcampaignhighscore[10];
97 extern float accountcampaignfasttime[10];
98 extern float accountcampaignscore[10];
99 extern float accountcampaigntime[10];
101 extern int accountcampaignchoicesmade[10];
102 extern int accountcampaignchoices[10][5000];
104 extern OPENAL_STREAM * strm[20];
106 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
107 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
109 void LOG(const std::string &fmt, ...)
111 // !!! FIXME: write me.
115 Game::TextureList Game::textures;
124 accountactive->endGame();
128 Account::saveFile(":Data:Users", accountactive);
130 TexIter it = textures.begin();
131 for (; it != textures.end(); ++it)
133 if (glIsTexture(it->second))
134 glDeleteTextures(1, &it->second);
138 LOG("Shutting down sound system...");
140 OPENAL_StopSound(OPENAL_ALL);
142 // this is causing problems on Linux, but we'll force an _exit() a little
143 // later in the shutdown process. --ryan.
145 #define streamcount 20
146 #define samplecount 100
148 for (i=0; i < samplecount; ++i)
150 OPENAL_Sample_Free(samp[i]);
153 for (i=0; i < streamcount; ++i)
155 OPENAL_Stream_Close(strm[i]);
168 //void Game::LoadSounds();
169 void Game::LoadSounds()
173 LOG(std::string("Loading sounds..."));
175 OPENAL_3D_SetDopplerFactor(0);
177 OPENAL_SetSFXMasterVolume((int)(volume*255));
179 samp[footstepsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
180 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
182 samp[footstepsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
183 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
185 samp[footstepsound3] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
186 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
188 samp[footstepsound4] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
189 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
191 samp[landsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
192 OPENAL_Sample_SetMinMaxDistance(samp[landsound], 4.0f, 1000.0f);
194 samp[jumpsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:jump.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
195 OPENAL_Sample_SetMinMaxDistance(samp[jumpsound], 4.0f, 1000.0f);
197 samp[hawksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:hawk.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
198 OPENAL_Sample_SetMinMaxDistance(samp[hawksound], 40.0f, 10000.0f);
200 samp[whooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:whoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
201 OPENAL_Sample_SetMinMaxDistance(samp[whooshsound], 4.0f, 1000.0f);
202 OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL);
204 samp[landsound1] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
205 OPENAL_Sample_SetMinMaxDistance(samp[landsound1], 4.0f, 1000.0f);
209 samp[landsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
210 OPENAL_Sample_SetMinMaxDistance(samp[landsound2], 4.0f, 1000.0f);
212 samp[breaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:broken.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
213 OPENAL_Sample_SetMinMaxDistance(samp[breaksound], 8.0f, 2000.0f);
215 samp[lowwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Lowwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
216 OPENAL_Sample_SetMinMaxDistance(samp[lowwhooshsound], 8.0f, 2000.0f);
218 samp[midwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:midwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
219 OPENAL_Sample_SetMinMaxDistance(samp[midwhooshsound], 8.0f, 2000.0f);
221 samp[highwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:highwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
222 OPENAL_Sample_SetMinMaxDistance(samp[highwhooshsound], 8.0f, 2000.0f);
224 samp[movewhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:movewhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
225 OPENAL_Sample_SetMinMaxDistance(samp[movewhooshsound], 8.0f, 2000.0f);
227 samp[heavyimpactsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:heavyimpact.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
228 OPENAL_Sample_SetMinMaxDistance(samp[heavyimpactsound], 8.0f, 2000.0f);
230 samp[whooshhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Whooshhit.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
231 OPENAL_Sample_SetMinMaxDistance(samp[whooshhitsound], 8.0f, 2000.0f);
233 samp[thudsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:thud.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
234 OPENAL_Sample_SetMinMaxDistance(samp[thudsound], 8.0f, 2000.0f);
236 samp[alarmsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:alarm.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
237 OPENAL_Sample_SetMinMaxDistance(samp[alarmsound], 8.0f, 2000.0f);
239 samp[breaksound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:break.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
240 OPENAL_Sample_SetMinMaxDistance(samp[breaksound2], 8.0f, 2000.0f);
242 samp[knifedrawsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifedraw.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
243 OPENAL_Sample_SetMinMaxDistance(samp[knifedrawsound], 8.0f, 2000.0f);
245 samp[knifesheathesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifesheathe.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
246 OPENAL_Sample_SetMinMaxDistance(samp[knifesheathesound], 8.0f, 2000.0f);
248 samp[fleshstabsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Fleshstab.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
249 OPENAL_Sample_SetMinMaxDistance(samp[fleshstabsound], 8.0f, 2000.0f);
251 samp[fleshstabremovesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Fleshstabremove.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
252 OPENAL_Sample_SetMinMaxDistance(samp[fleshstabremovesound], 8.0f, 2000.0f);
254 samp[knifeswishsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifeswish.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
255 OPENAL_Sample_SetMinMaxDistance(samp[knifeswishsound], 8.0f, 2000.0f);
257 samp[knifeslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifeslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
258 OPENAL_Sample_SetMinMaxDistance(samp[knifeslicesound], 8.0f, 2000.0f);
260 samp[swordslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:swordslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
261 OPENAL_Sample_SetMinMaxDistance(samp[swordslicesound], 8.0f, 2000.0f);
263 samp[skidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:skid.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
264 OPENAL_Sample_SetMinMaxDistance(samp[skidsound], 8.0f, 2000.0f);
266 samp[snowskidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snowskid.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
267 OPENAL_Sample_SetMinMaxDistance(samp[snowskidsound], 8.0f, 2000.0f);
269 samp[bushrustle] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bushrustle.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
270 OPENAL_Sample_SetMinMaxDistance(samp[bushrustle], 4.0f, 1000.0f);
272 samp[clank1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
273 OPENAL_Sample_SetMinMaxDistance(samp[clank1sound], 8.0f, 2000.0f);
275 samp[clank2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
276 OPENAL_Sample_SetMinMaxDistance(samp[clank2sound], 8.0f, 2000.0f);
278 samp[clank3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
279 OPENAL_Sample_SetMinMaxDistance(samp[clank3sound], 8.0f, 2000.0f);
281 samp[clank4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank4.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
282 OPENAL_Sample_SetMinMaxDistance(samp[clank4sound], 8.0f, 2000.0f);
284 samp[consolesuccesssound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:consolesuccess.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
285 OPENAL_Sample_SetMinMaxDistance(samp[consolesuccesssound], 4.0f, 1000.0f);
287 samp[consolefailsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:consolefail.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
288 OPENAL_Sample_SetMinMaxDistance(samp[consolefailsound], 4.0f, 1000.0f);
290 samp[metalhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:MetalHit.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
291 OPENAL_Sample_SetMinMaxDistance(samp[metalhitsound], 8.0f, 2000.0f);
293 samp[clawslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clawslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
294 OPENAL_Sample_SetMinMaxDistance(samp[clawslicesound], 8.0f, 2000.0f);
296 samp[splattersound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:splatter.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
297 OPENAL_Sample_SetMinMaxDistance(samp[splattersound], 8.0f, 2000.0f);
299 samp[growlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Growl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
300 OPENAL_Sample_SetMinMaxDistance(samp[growlsound], 1000.0f, 2000.0f);
302 samp[growl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Growl2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
303 OPENAL_Sample_SetMinMaxDistance(samp[growl2sound], 1000.0f, 2000.0f);
305 samp[barksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
306 OPENAL_Sample_SetMinMaxDistance(samp[barksound], 1000.0f, 2000.0f);
308 samp[bark2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
309 OPENAL_Sample_SetMinMaxDistance(samp[bark2sound], 1000.0f, 2000.0f);
311 samp[bark3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
312 OPENAL_Sample_SetMinMaxDistance(samp[bark3sound], 1000.0f, 2000.0f);
314 samp[snarlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snarl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
315 OPENAL_Sample_SetMinMaxDistance(samp[snarlsound], 1000.0f, 2000.0f);
318 samp[snarl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snarl2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
319 OPENAL_Sample_SetMinMaxDistance(samp[snarl2sound], 1000.0f, 2000.0f);
321 samp[barkgrowlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:barkgrowl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
322 OPENAL_Sample_SetMinMaxDistance(samp[barkgrowlsound], 1000.0f, 2000.0f);
324 samp[rabbitattacksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
325 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattacksound], 1000.0f, 2000.0f);
327 samp[rabbitattack2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
328 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack2sound], 1000.0f, 2000.0f);
330 samp[rabbitattack3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
331 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack3sound], 1000.0f, 2000.0f);
333 samp[rabbitattack4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack4.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
334 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack4sound], 1000.0f, 2000.0f);
336 samp[rabbitpainsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
337 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpainsound], 1000.0f, 2000.0f);
339 samp[rabbitpain1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
340 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain1sound], 1000.0f, 2000.0f);
342 /*samp[rabbitpain2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
343 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain2sound], 1000.0f, 2000.0f);
345 samp[rabbitchitter] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitchitter.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
346 OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter], 1000.0f, 2000.0f);
348 samp[rabbitchitter2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitchitter2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
349 OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter2], 1000.0f, 2000.0f);
351 samp[swordstaffsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:swordstaff.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
352 OPENAL_Sample_SetMinMaxDistance(samp[swordstaffsound], 8.0f, 2000.0f);
354 samp[staffbodysound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffbody.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
355 OPENAL_Sample_SetMinMaxDistance(samp[staffbodysound], 8.0f, 2000.0f);
357 samp[staffheadsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffhead.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
358 OPENAL_Sample_SetMinMaxDistance(samp[staffheadsound], 8.0f, 2000.0f);
360 samp[staffbreaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffbreak.wav"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
361 OPENAL_Sample_SetMinMaxDistance(samp[staffbreaksound], 8.0f, 2000.0f);
364 void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha)
370 LOG(std::string("Loading texture...") + fileName);
372 // Fix filename so that is os appropreate
373 char * fixedFN = ConvertFileName(fileName);
375 unsigned char fileNamep[256];
376 CopyCStringToPascal(fixedFN, fileNamep);
378 upload_image( fileNamep ,hasalpha);
380 // std::string fname(fileName);
381 // std::transform(fname.begin(), fname.end(), tolower);
382 // TexIter it = textures.find(fname);
386 //if(textures.end() == it)
389 if ( texture.bpp == 24 )
394 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
396 if(!*textureid)glGenTextures( 1, textureid );
397 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
399 glBindTexture( GL_TEXTURE_2D, *textureid);
400 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
401 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
402 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
403 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
405 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.sizeX, texture.sizeY, 0,
406 // GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data);
408 //gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data );
410 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
412 // textures.insert(std::make_pair(fname, *textureid));
416 // *textureid = it->second;
420 void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize)
428 LOG(std::string("Loading texture (S)...") + fileName);
431 unsigned char fileNamep[256];
432 CopyCStringToPascal(ConvertFileName(fileName), fileNamep);
434 upload_image( fileNamep ,0);
435 //LoadTGA( fileName );
437 // std::string fname(fileName);
438 // std::transform(fname.begin(), fname.end(), tolower);
439 // TexIter it = textures.find(fname);
443 //if(textures.end() == it)
445 bytesPerPixel=texture.bpp/8;
448 if ( texture.bpp == 24 )
453 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
455 if(!*textureid)glGenTextures( 1, textureid );
456 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
458 glBindTexture( GL_TEXTURE_2D, *textureid);
459 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
460 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
461 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
462 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
465 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
466 if((i+1)%4||type==GL_RGB){
467 array[tempnum]=texture.data[i];
472 *skinsize=texture.sizeX;
474 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_RGB, GL_UNSIGNED_BYTE, array );
476 // textures.insert(std::make_pair(fname, *textureid));
480 // *textureid = it->second;
484 void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
491 LOG(std::string("Loading (S)...") + fileName);
494 float temptexdetail=texdetail;
496 //upload_image( fileName );
497 //LoadTGA( fileName );
499 // Converting file to something os specific
500 char * fixedFN = ConvertFileName(fileName);
503 unsigned char fileNamep[256];
504 CopyCStringToPascal(fixedFN, fileNamep);
506 upload_image( fileNamep ,0);
507 texdetail=temptexdetail;
511 bytesPerPixel=texture.bpp/8;
514 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
515 if((i+1)%4||bytesPerPixel==3){
516 array[tempnum]=texture.data[i];
523 bool Game::AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
530 //upload_image( fileName );
531 //LoadTGA( fileName );
533 unsigned char fileNamep[256];
534 CopyCStringToPascal(fileName,fileNamep);
537 opened=upload_image( fileNamep ,1);
550 bytesPerPixel=texture.bpp/8;
554 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
555 if(bytesPerPixel==3)alphanum=255;
556 else if((i+1)%4==0)alphanum=texture.data[i];
558 if((i+1)%4||bytesPerPixel==3){
559 if((i%4)==0)texture.data[i]*=tintr;
560 if((i%4)==1)texture.data[i]*=tintg;
561 if((i%4)==2)texture.data[i]*=tintb;
562 array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255);
572 //***************> ResizeGLScene() <******/
573 GLvoid Game::ReSizeGLScene(float fov, float pnear)
580 glViewport(0,0,screenwidth,screenheight);
582 glMatrixMode(GL_PROJECTION);
585 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
587 glMatrixMode(GL_MODELVIEW);
591 void Game::LoadingScreen()
593 static float loadprogress,minprogress,maxprogress;
594 static AbsoluteTime time = {0,0};
595 static AbsoluteTime frametime = {0,0};
596 AbsoluteTime currTime = UpTime ();
597 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
599 if (0 > deltaTime) // if negative microseconds
600 deltaTime /= -1000000.0;
601 else // else milliseconds
604 multiplier=deltaTime;
605 if(multiplier<.001)multiplier=.001;
606 if(multiplier>10)multiplier=10;
608 frametime = currTime; // reset for next time interval
613 glClearColor(0,0,0,1);
614 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
617 loadtime+=multiplier*4;
619 loadprogress=loadtime;
620 if(loadprogress>100)loadprogress=100;
622 //loadprogress=abs(Random()%100);
626 glEnable(GL_TEXTURE_2D);
627 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
628 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
629 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
630 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
631 glDisable(GL_CULL_FACE);
632 glDisable(GL_LIGHTING);
634 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
635 glPushMatrix(); // Store The Projection Matrix
636 glLoadIdentity(); // Reset The Projection Matrix
637 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
638 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
639 glPushMatrix(); // Store The Modelview Matrix
640 glLoadIdentity(); // Reset The Modelview Matrix
641 glTranslatef(screenwidth/2,screenheight/2,0);
642 glScalef((float)screenwidth/2,(float)screenheight/2,1);
643 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
645 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
646 //glColor4f(1,1,1,1);
647 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
648 if(loadscreencolor==1)glColor4f(1,0,0,1);
649 if(loadscreencolor==2)glColor4f(0,1,0,1);
650 if(loadscreencolor==3)glColor4f(0,0,1,1);
651 if(loadscreencolor==4)glColor4f(1,1,0,1);
652 if(loadscreencolor==5)glColor4f(1,0,1,1);
655 //glScalef(.25,.25,.25);
657 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
658 glVertex3f(-1, -1, 0.0f);
659 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
660 glVertex3f(1, -1, 0.0f);
661 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
662 glVertex3f(1, 1, 0.0f);
663 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
664 glVertex3f(-1, 1, 0.0f);
669 //glScalef(.25,.25,.25);
671 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
672 glVertex3f(-1, -1, 0.0f);
673 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
674 glVertex3f(1, -1, 0.0f);
675 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
676 glVertex3f(1, 1, 0.0f);
677 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
678 glVertex3f(-1, 1, 0.0f);
681 glDisable(GL_TEXTURE_2D);
682 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
683 glPopMatrix(); // Restore The Old Projection Matrix
684 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
685 glPopMatrix(); // Restore The Old Projection Matrix
689 glEnable(GL_TEXTURE_2D);
690 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
691 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
692 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
693 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
694 glDisable(GL_CULL_FACE);
695 glDisable(GL_LIGHTING);
697 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
698 glPushMatrix(); // Store The Projection Matrix
699 glLoadIdentity(); // Reset The Projection Matrix
700 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
701 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
702 glPushMatrix(); // Store The Modelview Matrix
703 glLoadIdentity(); // Reset The Modelview Matrix
704 glTranslatef(screenwidth/2,screenheight/2,0);
705 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
706 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
708 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
709 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
710 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
711 if(loadscreencolor==1)glColor4f(1,0,0,1);
712 if(loadscreencolor==2)glColor4f(0,1,0,1);
713 if(loadscreencolor==3)glColor4f(0,0,1,1);
714 if(loadscreencolor==4)glColor4f(1,1,0,1);
715 if(loadscreencolor==5)glColor4f(1,0,1,1);
718 //glScalef(.25,.25,.25);
720 glTexCoord2f(0+.5,0+.5);
721 glVertex3f(-1, -1, 0.0f);
722 glTexCoord2f(1+.5,0+.5);
723 glVertex3f(1, -1, 0.0f);
724 glTexCoord2f(1+.5,1+.5);
725 glVertex3f(1, 1, 0.0f);
726 glTexCoord2f(0+.5,1+.5);
727 glVertex3f(-1, 1, 0.0f);
730 glDisable(GL_TEXTURE_2D);
731 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
732 glPopMatrix(); // Restore The Old Projection Matrix
733 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
734 glPopMatrix(); // Restore The Old Projection Matrix
738 glEnable(GL_TEXTURE_2D);
739 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
740 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
741 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
742 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
743 glDisable(GL_CULL_FACE);
744 glDisable(GL_LIGHTING);
746 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
747 glPushMatrix(); // Store The Projection Matrix
748 glLoadIdentity(); // Reset The Projection Matrix
749 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
750 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
751 glPushMatrix(); // Store The Modelview Matrix
752 glLoadIdentity(); // Reset The Modelview Matrix
753 glTranslatef(screenwidth/2,screenheight/2,0);
754 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
755 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
757 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
759 //glScalef(.25,.25,.25);
761 glTexCoord2f(0+.2,0+.8);
762 glVertex3f(-1, -1, 0.0f);
763 glTexCoord2f(1+.2,0+.8);
764 glVertex3f(1, -1, 0.0f);
765 glTexCoord2f(1+.2,1+.8);
766 glVertex3f(1, 1, 0.0f);
767 glTexCoord2f(0+.2,1+.8);
768 glVertex3f(-1, 1, 0.0f);
771 glDisable(GL_TEXTURE_2D);
772 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
773 glPopMatrix(); // Restore The Old Projection Matrix
774 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
775 glPopMatrix(); // Restore The Old Projection Matrix
781 glEnable(GL_TEXTURE_2D);
782 static char string[256]="";
783 sprintf (string, "LOADING... %d%",(int)loadprogress);
785 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
786 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
787 text.glPrint(280,125,string,1,1,640,480);
791 if(flashamount>1)flashamount=1;
792 if(flashdelay<=0)flashamount-=multiplier;
794 if(flashamount<0)flashamount=0;
795 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
796 glDisable(GL_CULL_FACE);
797 glDisable(GL_LIGHTING);
798 glDisable(GL_TEXTURE_2D);
800 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
801 glPushMatrix(); // Store The Projection Matrix
802 glLoadIdentity(); // Reset The Projection Matrix
803 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
804 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
805 glPushMatrix(); // Store The Modelview Matrix
806 glLoadIdentity(); // Reset The Modelview Matrix
807 glScalef(screenwidth,screenheight,1);
808 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
810 glColor4f(flashr,flashg,flashb,flashamount);
812 glVertex3f(0, 0, 0.0f);
813 glVertex3f(256, 0, 0.0f);
814 glVertex3f(256, 256, 0.0f);
815 glVertex3f(0, 256, 0.0f);
817 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
818 glPopMatrix(); // Restore The Old Projection Matrix
819 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
820 glPopMatrix(); // Restore The Old Projection Matrix
821 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
822 glEnable(GL_CULL_FACE);
832 void Game::FadeLoadingScreen(float howmuch)
834 static float loadprogress,minprogress,maxprogress;
839 glClearColor(0,0,0,1);
840 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
842 loadprogress=howmuch;
844 //loadprogress=abs(Random()%100);
848 //glEnable(GL_TEXTURE_2D);
849 glDisable(GL_TEXTURE_2D);
850 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
851 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
852 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
853 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
854 glDisable(GL_CULL_FACE);
855 glDisable(GL_LIGHTING);
857 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
858 glPushMatrix(); // Store The Projection Matrix
859 glLoadIdentity(); // Reset The Projection Matrix
860 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
861 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
862 glPushMatrix(); // Store The Modelview Matrix
863 glLoadIdentity(); // Reset The Modelview Matrix
864 glTranslatef(screenwidth/2,screenheight/2,0);
865 glScalef((float)screenwidth/2,(float)screenheight/2,1);
866 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
868 glColor4f(loadprogress/100,0,0,1);
869 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
870 if(loadscreencolor==1)glColor4f(1,0,0,1);
871 if(loadscreencolor==2)glColor4f(0,1,0,1);
872 if(loadscreencolor==3)glColor4f(0,0,1,1);
873 if(loadscreencolor==4)glColor4f(1,1,0,1);
874 if(loadscreencolor==5)glColor4f(1,0,1,1);
877 //glScalef(.25,.25,.25);
880 glVertex3f(-1, -1, 0.0f);
882 glVertex3f(1, -1, 0.0f);
884 glVertex3f(1, 1, 0.0f);
886 glVertex3f(-1, 1, 0.0f);
889 glDisable(GL_TEXTURE_2D);
890 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
891 glPopMatrix(); // Restore The Old Projection Matrix
892 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
893 glPopMatrix(); // Restore The Old Projection Matrix
898 glEnable(GL_TEXTURE_2D);
899 static char string[256]="";
900 sprintf (string, "LOADING... %d%",(int)loadprogress);
902 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
903 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
904 text.glPrint(280,125,string,1,1,640,480);
911 void Game::InitGame()
914 ProcessSerialNumber PSN;
915 ProcessInfoRec pinfo;
918 /* set up process serial number */
919 PSN.highLongOfPSN = 0;
920 PSN.lowLongOfPSN = kCurrentProcess;
921 /* set up info block */
922 pinfo.processInfoLength = sizeof(pinfo);
923 pinfo.processName = NULL;
924 pinfo.processAppSpec = &pspec;
925 /* grab the vrefnum and directory */
926 err = GetProcessInformation(&PSN, &pinfo);
928 vRefNum = pspec.vRefNum;
939 numchallengelevels=14;
941 accountactive=Account::loadFile(":Data:Users");
947 whichjointstartarray[0]=righthip;
948 whichjointendarray[0]=rightfoot;
950 whichjointstartarray[1]=righthip;
951 whichjointendarray[1]=rightankle;
953 whichjointstartarray[2]=righthip;
954 whichjointendarray[2]=rightknee;
956 whichjointstartarray[3]=rightknee;
957 whichjointendarray[3]=rightankle;
959 whichjointstartarray[4]=rightankle;
960 whichjointendarray[4]=rightfoot;
962 whichjointstartarray[5]=lefthip;
963 whichjointendarray[5]=leftfoot;
965 whichjointstartarray[6]=lefthip;
966 whichjointendarray[6]=leftankle;
968 whichjointstartarray[7]=lefthip;
969 whichjointendarray[7]=leftknee;
971 whichjointstartarray[8]=leftknee;
972 whichjointendarray[8]=leftankle;
974 whichjointstartarray[9]=leftankle;
975 whichjointendarray[9]=leftfoot;
977 whichjointstartarray[10]=abdomen;
978 whichjointendarray[10]=rightshoulder;
980 whichjointstartarray[11]=abdomen;
981 whichjointendarray[11]=rightelbow;
983 whichjointstartarray[12]=abdomen;
984 whichjointendarray[12]=rightwrist;
986 whichjointstartarray[13]=abdomen;
987 whichjointendarray[13]=righthand;
989 whichjointstartarray[14]=rightshoulder;
990 whichjointendarray[14]=rightelbow;
992 whichjointstartarray[15]=rightelbow;
993 whichjointendarray[15]=rightwrist;
995 whichjointstartarray[16]=rightwrist;
996 whichjointendarray[16]=righthand;
998 whichjointstartarray[17]=abdomen;
999 whichjointendarray[17]=leftshoulder;
1001 whichjointstartarray[18]=abdomen;
1002 whichjointendarray[18]=leftelbow;
1004 whichjointstartarray[19]=abdomen;
1005 whichjointendarray[19]=leftwrist;
1007 whichjointstartarray[20]=abdomen;
1008 whichjointendarray[20]=lefthand;
1010 whichjointstartarray[21]=leftshoulder;
1011 whichjointendarray[21]=leftelbow;
1013 whichjointstartarray[22]=leftelbow;
1014 whichjointendarray[22]=leftwrist;
1016 whichjointstartarray[23]=leftwrist;
1017 whichjointendarray[23]=lefthand;
1019 whichjointstartarray[24]=abdomen;
1020 whichjointendarray[24]=neck;
1022 whichjointstartarray[25]=neck;
1023 whichjointendarray[25]=head;
1025 FadeLoadingScreen(0);
1029 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1031 int temptexdetail=texdetail;
1033 text.LoadFontTexture(":Data:Textures:Font.png");
1035 texdetail=temptexdetail;
1037 FadeLoadingScreen(10);
1053 for (int it = 0; it < 100; ++it)
1058 for (int it = 0; it < 20; ++it)
1063 LOG("Initializing sound system...");
1068 extern bool cmdline(const char *cmd);
1069 unsigned char rc = 0;
1070 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
1071 if (cmdline("forceoss")) // ...but let user override that.
1072 output = OPENAL_OUTPUT_OSS;
1073 else if (cmdline("nosound"))
1074 output = OPENAL_OUTPUT_NOSOUND;
1076 OPENAL_SetOutput(output);
1077 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
1079 // if we tried ALSA and failed, fall back to OSS.
1080 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
1083 output = OPENAL_OUTPUT_OSS;
1084 OPENAL_SetOutput(output);
1085 rc = OPENAL_Init(44100, 32, 0);
1092 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
1093 OPENAL_SetOutput(output);
1094 rc = OPENAL_Init(44100, 32, 0);
1097 OPENAL_Init(44100, 32, 0);
1100 OPENAL_SetSFXMasterVolume((int)(volume*255));
1102 strm[stream_music3] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music3.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;}
1103 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music3], 4.0f, 1000.0f);
1104 OPENAL_Stream_SetMode(strm[stream_music3], OPENAL_LOOP_NORMAL);
1107 // PlaySoundEx( stream_music3, strm[stream_music3], NULL, true);
1108 PlayStreamEx(stream_music3, strm[stream_music3], 0, true);
1109 OPENAL_SetPaused(channels[stream_music3], false);
1110 OPENAL_SetVolume(channels[stream_music3], 256);
1113 FadeLoadingScreen(20);
1116 strm[stream_wind] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:wind.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1117 // OPENAL_Sample_SetMinMaxDistance(strm[stream_wind], 4.0f, 1000.0f);
1118 OPENAL_Stream_SetMode(strm[stream_wind], OPENAL_LOOP_NORMAL);
1120 FadeLoadingScreen(30);
1122 strm[stream_desertambient] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:desertambient.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1123 // OPENAL_Sample_SetMinMaxDistance(strm[stream_desertambient], 4.0f, 1000.0f);
1124 OPENAL_Stream_SetMode(strm[stream_desertambient], OPENAL_LOOP_NORMAL);
1127 FadeLoadingScreen(40);
1129 samp[firestartsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:firestart.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1130 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1132 strm[stream_firesound] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:fire.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1133 // OPENAL_Sample_SetMinMaxDistance(strm[stream_firesound], 8.0f, 2000.0f);
1134 OPENAL_Stream_SetMode(strm[stream_firesound], OPENAL_LOOP_NORMAL);
1136 FadeLoadingScreen(50);
1138 samp[fireendsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:fireend.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1139 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1142 strm[stream_music1grass] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1grass.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;}
1143 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1grass], 4.0f, 1000.0f);
1144 OPENAL_Stream_SetMode(strm[stream_music1grass], OPENAL_LOOP_NORMAL);
1146 strm[stream_music1snow] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1snow.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;}
1147 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1snow], 4.0f, 1000.0f);
1148 OPENAL_Stream_SetMode(strm[stream_music1snow], OPENAL_LOOP_NORMAL);
1150 FadeLoadingScreen(60);
1152 strm[stream_music1desert] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1desert.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;}
1153 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1desert], 4.0f, 1000.0f);
1154 OPENAL_Stream_SetMode(strm[stream_music1desert], OPENAL_LOOP_NORMAL);
1156 FadeLoadingScreen(80);
1157 strm[stream_music2] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music2.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;}
1158 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music2], 4.0f, 1000.0f);
1159 OPENAL_Stream_SetMode(strm[stream_music2], OPENAL_LOOP_NORMAL);
1164 FadeLoadingScreen(90);
1167 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
1169 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
1170 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
1171 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
1173 temptexdetail=texdetail;
1174 if(texdetail>2)texdetail=2;
1175 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
1176 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
1177 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
1178 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
1179 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
1180 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
1181 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
1182 texdetail=temptexdetail;
1187 FadeLoadingScreen(95);
1198 newscreenwidth=screenwidth;
1199 newscreenheight=screenheight;
1203 void Game::LoadStuff()
1205 static float temptexdetail;
1206 static float viewdistdetail;
1207 static int i,j,texsize;
1214 /*musicvolume[3]=512;
1215 PlaySoundEx( music4, samp[music4], NULL, true);
1216 OPENAL_SetPaused(channels[music4], false);
1217 OPENAL_SetVolume(channels[music4], 512);
1223 //texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1225 for(i=0;i<maxplayers;i++)
1227 if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
1229 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
1231 player[i].skeleton.drawmodel.textureptr=0;;
1234 //temptexdetail=texdetail;
1237 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
1238 //texdetail=temptexdetail;
1240 temptexdetail=texdetail;
1242 text.LoadFontTexture(":Data:Textures:Font.png");
1244 texdetail=temptexdetail;
1249 viewdistance=50*megascale*viewdistdetail;
1269 realtexdetail=texdetail;
1272 if(texdetail<1)texdetail=1;
1273 realtexdetail=texdetail*4;
1279 /*LoadTexture(":Data:Textures:snow.png",&terraintexture,1);
1281 LoadTexture(":Data:Textures:rock.png",&terraintexture2,1);
1283 LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
1287 LOG("Loading weapon data...");
1289 LoadTexture(":Data:Textures:knife.png",&weapons.knifetextureptr,0,1);
1290 LoadTexture(":Data:Textures:bloodknife.png",&weapons.bloodknifetextureptr,0,1);
1291 LoadTexture(":Data:Textures:lightbloodknife.png",&weapons.lightbloodknifetextureptr,0,1);
1292 LoadTexture(":Data:Textures:sword.jpg",&weapons.swordtextureptr,1,0);
1293 LoadTexture(":Data:Textures:Swordblood.jpg",&weapons.bloodswordtextureptr,1,0);
1294 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&weapons.lightbloodswordtextureptr,1,0);
1295 LoadTexture(":Data:Textures:Staff.jpg",&weapons.stafftextureptr,1,0);
1297 weapons.throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
1298 weapons.throwingknifemodel.Scale(.001,.001,.001);
1299 //weapons.throwingknifemodel.Rotate(0,0,-90);
1300 weapons.throwingknifemodel.Rotate(90,0,0);
1301 weapons.throwingknifemodel.Rotate(0,90,0);
1302 weapons.throwingknifemodel.flat=0;
1303 weapons.throwingknifemodel.CalculateNormals(1);
1304 //weapons.throwingknifemodel.ScaleNormals(-1,-1,-1);
1306 weapons.swordmodel.load((char *)":Data:Models:sword.solid",1);
1307 weapons.swordmodel.Scale(.001,.001,.001);
1308 //weapons.swordmodel.Rotate(0,0,-90);
1309 weapons.swordmodel.Rotate(90,0,0);
1310 weapons.swordmodel.Rotate(0,90,0);
1311 weapons.swordmodel.Rotate(0,0,90);
1312 weapons.swordmodel.flat=1;
1313 weapons.swordmodel.CalculateNormals(1);
1314 //weapons.swordmodel.ScaleNormals(-1,-1,-1);
1316 weapons.staffmodel.load((char *)":Data:Models:staff.solid",1);
1317 weapons.staffmodel.Scale(.005,.005,.005);
1318 //weapons.staffmodel.Rotate(0,0,-90);
1319 weapons.staffmodel.Rotate(90,0,0);
1320 weapons.staffmodel.Rotate(0,90,0);
1321 weapons.staffmodel.Rotate(0,0,90);
1322 weapons.staffmodel.flat=1;
1323 weapons.staffmodel.CalculateNormals(1);
1324 //weapons.staffmodel.ScaleNormals(-1,-1,-1);
1326 //temptexdetail=texdetail;
1327 //if(texdetail>4)texdetail=4;
1328 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
1330 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
1332 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
1334 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
1337 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
1339 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
1341 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1);
1343 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1);
1345 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1);
1347 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1);
1349 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1);
1351 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1);
1352 //texdetail=temptexdetail;
1353 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1);*/
1357 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
1359 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
1362 //LoadTexture(":Data:Textures:box.jpg",&objects.boxtextureptr,1,0);
1365 LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1366 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1367 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1368 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1369 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1370 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1371 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1372 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1373 LoadTexture(":Data:Textures:splinter.png",&sprites.splintertexture,1,1);
1374 LoadTexture(":Data:Textures:leaf.png",&sprites.leaftexture,1,1);
1375 LoadTexture(":Data:Textures:tooth.png",&sprites.toothtexture,1,1);
1379 ReSizeGLScene(90,.01);
1386 if(detail)kTextureSize=1024;
1387 if(detail==1)kTextureSize=512;
1388 if(detail==0)kTextureSize=256;
1391 //drawmode=motionblurmode;
1393 //Set up distant light
1397 light.ambient[0]=.2;
1398 light.ambient[1]=.2;
1399 light.ambient[2]=.24;
1402 light.location.z=-.2;
1403 Normalise(&light.location);
1413 texscale=.2/megascale/viewdistdetail;
1414 terrain.scale=3*megascale*terraindetail*viewdistdetail;
1416 viewer.x=terrain.size/2*terrain.scale;
1417 viewer.z=terrain.size/2*terrain.scale;
1419 hawk.load((char *)":Data:Models:hawk.solid",1);
1420 hawk.Scale(.03,.03,.03);
1421 hawk.Rotate(90,1,1);
1422 hawk.CalculateNormals(0);
1423 hawk.ScaleNormals(-1,-1,-1);
1424 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
1425 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
1426 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
1429 eye.load((char *)":Data:Models:eye.solid",1);
1430 eye.Scale(.03,.03,.03);
1431 eye.CalculateNormals(0);
1433 cornea.load((char *)":Data:Models:cornea.solid",1);
1434 cornea.Scale(.03,.03,.03);
1435 cornea.CalculateNormals(0);
1437 iris.load((char *)":Data:Models:iris.solid",1);
1438 iris.Scale(.03,.03,.03);
1439 iris.CalculateNormals(0);
1441 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
1442 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
1450 //if(targetlevel!=7)
1451 Loadlevel(targetlevel);
1454 rabbitcoords=player[0].coords;
1455 rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
1457 animation[runanim].Load((char *)":Data:Animations:Run",middleheight,neutral);
1459 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
1460 animation[stopanim].Load((char *)":Data:Animations:Stop",middleheight,neutral);
1462 animation[jumpupanim].Load((char *)":Data:Animations:JumpUp",highheight,neutral);
1463 animation[jumpdownanim].Load((char *)":Data:Animations:JumpDown",highheight,neutral);
1465 animation[landanim].Load((char *)":Data:Animations:Landing",lowheight,neutral);
1466 animation[landhardanim].Load((char *)":Data:Animations:Landhard",lowheight,neutral);
1467 animation[climbanim].Load((char *)":Data:Animations:Climb",lowheight,neutral);
1468 animation[hanganim].Load((char *)":Data:Animations:Hangon",lowheight,neutral);
1469 animation[spinkickanim].Load((char *)":Data:Animations:SpinKick",middleheight,normalattack);
1471 animation[getupfromfrontanim].Load((char *)":Data:Animations:GetUpFromFront",lowheight,neutral);
1472 animation[getupfrombackanim].Load((char *)":Data:Animations:GetUpFromBack",lowheight,neutral);
1473 animation[crouchanim].Load((char *)":Data:Animations:Crouch",lowheight,neutral);
1474 animation[sneakanim].Load((char *)":Data:Animations:Sneak",lowheight,neutral);
1475 animation[rollanim].Load((char *)":Data:Animations:Roll",lowheight,neutral);
1476 animation[flipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1477 animation[frontflipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1478 animation[spinkickreversedanim].Load((char *)":Data:Animations:SpinKickCaught",middleheight,reversed);
1480 animation[spinkickreversalanim].Load((char *)":Data:Animations:SpinKickCatch",middleheight,reversal);
1481 animation[lowkickanim].Load((char *)":Data:Animations:lowkick",middleheight,normalattack);
1482 animation[sweepanim].Load((char *)":Data:Animations:sweep",lowheight,normalattack);
1483 animation[sweepreversedanim].Load((char *)":Data:Animations:SweepCaught",lowheight,reversed);
1484 animation[sweepreversalanim].Load((char *)":Data:Animations:SweepCatch",middleheight,reversal);
1485 animation[rabbitkickanim].Load((char *)":Data:Animations:RabbitKick",middleheight,normalattack);
1486 animation[rabbitkickreversedanim].Load((char *)":Data:Animations:RabbitKickCaught",middleheight,reversed);
1487 animation[rabbitkickreversalanim].Load((char *)":Data:Animations:RabbitKickCatch",lowheight,reversal);
1488 animation[upunchanim].Load((char *)":Data:Animations:Upunch",middleheight,normalattack);
1489 animation[staggerbackhighanim].Load((char *)":Data:Animations:Staggerbackhigh",middleheight,neutral);
1490 animation[upunchreversedanim].Load((char *)":Data:Animations:UpunchCaught",middleheight,reversed);
1492 animation[upunchreversalanim].Load((char *)":Data:Animations:UpunchCatch",middleheight,reversal);
1493 animation[hurtidleanim].Load((char *)":Data:Animations:Hurtidle",middleheight,neutral);
1494 animation[backhandspringanim].Load((char *)":Data:Animations:Backhandspring",middleheight,neutral);
1495 animation[fightidleanim].Load((char *)":Data:Animations:Fightidle",middleheight,neutral);
1496 animation[walkanim].Load((char *)":Data:Animations:Walk",middleheight,neutral);
1498 animation[fightsidestep].Load((char *)":Data:Animations:Fightsidestep",middleheight,neutral);
1499 animation[killanim].Load((char *)":Data:Animations:Kill",middleheight,normalattack);
1500 animation[sneakattackanim].Load((char *)":Data:Animations:Sneakattack",middleheight,reversal);
1501 animation[sneakattackedanim].Load((char *)":Data:Animations:Sneakattacked",middleheight,reversed);
1502 animation[drawrightanim].Load((char *)":Data:Animations:drawright",middleheight,neutral);
1503 animation[knifeslashstartanim].Load((char *)":Data:Animations:slashstart",middleheight,normalattack);
1504 animation[crouchdrawrightanim].Load((char *)":Data:Animations:crouchdrawright",lowheight,neutral);
1505 animation[crouchstabanim].Load((char *)":Data:Animations:crouchstab",lowheight,normalattack);
1507 animation[knifefollowanim].Load((char *)":Data:Animations:slashfollow",middleheight,reversal);
1508 animation[knifefollowedanim].Load((char *)":Data:Animations:slashfollowed",middleheight,reversed);
1509 animation[knifethrowanim].Load((char *)":Data:Animations:knifethrow",middleheight,normalattack);
1510 animation[removeknifeanim].Load((char *)":Data:Animations:removeknife",middleheight,neutral);
1511 animation[crouchremoveknifeanim].Load((char *)":Data:Animations:crouchremoveknife",lowheight,neutral);
1512 animation[jumpreversedanim].Load((char *)":Data:Animations:JumpCaught",middleheight,reversed);
1513 animation[jumpreversalanim].Load((char *)":Data:Animations:JumpCatch",middleheight,reversal);
1514 animation[staggerbackhardanim].Load((char *)":Data:Animations:Staggerbackhard",middleheight,neutral);
1516 animation[dropkickanim].Load((char *)":Data:Animations:Dropkick",middleheight,normalattack);
1517 animation[winduppunchanim].Load((char *)":Data:Animations:Winduppunch",middleheight,normalattack);
1518 animation[winduppunchblockedanim].Load((char *)":Data:Animations:Winduppunchblocked",middleheight,normalattack);
1519 animation[blockhighleftanim].Load((char *)":Data:Animations:Blockhighleft",middleheight,normalattack);
1520 animation[blockhighleftstrikeanim].Load((char *)":Data:Animations:Blockhighleftstrike",middleheight,normalattack);
1521 animation[backflipanim].Load((char *)":Data:Animations:Backflip",highheight,neutral);
1522 animation[walljumpbackanim].Load((char *)":Data:Animations:Walljumpback",highheight,neutral);
1523 animation[walljumpfrontanim].Load((char *)":Data:Animations:Walljumpfront",highheight,neutral);
1524 animation[rightflipanim].Load((char *)":Data:Animations:Rightflip",highheight,neutral);
1525 animation[walljumprightanim].Load((char *)":Data:Animations:Walljumpright",highheight,neutral);
1526 animation[leftflipanim].Load((char *)":Data:Animations:Leftflip",highheight,neutral);
1527 animation[walljumpleftanim].Load((char *)":Data:Animations:Walljumpleft",highheight,neutral);
1528 animation[walljumprightkickanim].Load((char *)":Data:Animations:Walljumprightkick",highheight,neutral);
1529 animation[walljumpleftkickanim].Load((char *)":Data:Animations:Walljumpleftkick",highheight,neutral);
1530 animation[knifefightidleanim].Load((char *)":Data:Animations:Knifefightidle",middleheight,neutral);
1531 animation[knifesneakattackanim].Load((char *)":Data:Animations:Knifesneakattack",middleheight,reversal);
1532 animation[knifesneakattackedanim].Load((char *)":Data:Animations:Knifesneakattacked",middleheight,reversed);
1533 animation[swordfightidleanim].Load((char *)":Data:Animations:swordfightidle",middleheight,neutral);
1534 animation[drawleftanim].Load((char *)":Data:Animations:drawleft",middleheight,neutral);
1535 animation[swordslashanim].Load((char *)":Data:Animations:swordslash",middleheight,normalattack);
1536 animation[swordgroundstabanim].Load((char *)":Data:Animations:swordgroundstab",lowheight,normalattack);
1537 animation[dodgebackanim].Load((char *)":Data:Animations:dodgeback",middleheight,neutral);
1538 animation[swordsneakattackanim].Load((char *)":Data:Animations:Swordsneakattack",middleheight,reversal);
1539 animation[swordsneakattackedanim].Load((char *)":Data:Animations:Swordsneakattacked",middleheight,reversed);
1540 animation[swordslashreversedanim].Load((char *)":Data:Animations:swordslashCaught",middleheight,reversed);
1541 animation[swordslashreversalanim].Load((char *)":Data:Animations:swordslashCatch",middleheight,reversal);
1542 animation[knifeslashreversedanim].Load((char *)":Data:Animations:knifeslashCaught",middleheight,reversed);
1543 animation[knifeslashreversalanim].Load((char *)":Data:Animations:knifeslashCatch",middleheight,reversal);
1544 animation[swordfightidlebothanim].Load((char *)":Data:Animations:swordfightidleboth",middleheight,neutral);
1545 animation[swordslashparryanim].Load((char *)":Data:Animations:sworduprightparry",middleheight,normalattack);
1546 animation[swordslashparriedanim].Load((char *)":Data:Animations:swordslashparried",middleheight,normalattack);
1547 animation[wolfidle].Load((char *)":Data:Animations:Wolfidle",middleheight,neutral);
1548 animation[wolfcrouchanim].Load((char *)":Data:Animations:Wolfcrouch",lowheight,neutral);
1549 animation[wolflandanim].Load((char *)":Data:Animations:Wolflanding",lowheight,neutral);
1550 animation[wolflandhardanim].Load((char *)":Data:Animations:Wolflandhard",lowheight,neutral);
1551 animation[wolfrunanim].Load((char *)":Data:Animations:Wolfrun",middleheight,neutral);
1552 animation[wolfrunninganim].Load((char *)":Data:Animations:Wolfrunning",middleheight,neutral);
1553 animation[rabbitrunninganim].Load((char *)":Data:Animations:Rabbitrunning",middleheight,neutral);
1554 animation[wolfstopanim].Load((char *)":Data:Animations:Wolfstop",middleheight,neutral);
1555 animation[rabbittackleanim].Load((char *)":Data:Animations:Rabbittackle",middleheight,neutral);
1556 animation[rabbittacklinganim].Load((char *)":Data:Animations:Rabbittackling",middleheight,reversal);
1557 animation[rabbittackledbackanim].Load((char *)":Data:Animations:Rabbittackledback",middleheight,reversed);
1558 animation[rabbittackledfrontanim].Load((char *)":Data:Animations:Rabbittackledfront",middleheight,reversed);
1559 animation[wolfslapanim].Load((char *)":Data:Animations:Wolfslap",middleheight,normalattack);
1560 animation[staffhitanim].Load((char *)":Data:Animations:StaffHit",middleheight,normalattack);
1561 animation[staffgroundsmashanim].Load((char *)":Data:Animations:StaffGroundSmash",lowheight,normalattack);
1562 animation[staffspinhitanim].Load((char *)":Data:Animations:Spinwhack",middleheight,normalattack);
1563 animation[staffhitreversedanim].Load((char *)":Data:Animations:StaffHitCaught",middleheight,reversed);
1564 animation[staffhitreversalanim].Load((char *)":Data:Animations:StaffHitCatch",middleheight,reversal);
1565 animation[staffspinhitreversedanim].Load((char *)":Data:Animations:SpinWhackCaught",middleheight,reversed);
1566 animation[staffspinhitreversalanim].Load((char *)":Data:Animations:SpinWhackCatch",middleheight,reversal);
1568 animation[sitanim].Load((char *)":Data:Animations:Sit",lowheight,neutral);
1569 animation[sleepanim].Load((char *)":Data:Animations:Sleep",lowheight,neutral);
1570 animation[talkidleanim].Load((char *)":Data:Animations:TalkIdle",middleheight,neutral);
1572 animation[sitwallanim].Load((char *)":Data:Animations:Dying",lowheight,neutral);
1573 animation[dead1anim].Load((char *)":Data:Animations:Dead1",lowheight,neutral);
1574 animation[dead2anim].Load((char *)":Data:Animations:Dead2",lowheight,neutral);
1575 animation[dead3anim].Load((char *)":Data:Animations:Dead3",lowheight,neutral);
1576 animation[dead4anim].Load((char *)":Data:Animations:Dead4",lowheight,neutral);
1577 //Fix knife stab, too lazy to do it manually
1581 for(i=0;i<player[0].skeleton.num_joints;i++){
1582 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
1583 animation[knifesneakattackanim].position[i][j]+=moveamount;
1590 for(i=0;i<player[0].skeleton.num_joints;i++){
1591 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
1592 animation[knifesneakattackedanim].position[i][j]+=moveamount;
1599 for(i=0;i<player[0].skeleton.num_joints;i++){
1600 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
1601 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
1602 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
1603 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
1605 animation[dead1anim].speed[0]=0.001;
1606 animation[dead2anim].speed[0]=0.001;
1607 animation[dead3anim].speed[0]=0.001;
1608 animation[dead4anim].speed[0]=0.001;
1610 animation[dead1anim].speed[1]=0.001;
1611 animation[dead2anim].speed[1]=0.001;
1612 animation[dead3anim].speed[1]=0.001;
1613 animation[dead4anim].speed[1]=0.001;
1615 for(i=0;i<player[0].skeleton.num_joints;i++){
1616 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1617 animation[swordsneakattackanim].position[i][j]+=moveamount;
1622 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1623 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
1629 for(i=0;i<player[0].skeleton.num_joints;i++){
1630 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
1631 animation[swordsneakattackedanim].position[i][j]+=moveamount;
1635 for(i=0;i<player[0].skeleton.num_joints;i++){
1636 for(j=0;j<animation[sleepanim].numframes;j++){
1637 animation[sleepanim].position[i][j]=DoRotation(animation[sleepanim].position[i][j],0,180,0);
1643 temptexdetail=texdetail;
1645 texdetail=temptexdetail;
1652 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1654 glGenTextures( 1, &screentexture );
1655 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1658 glEnable(GL_TEXTURE_2D);
1659 glBindTexture( GL_TEXTURE_2D, screentexture);
1660 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1661 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1663 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1669 /*PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1670 OPENAL_SetVolume(channels[consolesuccesssound], 256);
1671 OPENAL_SetPaused(channels[consolesuccesssound], false);
1674 float gLoc[3]={0,0,0};
1675 float vel[3]={0,0,0};
1676 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1677 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1678 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1679 OPENAL_SetVolume(channels[fireendsound], 256);
1680 OPENAL_SetPaused(channels[fireendsound], false);
1681 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);