X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FWeapons.cpp;h=d72534862a4c95cb96f71a97c90eb1eba5d0af59;hb=335d0ac4212924d916ae6b6978fc3f3c8b505497;hp=496e0fee431acf410cf0770bfc8e4d10386cd1b7;hpb=decb00e82a2e65e25dbcdd8f16fff5a6a07d31d6;p=lugaru.git diff --git a/Source/Weapons.cpp b/Source/Weapons.cpp index 496e0fe..d725348 100644 --- a/Source/Weapons.cpp +++ b/Source/Weapons.cpp @@ -22,15 +22,16 @@ 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" +#include "Game.h" +#include "Awards.h" extern float multiplier; -extern Animation animation[animation_count]; -extern OPENAL_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; @@ -50,13 +51,7 @@ extern float terraindetail; extern float viewdistance; extern float blackout; extern int difficulty; -extern Person player[maxplayers]; -extern int numplayers; extern bool freeze; -extern int bonus; -extern float bonusvalue; -extern float bonustotal; -extern float bonustime; extern int tutoriallevel; extern int numthrowkill; extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); @@ -90,18 +85,7 @@ void Weapons::DoStuff(){ oldowner[i]=owner[i]; } if(damage[i]>=2&&type[i]==staff&&owner[i]!=-1){ - float gLoc[3]; - float vel[3]; - gLoc[0]=tippoint[i].x; - gLoc[1]=tippoint[i].y; - gLoc[2]=tippoint[i].z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( staffbreaksound, samp[staffbreaksound], NULL, true); - OPENAL_3D_SetAttributes(channels[staffbreaksound], gLoc, vel); - OPENAL_SetVolume(channels[staffbreaksound], 256); - OPENAL_SetPaused(channels[staffbreaksound], false); + emit_sound_at(staffbreaksound, tippoint[i]); XYZ tempvel; XYZ speed; //speed=(tippoint[i]-oldtippoint[i])/multiplier/6; @@ -111,7 +95,7 @@ void Weapons::DoStuff(){ 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]; @@ -174,22 +158,11 @@ void Weapons::DoStuff(){ bigtilt2[i]=0; bigrotation[i]=0; - float gLoc[3]; - float vel[3]; - gLoc[0]=position[i].x; - gLoc[1]=position[i].y; - gLoc[2]=position[i].z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true); - OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel); - OPENAL_SetVolume(channels[knifesheathesound], 128); - OPENAL_SetPaused(channels[knifesheathesound], false); + emit_sound_at(knifesheathesound, position[i], 128.); 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; @@ -209,18 +182,7 @@ void Weapons::DoStuff(){ if((player[j].aitype!=attacktypecutoff||abs(Random()%6)==0||(player[j].targetanimation!=backhandspringanim&&player[j].targetanimation!=rollanim&&player[j].targetanimation!=flipanim&&Random()%2==0))&&!missed[i]){ bool caught=0; if((player[j].creature==wolftype&&Random()%3!=0&&player[j].weaponactive==-1&&(player[j].isIdle()||player[j].isRun()||player[j].targetanimation==walkanim))||(player[j].creature==rabbittype&&Random()%2==0&&player[j].aitype==attacktypecutoff&&player[j].weaponactive==-1)){ - float gLoc[3]; - float vel[3]; - gLoc[0]=player[j].coords.x; - gLoc[1]=player[j].coords.y; - gLoc[2]=player[j].coords.z; - vel[0]=player[j].velocity.x; - vel[1]=player[j].velocity.y; - vel[2]=player[j].velocity.z; - PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true); - OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel); - OPENAL_SetVolume(channels[knifedrawsound], 128); - OPENAL_SetPaused(channels[knifedrawsound], false); + emit_sound_at(knifedrawsound, player[j].coords, 128.); player[j].weaponactive=0; player[j].targetanimation=removeknifeanim; @@ -250,11 +212,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); @@ -267,29 +229,12 @@ void Weapons::DoStuff(){ blooddrip[i]=5; } - float gLoc[3]; - float vel[3]; - gLoc[0]=position[i].x; - gLoc[1]=position[i].y; - gLoc[2]=position[i].z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true); - 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; - bonustime=0; - bonusvalue=60; - } - else{ - bonus=Bullseyebonus; - bonustime=0; - bonusvalue=30; - } + emit_sound_at(fleshstabsound, position[i], 128.); + + if(animation[player[0].targetanimation].height==highheight) + award_bonus(0, ninja); + else + award_bonus(0, Bullseyebonus); } } else missed[i]=1; @@ -336,29 +281,18 @@ void Weapons::DoStuff(){ bigtilt2[i]=0; bigrotation[i]=0; - float gLoc[3]; - float vel[3]; - gLoc[0]=position[i].x; - gLoc[1]=position[i].y; - gLoc[2]=position[i].z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true); - OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel); - OPENAL_SetVolume(channels[knifesheathesound], 128); - OPENAL_SetPaused(channels[knifesheathesound], false); + emit_sound_at(knifesheathesound, position[i], 128.); XYZ terrainlight; terrainlight=terrain.getLighting(position[i].x,position[i].z); if(environment==snowyenvironment){ - if(findDistancefast(&position[i],&viewer)1){ - float gLoc[3]; - float vel[3]; - //int whichsound=clank1sound+abs(Random()%4); int whichsound; if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=position[i].x; - gLoc[1]=position[i].y; - gLoc[2]=position[i].z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( whichsound, samp[whichsound], NULL, true); - OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); - OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - OPENAL_SetPaused(channels[whichsound], false); + if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, position[i], 128*findLengthfast(&bounceness)); } } start=oldtippoint[i]; @@ -520,22 +443,10 @@ void Weapons::DoStuff(){ tipvelocity[i]+=bounceness*elasticity; if(findLengthfast(&bounceness)>1){ - float gLoc[3]; - float vel[3]; - //int whichsound=clank1sound+abs(Random()%4); int whichsound; if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=position[i].x; - gLoc[0]=position[i].x; - gLoc[1]=position[i].y; - gLoc[2]=position[i].z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( whichsound, samp[whichsound], NULL, true); - OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); - OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - OPENAL_SetPaused(channels[whichsound], false); + if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, position[i], 128*findLengthfast(&bounceness)); } } @@ -563,21 +474,10 @@ void Weapons::DoStuff(){ velocity[i]+=bounceness*elasticity; if(findLengthfast(&bounceness)>1){ - float gLoc[3]; - float vel[3]; - //int whichsound=clank1sound+abs(Random()%4); int whichsound; if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=mid.x; - gLoc[1]=mid.y; - gLoc[2]=mid.z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( whichsound, samp[whichsound], NULL, true); - OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); - OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - OPENAL_SetPaused(channels[whichsound], false); + if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, mid, 128*findLengthfast(&bounceness)); } position[i]+=(mid-oldmid2)*(20/(1+(float)m*10)); } @@ -604,21 +504,10 @@ void Weapons::DoStuff(){ tipvelocity[i]+=bounceness*elasticity; if(findLengthfast(&bounceness)>1){ - float gLoc[3]; - float vel[3]; - //int whichsound=clank1sound+abs(Random()%4); int whichsound; if(type[i]==staff)whichsound=footstepsound3+abs(Random()%2); - if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4);gLoc[0]=mid.x; - gLoc[1]=mid.y; - gLoc[2]=mid.z; - vel[0]=0; - vel[1]=0; - vel[2]=0; - PlaySoundEx( whichsound, samp[whichsound], NULL, true); - OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel); - OPENAL_SetVolume(channels[whichsound], 128*findLengthfast(&bounceness)); - OPENAL_SetPaused(channels[whichsound], false); + if(type[i]!=staff)whichsound=clank1sound+abs(Random()%4); + emit_sound_at(whichsound, mid, 128*findLengthfast(&bounceness)); } tippoint[i]+=(mid-oldmid2)*(20/(1+(float)m*10)); } @@ -711,13 +600,13 @@ void Weapons::DoStuff(){ XYZ terrainlight; terrainlight=terrain.getLighting(position[i].x,position[i].z); if(environment==snowyenvironment){ - if(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); } } } @@ -1271,13 +1160,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;