X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FWeapons.cpp;h=267bd149d1ea2547fd5fa8ad64586d92cedc48ce;hb=85f9eeb8f438d6d542c0c7b7446b31585cc9c23d;hp=c4ee9f5aab46efaa74613997cf8141f5c167ed6a;hpb=9a5f2758e538d9216d255b4797f042a1b6874272;p=lugaru.git diff --git a/Source/Weapons.cpp b/Source/Weapons.cpp index c4ee9f5..267bd14 100644 --- a/Source/Weapons.cpp +++ b/Source/Weapons.cpp @@ -21,15 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /**> HEADER FILES <**/ #include "Weapons.h" +#include "openal_wrapper.h" +#include "Animation.h" +#include "Sounds.h" extern float multiplier; -extern Animation animation[animation_count]; -extern FSOUND_SAMPLE *samp[100]; extern int channels[100]; extern Terrain terrain; extern float gravity; extern int environment; -extern Sprites sprites; extern int detail; extern FRUSTUM frustum; extern XYZ viewer; @@ -58,7 +58,7 @@ extern float bonustotal; extern float bonustime; extern int tutoriallevel; extern int numthrowkill; -extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); +extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); void Weapons::DoStuff(){ static int i,whichpatchx,whichpatchz,j,k,whichhit,m; @@ -98,26 +98,19 @@ void Weapons::DoStuff(){ vel[1]=0; vel[2]=0; PlaySoundEx( staffbreaksound, samp[staffbreaksound], NULL, true); - FSOUND_3D_SetAttributes(channels[staffbreaksound], gLoc, vel); - FSOUND_SetVolume(channels[staffbreaksound], 256); - FSOUND_SetPaused(channels[staffbreaksound], false); + OPENAL_3D_SetAttributes(channels[staffbreaksound], gLoc, vel); + OPENAL_SetVolume(channels[staffbreaksound], 256); + OPENAL_SetPaused(channels[staffbreaksound], false); XYZ tempvel; XYZ speed; //speed=(tippoint[i]-oldtippoint[i])/multiplier/6; speed=0; - /*for(j=0;j<10;j++){ - tempvel.x=float(abs(Random()%100)-50)/20; - tempvel.y=float(abs(Random()%100)-50)/20; - tempvel.z=float(abs(Random()%100)-50)/20; - tempvel+=speed; - sprites.MakeSprite(cloudimpactsprite, position[i]+(tippoint[i]-position[i])*((float)j-2)/8,tempvel*.5, 115/255,73/255,12/255, .15+float(abs(Random()%100)-50)/1000, .7); - }*/ for(j=0;j<40;j++){ tempvel.x=float(abs(Random()%100)-50)/20; tempvel.y=float(abs(Random()%100)-50)/20; tempvel.z=float(abs(Random()%100)-50)/20; tempvel+=speed; - sprites.MakeSprite(splintersprite, position[i]+(tippoint[i]-position[i])*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1); + Sprite::MakeSprite(splintersprite, position[i]+(tippoint[i]-position[i])*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1); } int tempowner; tempowner=owner[i]; @@ -189,13 +182,13 @@ void Weapons::DoStuff(){ vel[1]=0; vel[2]=0; PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true); - FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel); - FSOUND_SetVolume(channels[knifesheathesound], 128); - FSOUND_SetPaused(channels[knifesheathesound], false); + OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel); + OPENAL_SetVolume(channels[knifesheathesound], 128); + OPENAL_SetPaused(channels[knifesheathesound], false); bloody[i]=0; - sprites.MakeSprite(cloudimpactsprite, position[i],velocity[i], 1,1,1, .8, .3); + Sprite::MakeSprite(cloudimpactsprite, position[i],velocity[i], 1,1,1, .8, .3); } else { physics[i]=1; @@ -224,9 +217,9 @@ void Weapons::DoStuff(){ vel[1]=player[j].velocity.y; vel[2]=player[j].velocity.z; PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true); - FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel); - FSOUND_SetVolume(channels[knifedrawsound], 128); - FSOUND_SetPaused(channels[knifedrawsound], false); + OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel); + OPENAL_SetVolume(channels[knifedrawsound], 128); + OPENAL_SetPaused(channels[knifedrawsound], false); player[j].weaponactive=0; player[j].targetanimation=removeknifeanim; @@ -256,11 +249,11 @@ void Weapons::DoStuff(){ player[j].skeleton.joints[player[j].skeleton.jointlabels[rightshoulder]].velocity+=velocity[i]*2; player[j].skeleton.joints[player[j].skeleton.jointlabels[leftshoulder]].velocity+=velocity[i]*2; //player[j].Puff(abdomen); - if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); - if(tutoriallevel==1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3); + if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3); + if(tutoriallevel==1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3); footvel=tippoint[i]-position[i]; Normalise(&footvel); - if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1); + if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1); if(tutoriallevel!=1){ if(player[j].weaponstuckwhere==0)player[j].DoBloodBig(2,205); @@ -282,9 +275,9 @@ void Weapons::DoStuff(){ vel[1]=0; vel[2]=0; PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true); - FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel); - FSOUND_SetVolume(channels[fleshstabsound], 128); - FSOUND_SetPaused(channels[fleshstabsound], false); + OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel); + OPENAL_SetVolume(channels[fleshstabsound], 128); + OPENAL_SetPaused(channels[fleshstabsound], false); if(animation[player[0].targetanimation].height==highheight){ bonus=ninja; @@ -351,20 +344,20 @@ void Weapons::DoStuff(){ vel[1]=0; vel[2]=0; PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true); - FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel); - FSOUND_SetVolume(channels[knifesheathesound], 128); - FSOUND_SetPaused(channels[knifesheathesound], false); + OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel); + OPENAL_SetVolume(channels[knifesheathesound], 128); + OPENAL_SetPaused(channels[knifesheathesound], false); XYZ terrainlight; terrainlight=terrain.getLighting(position[i].x,position[i].z); if(environment==snowyenvironment){ - if(findDistancefast(&position[i],&viewer).2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); - FSOUND_SetPaused(channels[whichsound], false); + OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); + if(terrain.getOpacity(position[i].x,position[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); + else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); + OPENAL_SetPaused(channels[whichsound], false); if(terrain.getOpacity(position[i].x,position[i].z)<.2){ XYZ terrainlight; terrainlight=terrain.getLighting(position[i].x,position[i].z); if(environment==snowyenvironment){ - if(findDistancefast(&position[i],&viewer).2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); - FSOUND_SetPaused(channels[whichsound], false); + OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); + if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); + else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); + OPENAL_SetPaused(channels[whichsound], false); if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)<.2){ XYZ terrainlight; terrainlight=terrain.getLighting(tippoint[i].x,tippoint[i].z); if(environment==snowyenvironment){ - if(findDistancefast(&tippoint[i],&viewer).2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); - FSOUND_SetPaused(channels[whichsound], false); + OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); + if(terrain.getOpacity(position[i].x,position[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); + else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); + OPENAL_SetPaused(channels[whichsound], false); } position[i]+=(mid-oldmid)*20; } @@ -864,10 +857,10 @@ void Weapons::DoStuff(){ vel[1]=0; vel[2]=0; PlaySoundEx( whichsound, samp[whichsound], NULL, true); - FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel); - if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); - FSOUND_SetPaused(channels[whichsound], false); + OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); + if(terrain.getOpacity(position[i].x,position[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); + else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); + OPENAL_SetPaused(channels[whichsound], false); } tippoint[i]+=(mid-oldmid)*20; } @@ -906,10 +899,10 @@ void Weapons::DoStuff(){ vel[1]=0; vel[2]=0; PlaySoundEx( whichsound, samp[whichsound], NULL, true); - FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel); - if(terrain.getOpacity(position[i].x,position[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); - FSOUND_SetPaused(channels[whichsound], false); + OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); + if(terrain.getOpacity(position[i].x,position[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); + else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); + OPENAL_SetPaused(channels[whichsound], false); } } @@ -945,10 +938,10 @@ void Weapons::DoStuff(){ vel[1]=0; vel[2]=0; PlaySoundEx( whichsound, samp[whichsound], NULL, true); - FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel); - if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)FSOUND_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - else FSOUND_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); - FSOUND_SetPaused(channels[whichsound], false); + OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); + if(terrain.getOpacity(tippoint[i].x,tippoint[i].z)>.2)OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); + else OPENAL_SetVolume(channels[whichsound], 32*findLengthfast(&bounceness)); + OPENAL_SetPaused(channels[whichsound], false); } }*/ @@ -1082,7 +1075,7 @@ void Weapons::DoStuff(){ bloodloc.y-=.05; if(bloodtoggle){ bloodvel=0; - sprites.MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1); + Sprite::MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1); } } } @@ -1101,9 +1094,9 @@ void Weapons::DoStuff(){ normalrot.y=1; } } - sprites.MakeSprite(weaponflamesprite, position[i]+tippoint[i]*(((float)abs(Random()%100))/600+.05),normalrot, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*1/3, 1); - sprites.speed[sprites.numsprites-1]=4; - sprites.alivetime[sprites.numsprites-1]=.3; + Sprite::MakeSprite(weaponflamesprite, position[i]+tippoint[i]*(((float)abs(Random()%100))/600+.05),normalrot, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*1/3, 1); + Sprite::setLastSpriteSpeed(4); + Sprite::setLastSpriteAlivetime(.3); } } @@ -1116,9 +1109,9 @@ void Weapons::DoStuff(){ if(Random()%50==0&&findDistancefast(&position[i],&viewer)>80){ XYZ shinepoint; shinepoint=position[i]+(tippoint[i]-position[i])*(((float)abs(Random()%100))/100); - sprites.MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1); - sprites.speed[sprites.numsprites-1]=4; - sprites.alivetime[sprites.numsprites-1]=.3; + Sprite::MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1); + Sprite::setLastSpriteSpeed(4); + Sprite::setLastSpriteAlivetime(.3); } } } @@ -1277,13 +1270,13 @@ int Weapons::Draw() XYZ nothingpoint; nothingpoint=0; shinepoint=position[i]; - sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1); - sprites.speed[sprites.numsprites-1]=4; - sprites.alivetime[sprites.numsprites-1]=.3; + Sprite::MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1); + Sprite::speed[Sprite::numsprites-1]=4; + Sprite::alivetime[Sprite::numsprites-1]=.3; shinepoint=tippoint[i]; - sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1); - sprites.speed[sprites.numsprites-1]=4; - sprites.alivetime[sprites.numsprites-1]=.3;*/ + Sprite::MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1); + Sprite::speed[Sprite::numsprites-1]=4; + Sprite::alivetime[Sprite::numsprites-1]=.3;*/ } } return 0;