summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Game.h2
-rw-r--r--src/GameInitDispose.cpp72
-rw-r--r--src/GameTick.cpp1059
3 files changed, 544 insertions, 589 deletions
diff --git a/src/Game.h b/src/Game.h
index a8d093d..e652303 100644
--- a/src/Game.h
+++ b/src/Game.h
@@ -57,6 +57,8 @@ class Game {
 	void handleMenu(unsigned char*);
 	void handleToggles(unsigned char*);
 	void mouseLook();
+	XYZ fluidAim(int&);
+	void setListener(XYZ&);
 public:
 	// Event loop
 	Boolean	gQuit;
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index 8a56e73..b791183 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -226,113 +226,109 @@ void LoadSounds(bool musictoggle)
 		FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1);
 	}
 
-	float gLoc[3];
-	gLoc[0]=0;
-	gLoc[1]=0;
-	gLoc[2]=0;
-
-	alSourcefv(gSourceID[visionsound], AL_POSITION, gLoc);
+	alListenerfv(AL_POSITION, {});
+	alSourcefv(gSourceID[visionsound], AL_POSITION, {});
 	alSourcei(gSourceID[visionsound], AL_LOOPING, 1);
 	alSourcef(gSourceID[visionsound], AL_MIN_GAIN, 1);
-	alSourcefv(gSourceID[soulinsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[soulinsound], AL_POSITION, {});
 	alSourcei(gSourceID[soulinsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[soulinsound], AL_MIN_GAIN, 1);
-	alSourcefv(gSourceID[souloutsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[souloutsound], AL_POSITION, {});
 	alSourcei(gSourceID[souloutsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[souloutsound], AL_MIN_GAIN, 1);
 
 	for(int i=0;i<5;i++){
-		alSourcefv(gSourceID[footstepsound+i], AL_POSITION, gLoc);
+		alSourcefv(gSourceID[footstepsound+i], AL_POSITION, {});
 		alSourcei(gSourceID[footstepsound+i], AL_LOOPING, 0);
 		alSourcef(gSourceID[footstepsound+i], AL_MIN_GAIN, 0);
 	}
 
-	alSourcefv(gSourceID[bodylandsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[bodylandsound], AL_POSITION, {});
 	alSourcei(gSourceID[bodylandsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[bodylandsound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[headlandsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[headlandsound], AL_POSITION, {});
 	alSourcei(gSourceID[headlandsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[headlandsound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[riflesound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[riflesound], AL_POSITION, {});
 	alSourcei(gSourceID[riflesound], AL_LOOPING, 0);
 	alSourcef(gSourceID[riflesound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[bodyhitsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[bodyhitsound], AL_POSITION, {});
 	alSourcei(gSourceID[bodyhitsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, .1);
-	alSourcefv(gSourceID[wallhitsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[wallhitsound], AL_POSITION, {});
 	alSourcei(gSourceID[wallhitsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[wallhitsound], AL_MIN_GAIN, 0);
 	alSourcef(gSourceID[wallhitsound], AL_MAX_GAIN, .6);
-	alSourcefv(gSourceID[machinegunsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[machinegunsound], AL_POSITION, {});
 	alSourcei(gSourceID[machinegunsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[machinegunsound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[nearbulletsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[nearbulletsound], AL_POSITION, {});
 	alSourcei(gSourceID[nearbulletsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[nearbulletsound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[headwhacksound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[headwhacksound], AL_POSITION, {});
 	alSourcei(gSourceID[headwhacksound], AL_LOOPING, 0);
 	alSourcef(gSourceID[headwhacksound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[headshotsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[headshotsound], AL_POSITION, {});
 	alSourcei(gSourceID[headshotsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[headshotsound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[reloadsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[reloadsound], AL_POSITION, {});
 	alSourcei(gSourceID[reloadsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[reloadsound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[clicksound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[clicksound], AL_POSITION, {});
 	alSourcei(gSourceID[clicksound], AL_LOOPING, 0);
 	alSourcef(gSourceID[clicksound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[pistol1sound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[pistol1sound], AL_POSITION, {});
 	alSourcei(gSourceID[pistol1sound], AL_LOOPING, 0);
 	alSourcef(gSourceID[pistol1sound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[pistol2sound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[pistol2sound], AL_POSITION, {});
 	alSourcei(gSourceID[pistol2sound], AL_LOOPING, 0);
 	alSourcef(gSourceID[pistol2sound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[pinpullsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[pinpullsound], AL_POSITION, {});
 	alSourcei(gSourceID[pinpullsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[pinpullsound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[pinreplacesound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[pinreplacesound], AL_POSITION, {});
 	alSourcei(gSourceID[pinreplacesound], AL_LOOPING, 0);
 	alSourcef(gSourceID[pinreplacesound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[grenadethrowsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[grenadethrowsound], AL_POSITION, {});
 	alSourcei(gSourceID[grenadethrowsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[grenadethrowsound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[bouncesound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[bouncesound], AL_POSITION, {});
 	alSourcei(gSourceID[bouncesound], AL_LOOPING, 0);
 	alSourcef(gSourceID[bouncesound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[bounce2sound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[bounce2sound], AL_POSITION, {});
 	alSourcei(gSourceID[bounce2sound], AL_LOOPING, 0);
 	alSourcef(gSourceID[bounce2sound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[explosionsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[explosionsound], AL_POSITION, {});
 	alSourcei(gSourceID[explosionsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[explosionsound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[bodywhacksound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[bodywhacksound], AL_POSITION, {});
 	alSourcei(gSourceID[bodywhacksound], AL_LOOPING, 0);
 	alSourcef(gSourceID[bodywhacksound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[rainsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[rainsound], AL_POSITION, {});
 	alSourcei(gSourceID[rainsound], AL_LOOPING, 1);
 	alSourcef(gSourceID[rainsound], AL_MIN_GAIN, .3);
-	alSourcefv(gSourceID[losesound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[losesound], AL_POSITION, {});
 	alSourcei(gSourceID[losesound], AL_LOOPING, 0);
 	alSourcef(gSourceID[losesound], AL_MIN_GAIN, 1);
-	alSourcefv(gSourceID[disguisekillsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[disguisekillsound], AL_POSITION, {});
 	alSourcei(gSourceID[disguisekillsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[disguisekillsound], AL_MIN_GAIN, 1);
-	alSourcefv(gSourceID[knifeslashsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[knifeslashsound], AL_POSITION, {});
 	alSourcei(gSourceID[knifeslashsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[knifeslashsound], AL_MIN_GAIN,0);
-	alSourcefv(gSourceID[shotgunsound], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[shotgunsound], AL_POSITION, {});
 	alSourcei(gSourceID[shotgunsound], AL_LOOPING, 0);
 	alSourcef(gSourceID[shotgunsound], AL_MIN_GAIN, 0);
-	alSourcefv(gSourceID[knifesong], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[knifesong], AL_POSITION, {});
 	alSourcei(gSourceID[knifesong], AL_LOOPING, 1);
 	alSourcef(gSourceID[knifesong], AL_MIN_GAIN, 1);
-	alSourcefv(gSourceID[mainmenusong], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[mainmenusong], AL_POSITION, {});
 	alSourcei(gSourceID[mainmenusong], AL_LOOPING, 1);
 	alSourcef(gSourceID[mainmenusong], AL_MIN_GAIN, 1);
-	alSourcefv(gSourceID[zombiesong], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[zombiesong], AL_POSITION, {});
 	alSourcei(gSourceID[zombiesong], AL_LOOPING, 1);
 	alSourcef(gSourceID[zombiesong], AL_MIN_GAIN, 1);
-	alSourcefv(gSourceID[shootsong], AL_POSITION, gLoc);
+	alSourcefv(gSourceID[shootsong], AL_POSITION, {});
 	alSourcei(gSourceID[shootsong], AL_LOOPING, 1);
 	alSourcef(gSourceID[shootsong], AL_MIN_GAIN, 1);
 }
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index d8c8801..ccf1a5c 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -3,6 +3,7 @@
 // Copyright (C) 2003  Dan Olson
 // Copyright (C) 2003  Steven Fuller
 // Copyright (C) 2003  Zachary Jack Slater
+// Copyright (C) 2003  Toby Haynes
 // Copyright (C) 2021  Nguyễn Gia Phong
 //
 // This file is part of Black Shades.
@@ -49,34 +50,36 @@ extern Decals decals;
 
 #define maxfallvel 40
 
-void Game::Splat(int k){
-	if(k!=0||visions==0){
-		person[k].health=0;
-		person[k].DoAnimations(k);
-		person[k].skeleton.offset=0;
-		person[k].skeleton.free=1;
-		person[k].longdead=1;
-		person[k].bleeding=1;
-		person[k].bleeddelay=1;
-		person[k].bjoint1=&person[k].skeleton.joints[person[k].skeleton.jointlabels[head]];
-		person[k].bjoint2=&person[k].skeleton.joints[person[k].skeleton.jointlabels[neck]];
-
-		for(int j=0;j<person[k].skeleton.num_joints;j++){
-			person[k].skeleton.joints[j].position+=person[k].skeleton.joints[j].offset;
-			person[k].skeleton.joints[j].position=DoRotation(person[k].skeleton.joints[j].position,0,person[k].playerrotation,0);
-			person[k].skeleton.joints[j].position+=person[k].playercoords;
-			person[k].skeleton.joints[j].realoldposition=person[k].skeleton.joints[j].position;
-			person[k].skeleton.joints[j].velocity=0;
-			person[k].skeleton.joints[j].velocity.y+=person[k].velocity.y;
-		}
+void Game::Splat(int k)
+{
+	if (k && visions)
+		return;
 
-		float gLoc[3];
-		gLoc[0]=person[k].skeleton.joints[person[k].skeleton.jointlabels[head]].position.x/soundscalefactor;
-		gLoc[1]=person[k].skeleton.joints[person[k].skeleton.jointlabels[head]].position.y/soundscalefactor;
-		gLoc[2]=person[k].skeleton.joints[person[k].skeleton.jointlabels[head]].position.z/soundscalefactor;
-		alSourcefv(gSourceID[headwhacksound], AL_POSITION, gLoc);
-		alSourcePlay(gSourceID[headwhacksound]);
+	auto& skeleton = person[k].skeleton;
+	skeleton.free = 1;
+	skeleton.offset = person[k].health = 0;
+	person[k].longdead = person[k].bleeding = person[k].bleeddelay = 1;
+	person[k].DoAnimations(k);
+
+	auto& joints = skeleton.joints;
+	auto& head_joint = joints[skeleton.jointlabels[head]];
+	person[k].bjoint1 = &head_joint;
+	person[k].bjoint2 = joints + skeleton.jointlabels[neck];
+
+	for (auto& joint : joints) {
+		joint.position = DoRotation(joint.position + joint.offset, 0,
+			person[k].playerrotation, 0) + person[k].playercoords;
+		joint.realoldposition = joint.position;
+		joint.velocity = {0, person[k].velocity.y, 0};
 	}
+
+	ALfloat gLoc[] {
+		(head_joint.position.x - camera.position.x) / soundscalefactor,
+		(head_joint.position.y - camera.position.x) / soundscalefactor,
+		(head_joint.position.z - camera.position.x) / soundscalefactor,
+	};
+	alSourcefv(gSourceID[headwhacksound], AL_POSITION, gLoc);
+	alSourcePlay(gSourceID[headwhacksound]);
 }
 
 void Game::saveHighScore()
@@ -84,7 +87,7 @@ void Game::saveHighScore()
 	if (score > highscore) {
 		highscore = score;
 		/* TODO */
-		ofstream opstream("Data/Highscore");
+		ofstream opstream("highscore.txt");
 		opstream << highscore;
 		opstream << "\n";
 		opstream << beatgame;
@@ -308,10 +311,79 @@ void Game::mouseLook()
 			max(camera.rotation2 - 15, camera.visrotation2));
 	}
 
+	person[0].playerrotation = 180 - camera.rotation;
 	camera.oldrotation = camera.rotation;
 	camera.oldrotation2 = camera.rotation2;
 }
 
+void Game::setListener(XYZ& facing)
+{
+	XYZ upvector {0, 0, -1};
+	upvector = DoRotation(upvector, -camera.rotation2 + 90, 0, 0);
+	upvector = DoRotation(upvector, 0, -camera.rotation, 0);
+
+	ALfloat ori[] {
+		facing.x, facing.y, facing.z,
+		-upvector.x, upvector.y, upvector.z,
+	};
+	alListenerfv(AL_ORIENTATION, ori);
+}
+
+XYZ Game::fluidAim(int& j)
+{
+	auto& joints = person[j].skeleton.joints;
+	auto& jointlabels = person[j].skeleton.jointlabels;
+	auto point = joints[jointlabels[lefthand]].position
+		- joints[jointlabels[righthand]].position;
+	float aimrot = 0.0f, aimrot2 = 0.0f;
+	switch (person[j].whichgun) {
+		case assaultrifle:
+			aimrot = -2.5f;
+			break;
+		case sniperrifle:
+			aimrot = 4.0f;
+			break;
+		case shotgun:
+			aimrot = Random() % 1000 / 500.0f - 1;
+			aimrot2 = Random() % 1000 / 500.0f + 2;
+			break;
+		case handgun1:
+		case handgun2:
+			aimrot = -0.9f;
+			point = joints[jointlabels[righthand]].position
+				- joints[jointlabels[head]].position * 0.35f
+				- joints[jointlabels[neck]].position * 0.65f;
+		break;
+	}
+	XYZ aim = DoRotation(point, aimrot2,
+		person[j].playerrotation + aimrot, 0);
+
+	if(j!=0&&person[person[j].killtarget].skeleton.free==0)aim=(DoRotation(person[person[j].killtarget].skeleton.joints[person[person[j].killtarget].skeleton.jointlabels[abdomen]].position,0,person[person[j].killtarget].playerrotation,0)+person[person[j].killtarget].playercoords)-(DoRotation(person[j].skeleton.joints[person[j].skeleton.jointlabels[lefthand]].position,0,person[j].playerrotation,0)+person[j].playercoords);
+
+	if(j!=0&&person[person[j].killtarget].skeleton.free!=0)aim=person[person[j].killtarget].skeleton.joints[person[person[j].killtarget].skeleton.jointlabels[abdomen]].position-(DoRotation(person[j].skeleton.joints[person[j].skeleton.jointlabels[lefthand]].position,0,person[j].playerrotation,0)+person[j].playercoords);
+
+	float inaccuracy = 0.0f;
+	switch (person[j].whichgun) {
+	case handgun1:
+	case handgun2:
+		inaccuracy = 8.0f;
+		break;
+	case assaultrifle:
+	case shotgun:
+		inaccuracy = 6.0f;
+		break;
+	case sniperrifle:
+		inaccuracy = 2.0f;
+		break;
+	}
+	if (person[person[j].killtarget].skeleton.free == 1)
+		inaccuracy *= 3;
+	if(j!=0)aim=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),(float)(abs(Random()%2000))/2000*inaccuracy-inaccuracy/2,(float)(abs(Random()%2000))/2000*inaccuracy-inaccuracy/2,0),0,person[j].playerrotation,0);
+
+	Normalise(&aim);
+	return std::move(aim);
+}
+
 void Game::Tick()
 {
 	unsigned char theKeyMap[16];
@@ -321,9 +393,6 @@ void Game::Tick()
 		return;
 	}
 
-	XYZ facing;
-	XYZ flatfacing;
-
 	if (person[1].health <= 0 || person[0].health <= 0 || killedinnocent)
 		losedelay -= multiplier / 6;
 	else
@@ -373,12 +442,11 @@ void Game::Tick()
 	decals.DoStuff();
 
 	// Facing
-	facing = 0;
-	facing.z = -1;
+	XYZ facing {0, 0, -1};
 	facing = DoRotation(facing, -camera.rotation2, 0, 0);
-	facing = DoRotation(facing, 0, 0 - camera.rotation, 0);
+	facing = DoRotation(facing, 0, -camera.rotation, 0);
 
-	flatfacing = facing;
+	XYZ flatfacing = facing;
 	flatfacing.y = 0;
 	Normalise(&flatfacing);
 
@@ -386,9 +454,7 @@ void Game::Tick()
 	mouseLook();
 
 	//Check collision with buildings
-
 	int beginx,endx;
-
 	int beginz,endz;
 
 	XYZ collpoint;
@@ -409,8 +475,6 @@ void Game::Tick()
 
 	bool inblock;
 
-	person[0].playerrotation=180-camera.rotation;
-
 	//Check people collisions
 
 	for(int k=0;k<numpeople;k++){
@@ -1936,16 +2000,10 @@ void Game::Tick()
 			                        + flatfacing) > 22)
 				continue;
 
-			float gLoc[3] {
-				(camera.position.x
-				 + person[0].playercoords.x
-				 + flatfacing.x) / soundscalefactor / 2,
-				(camera.position.y
-				 + person[0].playercoords.y
-				 + flatfacing.y) / soundscalefactor / 2,
-				(camera.position.z
-				 + person[0].playercoords.z
-				 + flatfacing.z) / soundscalefactor / 2,
+			float gLoc[] {
+				flatfacing.x / soundscalefactor,
+				flatfacing.y / soundscalefactor,
+				flatfacing.z / soundscalefactor,
 			};
 
 			alSourcefv(gSourceID[headwhacksound],
@@ -1998,14 +2056,13 @@ void Game::Tick()
 	XYZ wallhit;
 	XYZ start;
 	XYZ finalwallhit;
-	float inaccuracy = 0.0;
 	int numshots;
 	XYZ hitnorm;
 	XYZ hitmove;
 	int hitpoly = 0;
 	float hitrotation = 0.0f;
 	Model* model = NULL;
-
+ 
 	for (int j = 0; j < numpeople; j++) {
 		if (j && person[j].type != eviltype)
 			continue;
@@ -2041,286 +2098,215 @@ void Game::Tick()
 			person[j].aiming = 0;
 		}
 
-		if (firing) {
-			if(person[j].whichgun==handgun1||person[j].whichgun==handgun2)inaccuracy=8;
-
-			if(person[j].whichgun==assaultrifle)inaccuracy=6;
-
-			if(person[j].whichgun==sniperrifle)inaccuracy=2;
-
-			if(person[j].whichgun==shotgun)inaccuracy=6;
-
-			if(person[person[j].killtarget].skeleton.free==1)inaccuracy*=3;
-
-			person[j].shotdelay=shotdelayamount/difficulty;
-
-			if(person[j].aiming>=1&&person[j].recoil<=0){
-
-				//Firing
-
-				person[j].litup=1;
-
-				person[j].recoil=1;
-
-				XYZ end, aim, oldend;
-
-				HitStruct hitstruct,temphitstruct;
-
-				float olddistance = 0.0f;
-
-				float distance = 0.0f;
-
-				float totalarea = 0.0f;
-
-				int whichhit=-1;
+		if (!firing || person[j].aiming < 1 || person[j].recoil > 0)
+			continue;
+		person[j].shotdelay = shotdelayamount / difficulty;
 
-				if(person[j].whichgun==shotgun)numshots=7;
+		HitStruct hitstruct, temphitstruct;
+		person[j].litup = person[j].recoil = 1;
 
-				if(person[j].whichgun!=shotgun)numshots=1;
+		float olddistance = 0.0f, distance = 0.0f;
+		float totalarea = 0.0f;
+		int whichhit = -1;
 
-				if(person[j].whichgun!=grenade)person[j].ammo--;
+		numshots = (person[j].whichgun == shotgun) ? 7 : 1;
+		if (person[j].whichgun != grenade)
+			person[j].ammo--;
 
-				for(int p=0;p<numshots;p++){
+		for (int p = 0; p < numshots; p++) {
+			XYZ aim = (zoom && j == 0) ? facing : fluidAim(j);
+			if(person[j].whichgun==sniperrifle){
 
-				if(!zoom||j!=0){
+				start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position,0,person[j].playerrotation,0);
 
-					if(person[j].whichgun==assaultrifle)aim=DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position-person[j].skeleton.joints[(person[j].skeleton.jointlabels[righthand])].position,0,person[j].playerrotation-2.5,0);
+				float gLoc[3];
 
-					if(person[j].whichgun==sniperrifle)aim=DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position-person[j].skeleton.joints[(person[j].skeleton.jointlabels[righthand])].position,0,person[j].playerrotation+4,0);
+				start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.35;
 
-					if(person[j].whichgun==shotgun)aim=DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position-person[j].skeleton.joints[(person[j].skeleton.jointlabels[righthand])].position,2+(float)(Random()%1000)/500,0,0);
+				gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
 
-					if(person[j].whichgun==shotgun)aim=DoRotation(aim,0,person[j].playerrotation-1+(float)(Random()%1000)/500,0);
+				gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
 
-					if(person[j].whichgun==handgun1&&!thirdperson&&j==0)aim=DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[righthand])].position-(person[j].skeleton.joints[person[j].skeleton.jointlabels[head]].position*.65+person[j].skeleton.joints[person[j].skeleton.jointlabels[neck]].position*.35),0,person[j].playerrotation-.9,0);
+				gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
 
-					if(person[j].whichgun==handgun1&&(thirdperson||j!=0))aim=DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[righthand])].position-(person[j].skeleton.joints[person[j].skeleton.jointlabels[head]].position*.35+person[j].skeleton.joints[person[j].skeleton.jointlabels[neck]].position*.65),0,person[j].playerrotation-.9,0);
+				alSourcefv(gSourceID[riflesound], AL_POSITION, gLoc);
 
-					if(person[j].whichgun==handgun2&&!thirdperson&&j==0)aim=DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[righthand])].position-(person[j].skeleton.joints[person[j].skeleton.jointlabels[head]].position*.65+person[j].skeleton.joints[person[j].skeleton.jointlabels[neck]].position*.35),0,person[j].playerrotation-.9,0);
+				alSourcePlay(gSourceID[riflesound]);
 
-					if(person[j].whichgun==handgun2&&(thirdperson||j!=0))aim=DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[righthand])].position-(person[j].skeleton.joints[person[j].skeleton.jointlabels[head]].position*.35+person[j].skeleton.joints[person[j].skeleton.jointlabels[neck]].position*.65),0,person[j].playerrotation-.9,0);
-
-					if(j!=0&&person[person[j].killtarget].skeleton.free==0)aim=(DoRotation(person[person[j].killtarget].skeleton.joints[person[person[j].killtarget].skeleton.jointlabels[abdomen]].position,0,person[person[j].killtarget].playerrotation,0)+person[person[j].killtarget].playercoords)-(DoRotation(person[j].skeleton.joints[person[j].skeleton.jointlabels[lefthand]].position,0,person[j].playerrotation,0)+person[j].playercoords);
+				if(j==0){
 
-					if(j!=0&&person[person[j].killtarget].skeleton.free!=0)aim=person[person[j].killtarget].skeleton.joints[person[person[j].killtarget].skeleton.jointlabels[abdomen]].position-(DoRotation(person[j].skeleton.joints[person[j].skeleton.jointlabels[lefthand]].position,0,person[j].playerrotation,0)+person[j].playercoords);
+					if(person[j].currentanimation!=crouchanim)camera.rotation2-=7;
 
-					if(j!=0)aim=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),(float)(abs(Random()%2000))/2000*inaccuracy-inaccuracy/2,(float)(abs(Random()%2000))/2000*inaccuracy-inaccuracy/2,0),0,person[j].playerrotation,0);
+					if(person[j].currentanimation==crouchanim)camera.rotation2-=3;
 
 				}
 
-				if(zoom&&j==0){
-
-					start=camera.position;
-
-					aim=facing;
-
-				}
-
-				Normalise(&aim);
+			}
 
-				if(person[j].whichgun==sniperrifle){
+			if(person[j].whichgun==shotgun){
 
-					start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position,0,person[j].playerrotation,0);
+				start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position,0,person[j].playerrotation,0);
 
-					float gLoc[3];
+				float gLoc[3];
 
-					start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.35;
+				start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.35;
 
-					gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
+				if(p==numshots-1){
 
-					gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
+				gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
 
-					gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
+				gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
 
-					alSourcefv(gSourceID[riflesound], AL_POSITION, gLoc);
+				gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
 
-					alSourcePlay(gSourceID[riflesound]);
+				alSourcefv(gSourceID[shotgunsound], AL_POSITION, gLoc);
 
-					if(j==0){
+				alSourcePlay(gSourceID[shotgunsound]);
 
-						if(person[j].currentanimation!=crouchanim)camera.rotation2-=7;
+				if(j==0){
 
-						if(person[j].currentanimation==crouchanim)camera.rotation2-=3;
+					if(person[j].currentanimation!=crouchanim)camera.rotation2-=7;
 
-					}
+					if(person[j].currentanimation==crouchanim)camera.rotation2-=3;
 
 				}
 
-				if(person[j].whichgun==shotgun){
-
-					start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position,0,person[j].playerrotation,0);
-
-					float gLoc[3];
-
-					start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.35;
-
-					if(p==numshots-1){
-
-					gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
-
-					gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
-
-					gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
-
-					alSourcefv(gSourceID[shotgunsound], AL_POSITION, gLoc);
-
-					alSourcePlay(gSourceID[shotgunsound]);
-
-					if(j==0){
-
-						if(person[j].currentanimation!=crouchanim)camera.rotation2-=7;
-
-						if(person[j].currentanimation==crouchanim)camera.rotation2-=3;
-
-					}
-
-					}
-
 				}
 
-				if(person[j].whichgun==handgun1){
+			}
 
-					start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[rightwrist])].position,0,person[j].playerrotation,0);
+			if(person[j].whichgun==handgun1){
 
-					start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.55;
+				start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[rightwrist])].position,0,person[j].playerrotation,0);
 
-					float gLoc[3];
+				start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.55;
 
-					gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
+				float gLoc[3];
 
-					gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
+				gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
 
-					gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
+				gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
 
-					alSourcefv(gSourceID[pistol1sound], AL_POSITION, gLoc);
+				gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
 
-					alSourcePlay(gSourceID[pistol1sound]);
+				alSourcefv(gSourceID[pistol1sound], AL_POSITION, gLoc);
 
-					if(j==0){
+				alSourcePlay(gSourceID[pistol1sound]);
 
-						if(person[j].currentanimation!=crouchanim)camera.rotation2-=6;
+				if(j==0){
 
-						if(person[j].currentanimation==crouchanim)camera.rotation2-=4;
+					if(person[j].currentanimation!=crouchanim)camera.rotation2-=6;
 
-					}
+					if(person[j].currentanimation==crouchanim)camera.rotation2-=4;
 
 				}
 
-				if(person[j].whichgun==handgun2){
+			}
 
-					start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[rightwrist])].position,0,person[j].playerrotation,0);
+			if(person[j].whichgun==handgun2){
 
-					start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.55;
+				start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[rightwrist])].position,0,person[j].playerrotation,0);
 
-					float gLoc[3];
+				start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.55;
 
-					gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
+				float gLoc[3];
 
-					gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
+				gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
 
-					gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
+				gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
 
-					alSourcefv(gSourceID[pistol2sound], AL_POSITION, gLoc);
+				gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
 
-					alSourcePlay(gSourceID[pistol2sound]);
+				alSourcefv(gSourceID[pistol2sound], AL_POSITION, gLoc);
 
-					if(j==0){
+				alSourcePlay(gSourceID[pistol2sound]);
 
-						if(person[j].currentanimation!=crouchanim)camera.rotation2-=5;
+				if(j==0){
 
-						if(person[j].currentanimation==crouchanim)camera.rotation2-=3;
+					if(person[j].currentanimation!=crouchanim)camera.rotation2-=5;
 
-					}
+					if(person[j].currentanimation==crouchanim)camera.rotation2-=3;
 
 				}
 
-				if(person[j].whichgun==assaultrifle){
-
-					start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position,0,person[j].playerrotation,0);
-
-					start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.25;
-
-					float gLoc[3];
-
-					gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
-
-					gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
+			}
 
-					gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
+			if(person[j].whichgun==assaultrifle){
+				start=person[j].playercoords+DoRotation(person[j].skeleton.joints[(person[j].skeleton.jointlabels[lefthand])].position,0,person[j].playerrotation,0);
 
-					alSourcefv(gSourceID[machinegunsound], AL_POSITION, gLoc);
+				start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.25;
 
-					alSourcePlay(gSourceID[machinegunsound]);
+				float gLoc[3];
 
-					if(j==0){
+				gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor;
 
-						if(person[j].currentanimation!=crouchanim){
+				gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor;
 
-							camera.rotation2-=2.3;
+				gLoc[2]=(camera.position.z+(start.z-camera.position.z)/4)/soundscalefactor;
 
-							camera.rotation+=(float)(Random()%100)/50;
+				alSourcefv(gSourceID[machinegunsound], AL_POSITION, gLoc);
 
-						}
+				alSourcePlay(gSourceID[machinegunsound]);
 
-						if(person[j].currentanimation==crouchanim){
+				if(j==0){
 
-							camera.rotation2-=1.5;
+					if(person[j].currentanimation!=crouchanim){
 
-							camera.rotation+=(float)(Random()%100)/60;
+						camera.rotation2-=2.3;
 
-						}
+						camera.rotation+=(float)(Random()%100)/50;
 
 					}
 
-				}
+					if(person[j].currentanimation==crouchanim){
 
-				end=start+aim*1000;
-
-				if(debug){
+						camera.rotation2-=1.5;
 
-				if(IsKeyDown(theKeyMap, MAC_G_KEY)&&j==0){
+						camera.rotation+=(float)(Random()%100)/60;
 
-					sprites.MakeSprite(grenadesprite, 1, 1, 1, 1, start, aim*200, 1.01);
-
-				}
+					}
 
 				}
 
-				if(!IsKeyDown(theKeyMap, MAC_G_KEY)||j!=0||!debug){
-
-				int bulletstrength=1;
-
-				int firstpass=-1;
+			}
 
-				bool penetrate;
+			XYZ end {start + aim * 1000};
+			if (debug && j == 0
+			    && IsKeyDown(theKeyMap, MAC_G_KEY)) {
+				sprites.MakeSprite(grenadesprite, 1, 1, 1, 1,
+					start, aim * 200, 1.01);
+				continue;
+			}
 
-				for(int m=0;m<bulletstrength;m++){
+			int bulletstrength=1;
+			int firstpass=-1;
+			bool penetrate;
 
-					//People
+			for(int m=0;m<bulletstrength;m++){
 
-					whichhit=-1;
+				//People
 
-					for(int i=0;i<numpeople;i++){
+				whichhit=-1;
 
-						if(i!=j&&i!=firstpass&&person[i].existing){
+				for(int i=0;i<numpeople;i++){
 
-							temphitstruct=person[i].BulletCollideWithPlayer(i, start, end);
+					if(i!=j&&i!=firstpass&&person[i].existing){
 
-							if(temphitstruct.collision){
+						temphitstruct=person[i].BulletCollideWithPlayer(i, start, end);
 
-								distance=findDistancefast(start,temphitstruct.hitlocation);
+						if(temphitstruct.collision){
 
-								if(distance<olddistance||whichhit==-1){
+							distance=findDistancefast(start,temphitstruct.hitlocation);
 
-									end=temphitstruct.hitlocation;
+							if(distance<olddistance||whichhit==-1){
 
-									olddistance=distance;
+								end=temphitstruct.hitlocation;
 
-									hitstruct=temphitstruct;
+								olddistance=distance;
 
-									whichhit=i;
+								hitstruct=temphitstruct;
 
-								}
+								whichhit=i;
 
 							}
 
@@ -2328,387 +2314,387 @@ void Game::Tick()
 
 					}
 
-					//Blocks
+				}
 
-					wallhit=0;
+				//Blocks
 
-					beginx=(person[j].playercoords.x+block_spacing/2)/block_spacing-3;
+				wallhit=0;
 
-					if(beginx<0)beginx=0;
+				beginx=(person[j].playercoords.x+block_spacing/2)/block_spacing-3;
 
-					beginz=(person[j].playercoords.z+block_spacing/2)/block_spacing-3;
+				if(beginx<0)beginx=0;
 
-					if(beginz<0)beginz=0;
+				beginz=(person[j].playercoords.z+block_spacing/2)/block_spacing-3;
 
-					endx=(person[j].playercoords.x+block_spacing/2)/block_spacing+3;
+				if(beginz<0)beginz=0;
 
-					if(endx>num_blocks-1)endx=num_blocks-1;
+				endx=(person[j].playercoords.x+block_spacing/2)/block_spacing+3;
 
-					endz=(person[j].playercoords.z+block_spacing/2)/block_spacing+3;
+				if(endx>num_blocks-1)endx=num_blocks-1;
 
-					if(endz>num_blocks-1)endz=num_blocks-1;
+				endz=(person[j].playercoords.z+block_spacing/2)/block_spacing+3;
 
-					if(beginx<endx&&beginz<endz)
+				if(endz>num_blocks-1)endz=num_blocks-1;
 
-					finalwallhit=0;
+				if(beginx<endx&&beginz<endz)
 
-					for(int i=beginx;i<=endx;i++)
+				finalwallhit=0;
 
-						for(int j=beginz;j<=endz;j++){
+				for(int i=beginx;i<=endx;i++)
 
-							move=0;
+					for(int j=beginz;j<=endz;j++){
 
-							move.x=i*block_spacing;
+						move=0;
 
-							move.z=j*block_spacing;
+						move.x=i*block_spacing;
 
-							whichtri=blocks[citytype[i][j]].LineCheck2(start,end,&wallhit,move,cityrotation[i][j]*90);
+						move.z=j*block_spacing;
 
-							if(whichtri!=-1){
+						whichtri=blocks[citytype[i][j]].LineCheck2(start,end,&wallhit,move,cityrotation[i][j]*90);
 
-								whichhit=-1;
+						if(whichtri!=-1){
 
-								end=wallhit;
+							whichhit=-1;
 
-								finalwallhit=wallhit;
+							end=wallhit;
 
-								hitnorm=DoRotation(blocks[citytype[i][j]].normals[whichtri],0,cityrotation[i][j]*90,0);
+							finalwallhit=wallhit;
 
-								hitmove=move;
+							hitnorm=DoRotation(blocks[citytype[i][j]].normals[whichtri],0,cityrotation[i][j]*90,0);
 
-								hitrotation=cityrotation[i][j]*90;
+							hitmove=move;
 
-								hitpoly=whichtri;
+							hitrotation=cityrotation[i][j]*90;
 
-								model=&blocks[citytype[i][j]];
+							hitpoly=whichtri;
 
-								if(j==0&&blocks[citytype[i][j]].normals[whichtri].y>.9)bulletstrength=2;
+							model=&blocks[citytype[i][j]];
 
-							}
+							if(j==0&&blocks[citytype[i][j]].normals[whichtri].y>.9)bulletstrength=2;
 
 						}
 
-					wallhit=0;
+					}
 
-					wallhit.x=camera.position.x;
+				wallhit=0;
 
-					wallhit.z=camera.position.z;
+				wallhit.x=camera.position.x;
 
-					whichtri=Bigstreet.LineCheck2(start,end,&wallhit,wallhit,0);
+				wallhit.z=camera.position.z;
 
-					if(whichtri!=-1){
+				whichtri=Bigstreet.LineCheck2(start,end,&wallhit,wallhit,0);
 
-						end.y-=.5;
+				if(whichtri!=-1){
 
-						end=wallhit;
+					end.y-=.5;
 
-						finalwallhit=wallhit;
+					end=wallhit;
 
-						bulletstrength=2;
+					finalwallhit=wallhit;
 
-						hitnorm=0;
+					bulletstrength=2;
 
-						hitnorm.y=1;
+					hitnorm=0;
 
-						hitmove=0;
+					hitnorm.y=1;
 
-						hitrotation=0;
+					hitmove=0;
 
-					}
+					hitrotation=0;
 
-					if(m==0){
+				}
 
-						if(j==0&&slomo==2){
+				if(m==0){
 
-							soundscalefactor=soundscalefactordefault;
+					if(j==0&&slomo==2){
 
-							alSourceStop(gSourceID[whichsong]);
+						soundscalefactor=soundscalefactordefault;
 
-							alSourcef(gSourceID[whichsong], AL_MIN_GAIN, 0);
+						alSourceStop(gSourceID[whichsong]);
 
-							alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 0);
+						alSourcef(gSourceID[whichsong], AL_MIN_GAIN, 0);
 
-							if(person[0].whichgun==knife)whichsong=knifesong;
+						alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 0);
 
-							if(person[0].whichgun!=knife)whichsong=shootsong;
+						if(person[0].whichgun==knife)whichsong=knifesong;
 
-							if(type==zombie_type)whichsong=zombiesong;
+						if(person[0].whichgun!=knife)whichsong=shootsong;
 
-							alSourcef(gSourceID[whichsong], AL_PITCH, 1);
+						if(type==zombie_type)whichsong=zombiesong;
 
-							alSourcePlay(gSourceID[whichsong]);
+						alSourcef(gSourceID[whichsong], AL_PITCH, 1);
 
-							alSourcef(gSourceID[whichsong], AL_MIN_GAIN, 1);
+						alSourcePlay(gSourceID[whichsong]);
 
-							alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 1);
+						alSourcef(gSourceID[whichsong], AL_MIN_GAIN, 1);
 
-							slomo=0;
+						alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 1);
 
-							if(whichhit==-1)alSourcePlay(gSourceID[disguisekillsound]);
+						slomo=0;
 
-							flashamount=.5;
+						if(whichhit==-1)alSourcePlay(gSourceID[disguisekillsound]);
 
-							flashr=1;flashg=1;flashb=1;
+						flashamount=.5;
 
-						}
+						flashr=1;flashg=1;flashb=1;
 
 					}
 
-					//Impact
+				}
 
-					oldend=end;
+				//Impact
 
-					//with person
+				XYZ oldend {end};
 
-					if(whichhit!=-1&&whichhit!=firstpass){
+				//with person
 
-						if(j==0)person[whichhit].dead=1;
+				if(whichhit!=-1&&whichhit!=firstpass){
 
-						if(whichhit==1){
+					if(j==0)person[whichhit].dead=1;
 
-							murderer=j;
+					if(whichhit==1){
 
-						}
+						murderer=j;
 
-						if(person[whichhit].health==100&&j==0){
+					}
 
-							if(person[whichhit].type==civiliantype)civkills++;
+					if(person[whichhit].health==100&&j==0){
 
-							if(person[whichhit].type==eviltype)goodkills++;
+						if(person[whichhit].type==civiliantype)civkills++;
 
-						}
+						if(person[whichhit].type==eviltype)goodkills++;
 
-						if(person[whichhit].health==100&&j!=0){
+					}
 
-							badkills++;
+					if(person[whichhit].health==100&&j!=0){
 
-						}
+						badkills++;
 
-						//penetrate
+					}
 
-							penetrate=abs(Random()%2)==1;
+					//penetrate
 
-							if(numshots>1)penetrate=0;
+						penetrate=abs(Random()%2)==1;
 
-							if(penetrate){bulletstrength=2;
+						if(numshots>1)penetrate=0;
 
-							firstpass=whichhit;
+						if(penetrate){bulletstrength=2;
 
-							end=start+aim*1000;}
+						firstpass=whichhit;
 
-						if(person[j].whichgun==assaultrifle)person[whichhit].health-=20;
+						end=start+aim*1000;}
 
-						if(person[j].whichgun==assaultrifle&&person[whichhit].type==zombietype)person[whichhit].health-=60;
+					if(person[j].whichgun==assaultrifle)person[whichhit].health-=20;
 
-						if(person[j].whichgun==handgun1){
+					if(person[j].whichgun==assaultrifle&&person[whichhit].type==zombietype)person[whichhit].health-=60;
 
-							if(person[whichhit].type!=zombietype)person[whichhit].health-=100;
+					if(person[j].whichgun==handgun1){
 
-							if(person[whichhit].type==zombietype)person[whichhit].health-=100;
+						if(person[whichhit].type!=zombietype)person[whichhit].health-=100;
 
-							person[whichhit].DoAnimations(whichhit);
+						if(person[whichhit].type==zombietype)person[whichhit].health-=100;
 
-						}
+						person[whichhit].DoAnimations(whichhit);
 
-						if(person[j].whichgun==handgun2)person[whichhit].health-=20;
+					}
 
-						if(person[j].whichgun==handgun2&&person[whichhit].type==zombietype)person[whichhit].health-=60;
+					if(person[j].whichgun==handgun2)person[whichhit].health-=20;
 
-						if(person[j].whichgun==sniperrifle&&m!=0)person[whichhit].health-=30;
+					if(person[j].whichgun==handgun2&&person[whichhit].type==zombietype)person[whichhit].health-=60;
 
-						if(person[j].whichgun==shotgun)person[whichhit].health-=60;
+					if(person[j].whichgun==sniperrifle&&m!=0)person[whichhit].health-=30;
 
-						if(person[j].whichgun==sniperrifle&&m==0){
+					if(person[j].whichgun==shotgun)person[whichhit].health-=60;
 
-							if(person[whichhit].type!=zombietype)person[whichhit].health-=100;
+					if(person[j].whichgun==sniperrifle&&m==0){
 
-							if(person[whichhit].type==zombietype)person[whichhit].health-=120;
+						if(person[whichhit].type!=zombietype)person[whichhit].health-=100;
 
-							person[whichhit].DoAnimations(whichhit);
+						if(person[whichhit].type==zombietype)person[whichhit].health-=120;
 
-						}
+						person[whichhit].DoAnimations(whichhit);
 
-						if(hitstruct.joint1->modelnum==headmodel&&person[whichhit].type!=zombietype){
+					}
 
-							person[whichhit].health-=60;
+					if(hitstruct.joint1->modelnum==headmodel&&person[whichhit].type!=zombietype){
 
-						}
+						person[whichhit].health-=60;
 
-						if(person[whichhit].type==zombietype)person[whichhit].speedmult-=.05;
+					}
 
-						if(person[whichhit].type==zombietype)person[whichhit].maxhealth-=10;
+					if(person[whichhit].type==zombietype)person[whichhit].speedmult-=.05;
 
-						if(whichhit==0){
+					if(person[whichhit].type==zombietype)person[whichhit].maxhealth-=10;
 
-							bulletstrength=1;
+					if(whichhit==0){
 
-							person[0].health=100;
+						bulletstrength=1;
 
-							flashr=0;
+						person[0].health=100;
 
-							flashg=0;
+						flashr=0;
 
-							flashb=0;
+						flashg=0;
 
-							flashamount=1;
+						flashb=0;
 
-							float gLoc[3];
+						flashamount=1;
 
-							gLoc[0]=hitstruct.hitlocation.x/soundscalefactor;
+						float gLoc[3];
 
-							gLoc[1]=hitstruct.hitlocation.y/soundscalefactor;
+						gLoc[0]=hitstruct.hitlocation.x/soundscalefactor;
 
-							gLoc[2]=hitstruct.hitlocation.z/soundscalefactor;
+						gLoc[1]=hitstruct.hitlocation.y/soundscalefactor;
 
-							alSourcefv(gSourceID[bodywhacksound], AL_POSITION, gLoc);
+						gLoc[2]=hitstruct.hitlocation.z/soundscalefactor;
 
-							alSourcePlay(gSourceID[bodywhacksound]);
+						alSourcefv(gSourceID[bodywhacksound], AL_POSITION, gLoc);
 
-						}
+						alSourcePlay(gSourceID[bodywhacksound]);
 
-						person[whichhit].longdead=1;
+					}
 
-						if(person[whichhit].health<=0){
+					person[whichhit].longdead=1;
 
-							person[whichhit].skeleton.offset=0;
+					if(person[whichhit].health<=0){
 
-							if(person[whichhit].skeleton.free!=1){
+						person[whichhit].skeleton.offset=0;
 
-								person[whichhit].skeleton.free=1;
+						if(person[whichhit].skeleton.free!=1){
 
-								totalarea=0;
+							person[whichhit].skeleton.free=1;
 
-								for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
+							totalarea=0;
 
-									person[whichhit].skeleton.joints[j].position=DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0);
+							for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
 
-									person[whichhit].skeleton.joints[j].position+=person[whichhit].playercoords;
+								person[whichhit].skeleton.joints[j].position=DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0);
 
-									person[whichhit].skeleton.joints[j].realoldposition=person[whichhit].skeleton.joints[j].position;
+								person[whichhit].skeleton.joints[j].position+=person[whichhit].playercoords;
 
-									person[whichhit].skeleton.joints[j].velocity=person[whichhit].velocity;
+								person[whichhit].skeleton.joints[j].realoldposition=person[whichhit].skeleton.joints[j].position;
 
-									person[whichhit].skeleton.joints[j].velocity.x+=(float)(abs(Random()%20)-10)/2;
+								person[whichhit].skeleton.joints[j].velocity=person[whichhit].velocity;
 
-									person[whichhit].skeleton.joints[j].velocity.y+=(float)(abs(Random()%20)-10)/2;
+								person[whichhit].skeleton.joints[j].velocity.x+=(float)(abs(Random()%20)-10)/2;
 
-									person[whichhit].skeleton.joints[j].velocity.z+=(float)(abs(Random()%20)-10)/2;
+								person[whichhit].skeleton.joints[j].velocity.y+=(float)(abs(Random()%20)-10)/2;
 
-								}
+								person[whichhit].skeleton.joints[j].velocity.z+=(float)(abs(Random()%20)-10)/2;
 
 							}
 
-							for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
+						}
 
-								if(findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation)<200){
+						for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
 
-									totalarea+=(200/findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation));
+							if(findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation)<200){
 
-								}
+								totalarea+=(200/findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation));
 
 							}
 
-							for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
+						}
 
-								if(findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation)<200){
+						for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
 
-									person[whichhit].skeleton.joints[j].velocity+=aim*((200/findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation))/totalarea*200);
+							if(findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation)<200){
 
-								}
+								person[whichhit].skeleton.joints[j].velocity+=aim*((200/findDistancefast(person[whichhit].skeleton.joints[j].position,hitstruct.hitlocation))/totalarea*200);
 
 							}
 
 						}
 
-						if(person[whichhit].health>0){
+					}
 
-							if(person[whichhit].killtargetvisible==0&&person[whichhit].type!=zombietype&&person[whichhit].currentanimation!=getupfrontanim&person[whichhit].currentanimation!=getupbackanim){
+					if(person[whichhit].health>0){
 
-								if(hitstruct.joint1->modelnum==headmodel)person[whichhit].targetanimation=headpainanim;
+						if(person[whichhit].killtargetvisible==0&&person[whichhit].type!=zombietype&&person[whichhit].currentanimation!=getupfrontanim&person[whichhit].currentanimation!=getupbackanim){
 
-								if(hitstruct.joint1->modelnum==chestmodel)person[whichhit].targetanimation=chestpainanim;
+							if(hitstruct.joint1->modelnum==headmodel)person[whichhit].targetanimation=headpainanim;
 
-								if(hitstruct.joint1->modelnum==abdomenmodel)person[whichhit].targetanimation=stomachpainanim;
+							if(hitstruct.joint1->modelnum==chestmodel)person[whichhit].targetanimation=chestpainanim;
 
-								if(hitstruct.joint1->label==rightelbow||hitstruct.joint1->label==rightshoulder||hitstruct.joint1->label==rightwrist||hitstruct.joint1->label==righthand)person[whichhit].targetanimation=rightarmpainanim;
+							if(hitstruct.joint1->modelnum==abdomenmodel)person[whichhit].targetanimation=stomachpainanim;
 
-								if(hitstruct.joint1->label==leftelbow||hitstruct.joint1->label==leftshoulder||hitstruct.joint1->label==leftwrist||hitstruct.joint1->label==lefthand)person[whichhit].targetanimation=leftarmpainanim;
+							if(hitstruct.joint1->label==rightelbow||hitstruct.joint1->label==rightshoulder||hitstruct.joint1->label==rightwrist||hitstruct.joint1->label==righthand)person[whichhit].targetanimation=rightarmpainanim;
 
-								if(hitstruct.joint1->label==rightknee||hitstruct.joint1->label==righthip||hitstruct.joint1->label==rightankle||hitstruct.joint1->label==rightfoot)person[whichhit].targetanimation=rightlegpainanim;
+							if(hitstruct.joint1->label==leftelbow||hitstruct.joint1->label==leftshoulder||hitstruct.joint1->label==leftwrist||hitstruct.joint1->label==lefthand)person[whichhit].targetanimation=leftarmpainanim;
 
-								if(hitstruct.joint1->label==leftknee||hitstruct.joint1->label==lefthip||hitstruct.joint1->label==leftankle||hitstruct.joint1->label==leftfoot)person[whichhit].targetanimation=leftlegpainanim;
+							if(hitstruct.joint1->label==rightknee||hitstruct.joint1->label==righthip||hitstruct.joint1->label==rightankle||hitstruct.joint1->label==rightfoot)person[whichhit].targetanimation=rightlegpainanim;
 
-								person[whichhit].targetframe=0;
+							if(hitstruct.joint1->label==leftknee||hitstruct.joint1->label==lefthip||hitstruct.joint1->label==leftankle||hitstruct.joint1->label==leftfoot)person[whichhit].targetanimation=leftlegpainanim;
 
-								person[whichhit].target=0;
+							person[whichhit].targetframe=0;
 
-							}
+							person[whichhit].target=0;
 
-							person[whichhit].skeleton.offset=1;
+						}
 
-							for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
+						person[whichhit].skeleton.offset=1;
 
-								if(findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation)<200){
+						for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
 
-									totalarea+=(200/findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation));
+							if(findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation)<200){
 
-								}
+								totalarea+=(200/findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation));
 
 							}
 
-							float offsetlength;
+						}
 
-							for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
+						float offsetlength;
 
-								if(findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation)<200){
+						for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
 
-									person[whichhit].skeleton.joints[j].offset+=DoRotation(aim*((200/findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation))/totalarea*10),0,-person[whichhit].playerrotation,0);
+							if(findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation)<200){
 
-								}
+								person[whichhit].skeleton.joints[j].offset+=DoRotation(aim*((200/findDistancefast(DoRotation(person[whichhit].skeleton.joints[j].position,0,person[whichhit].playerrotation,0)+person[whichhit].playercoords,hitstruct.hitlocation))/totalarea*10),0,-person[whichhit].playerrotation,0);
 
-								offsetlength=findLengthfast(person[whichhit].skeleton.joints[j].offset);
+							}
 
-								if(offsetlength>36){
+							offsetlength=findLengthfast(person[whichhit].skeleton.joints[j].offset);
 
-									Normalise(&person[whichhit].skeleton.joints[j].offset);
+							if(offsetlength>36){
 
-									person[whichhit].skeleton.joints[j].offset*=6;
+								Normalise(&person[whichhit].skeleton.joints[j].offset);
 
-								}
+								person[whichhit].skeleton.joints[j].offset*=6;
 
 							}
 
 						}
 
-						if(hitstruct.joint1->modelnum==headmodel&&person[whichhit].health<=0){
+					}
 
-							for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
+					if(hitstruct.joint1->modelnum==headmodel&&person[whichhit].health<=0){
 
-								if(&person[whichhit].skeleton.joints[j]==hitstruct.joint1||&person[whichhit].skeleton.joints[j]==hitstruct.joint2){
+						for(int j=0;j<person[whichhit].skeleton.num_joints;j++){
 
-									if(j!=person[whichhit].skeleton.jointlabels[abdomen]&&j!=person[whichhit].skeleton.jointlabels[groin]&&j!=person[whichhit].skeleton.jointlabels[neck]){
+							if(&person[whichhit].skeleton.joints[j]==hitstruct.joint1||&person[whichhit].skeleton.joints[j]==hitstruct.joint2){
 
-										sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, person[whichhit].skeleton.joints[j].velocity/3, 9);
+								if(j!=person[whichhit].skeleton.jointlabels[abdomen]&&j!=person[whichhit].skeleton.jointlabels[groin]&&j!=person[whichhit].skeleton.jointlabels[neck]){
 
-										sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
+									sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, person[whichhit].skeleton.joints[j].velocity/3, 9);
 
-										sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
+									sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
 
-										sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
+									sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
 
-										sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
+									sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
 
-										person[whichhit].skeleton.DeleteJoint(j);
+									sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,person[whichhit].skeleton.joints[j].position, DoRotation(person[whichhit].skeleton.joints[j].velocity/3,Random()%360,Random()%360,0)/5, 5);
 
-										person[whichhit].skeleton.broken=1;
+									person[whichhit].skeleton.DeleteJoint(j);
 
-										person[whichhit].health=-10000;
+									person[whichhit].skeleton.broken=1;
 
-										person[whichhit].skeleton.joints[j].existing=0;
+									person[whichhit].health=-10000;
 
-										if(person[whichhit].type==zombietype)score+=300;
+									person[whichhit].skeleton.joints[j].existing=0;
 
-									}
+									if(person[whichhit].type==zombietype)score+=300;
 
 								}
 
@@ -2716,221 +2702,215 @@ void Game::Tick()
 
 						}
 
-						XYZ velocity;
-
-						velocity=aim*-8;
+					}
 
-						//blood
+					XYZ velocity;
 
-						if(!hitstruct.joint1->modelnum==headmodel){
+					velocity=aim*-8;
 
-						if(person[j].whichgun==sniperrifle)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 5);
+					//blood
 
-						if(person[j].whichgun==sniperrifle&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 7);
+					if(!hitstruct.joint1->modelnum==headmodel){
 
-						if(person[j].whichgun==shotgun)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 5);
+					if(person[j].whichgun==sniperrifle)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 5);
 
-						if(person[j].whichgun==shotgun&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 7);
+					if(person[j].whichgun==sniperrifle&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 7);
 
-						if(person[j].whichgun==assaultrifle)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 3);
+					if(person[j].whichgun==shotgun)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 5);
 
-						if(person[j].whichgun==assaultrifle&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 7);
+					if(person[j].whichgun==shotgun&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 7);
 
-						if(person[j].whichgun==handgun1)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 3);
+					if(person[j].whichgun==assaultrifle)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 3);
 
-						if(person[j].whichgun==handgun1&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 4);
+					if(person[j].whichgun==assaultrifle&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 7);
 
-						if(person[j].whichgun==handgun2)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 3);
+					if(person[j].whichgun==handgun1)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 3);
 
-						if(person[j].whichgun==handgun2&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 4);
+					if(person[j].whichgun==handgun1&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 4);
 
-						}else{
+					if(person[j].whichgun==handgun2)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 3);
 
-							sprites.MakeSprite(bloodspritenoup, 1, 1, .2, .2, hitstruct.hitlocation, velocity*0, 6);
+					if(person[j].whichgun==handgun2&&penetrate)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*-3, 4);
 
-							sprites.MakeSprite(bloodspritenoup, 1, 1, .5, .5, hitstruct.hitlocation, velocity*-2, 7);
+					}else{
 
-							sprites.MakeSprite(bloodspritenoup, 1, 1, .2, .2, hitstruct.hitlocation, velocity*-3, 10);
+						sprites.MakeSprite(bloodspritenoup, 1, 1, .2, .2, hitstruct.hitlocation, velocity*0, 6);
 
-						}
+						sprites.MakeSprite(bloodspritenoup, 1, 1, .5, .5, hitstruct.hitlocation, velocity*-2, 7);
 
-						person[whichhit].bjoint1=hitstruct.joint1;
+						sprites.MakeSprite(bloodspritenoup, 1, 1, .2, .2, hitstruct.hitlocation, velocity*-3, 10);
 
-						person[whichhit].bjoint2=hitstruct.joint2;
+					}
 
-						person[whichhit].bleeding=1;
+					person[whichhit].bjoint1=hitstruct.joint1;
 
-						person[whichhit].bleeddelay=1;
+					person[whichhit].bjoint2=hitstruct.joint2;
 
-						float gLoc[3];
+					person[whichhit].bleeding=1;
 
-						gLoc[0]=(camera.position.x+(hitstruct.hitlocation.x-camera.position.x)/4)/soundscalefactor;
+					person[whichhit].bleeddelay=1;
 
-						gLoc[1]=(camera.position.y+(hitstruct.hitlocation.y-camera.position.y)/4)/soundscalefactor;
+					float gLoc[3];
 
-						gLoc[2]=(camera.position.z+(hitstruct.hitlocation.z-camera.position.z)/4)/soundscalefactor;
+					gLoc[0]=(camera.position.x+(hitstruct.hitlocation.x-camera.position.x)/4)/soundscalefactor;
 
-						if(!hitstruct.joint1->modelnum==headmodel){
+					gLoc[1]=(camera.position.y+(hitstruct.hitlocation.y-camera.position.y)/4)/soundscalefactor;
 
-							if(!thirdperson)alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, 1);
+					gLoc[2]=(camera.position.z+(hitstruct.hitlocation.z-camera.position.z)/4)/soundscalefactor;
 
-							if(thirdperson)alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, .1);
+					if(!hitstruct.joint1->modelnum==headmodel){
 
-							alSourcefv(gSourceID[bodyhitsound], AL_POSITION, gLoc);
+						if(!thirdperson)alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, 1);
 
-							alSourcePlay(gSourceID[bodyhitsound]);
+						if(thirdperson)alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, .1);
 
-						}
+						alSourcefv(gSourceID[bodyhitsound], AL_POSITION, gLoc);
 
-						if(hitstruct.joint1->modelnum==headmodel){
+						alSourcePlay(gSourceID[bodyhitsound]);
 
-							if(!thirdperson)alSourcef(gSourceID[headshotsound], AL_MIN_GAIN, 1);
+					}
 
-							if(thirdperson)alSourcef(gSourceID[headshotsound], AL_MIN_GAIN, .1);
+					if(hitstruct.joint1->modelnum==headmodel){
 
-							alSourcefv(gSourceID[headshotsound], AL_POSITION, gLoc);
+						if(!thirdperson)alSourcef(gSourceID[headshotsound], AL_MIN_GAIN, 1);
 
-							alSourcePlay(gSourceID[headshotsound]);
+						if(thirdperson)alSourcef(gSourceID[headshotsound], AL_MIN_GAIN, .1);
 
-						}
+						alSourcefv(gSourceID[headshotsound], AL_POSITION, gLoc);
 
-					}//with wall
+						alSourcePlay(gSourceID[headshotsound]);
 
-					if(oldend==finalwallhit){
+					}
 
-						decals.MakeDecal(bullethole, finalwallhit,.7,hitnorm, hitpoly, model, hitmove, hitrotation);
+				}//with wall
 
-						XYZ velocity;
+				if(oldend==finalwallhit){
 
-						velocity=aim*-4;
+					decals.MakeDecal(bullethole, finalwallhit,.7,hitnorm, hitpoly, model, hitmove, hitrotation);
 
-						velocity=hitnorm*3;
+					XYZ velocity;
 
-						if(person[j].whichgun==sniperrifle){
+					velocity=aim*-4;
 
-							sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 10);
+					velocity=hitnorm*3;
 
-							sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 2);
+					if(person[j].whichgun==sniperrifle){
 
-						}
+						sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 10);
 
-						if(person[j].whichgun==shotgun){
+						sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 2);
 
-							sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 5);
+					}
 
-							sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, .8);
+					if(person[j].whichgun==shotgun){
 
-						}
+						sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 5);
 
-						if(person[j].whichgun==assaultrifle){
+						sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, .8);
 
-							sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 6);
+					}
 
-							sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 1);
+					if(person[j].whichgun==assaultrifle){
 
-						}
+						sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 6);
 
-						if(person[j].whichgun==handgun1){
+						sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 1);
 
-							sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 6);
+					}
 
-							sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 1);
+					if(person[j].whichgun==handgun1){
 
-						}
+						sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 6);
 
-						if(person[j].whichgun==handgun2){
+						sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 1);
 
-							sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 6);
+					}
 
-							sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 1);
+					if(person[j].whichgun==handgun2){
 
-						}
+						sprites.MakeSprite(smokesprite, .4, 1, 1, 1, finalwallhit, velocity, 6);
 
-						float gLoc[3];
+						sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, finalwallhit, velocity, 1);
 
-						gLoc[0]=finalwallhit.x/soundscalefactor;
+					}
 
-						gLoc[1]=finalwallhit.y/soundscalefactor;
+					float gLoc[3];
 
-						gLoc[2]=finalwallhit.z/soundscalefactor;
+					gLoc[0]=finalwallhit.x/soundscalefactor;
 
-						alSourcefv(gSourceID[wallhitsound], AL_POSITION, gLoc);
+					gLoc[1]=finalwallhit.y/soundscalefactor;
 
-						alSourcePlay(gSourceID[wallhitsound]);
+					gLoc[2]=finalwallhit.z/soundscalefactor;
 
-					}
+					alSourcefv(gSourceID[wallhitsound], AL_POSITION, gLoc);
 
-					lastshot[0]=start;
+					alSourcePlay(gSourceID[wallhitsound]);
 
-					lastshot[1]=oldend;
+				}
 
-					velocity=aim*8;
+				lastshot[0]=start;
 
-					if(person[j].whichgun!=sniperrifle&&person[j].whichgun!=shotgun&&p==numshots-1)sprites.MakeSprite(smokesprite, .3, 1, 1, 1, start+aim*1.5, velocity, 3);
+				lastshot[1]=oldend;
 
-					if(person[j].whichgun==shotgun&&p==numshots-1)sprites.MakeSprite(smokesprite, .4, 1, 1, 1, start+aim*1.5, velocity, 5);
+				velocity=aim*8;
 
-					if(person[j].whichgun==sniperrifle&&!zoom)sprites.MakeSprite(smokesprite, .3, 1, 1, 1, start+aim*2.2, velocity, 4);
+				if(person[j].whichgun!=sniperrifle&&person[j].whichgun!=shotgun&&p==numshots-1)sprites.MakeSprite(smokesprite, .3, 1, 1, 1, start+aim*1.5, velocity, 3);
 
-					if(j!=0||zoom==0)sprites.MakeSprite(bullet, .07, 1, 1, .7, lastshot[0]+aim*1, lastshot[1], .2);
+				if(person[j].whichgun==shotgun&&p==numshots-1)sprites.MakeSprite(smokesprite, .4, 1, 1, 1, start+aim*1.5, velocity, 5);
 
-					//Nearby bullet whoosh
+				if(person[j].whichgun==sniperrifle&&!zoom)sprites.MakeSprite(smokesprite, .3, 1, 1, 1, start+aim*2.2, velocity, 4);
 
-					long dot_ta,dot_tb;
+				if(j!=0||zoom==0)sprites.MakeSprite(bullet, .07, 1, 1, .7, lastshot[0]+aim*1, lastshot[1], .2);
 
-					XYZ *a,*b,*c,nearest;
+				//Nearby bullet whoosh
 
-					a=&lastshot[0];
+				long dot_ta,dot_tb;
 
-					*a+=aim*1;
+				XYZ *a,*b,*c,nearest;
 
-					b=&lastshot[1];
+				a=&lastshot[0];
 
-					c=&camera.position;
+				*a+=aim*1;
 
-					nearest=0;
+				b=&lastshot[1];
 
-					dot_ta = (c->x - a->x)*(b->x - a->x) + (c->y - a->y)*(b->y - a->y) + (c->z - a->z)*(b->z - a->z);
+				c=&camera.position;
 
-					dot_tb = (c->x - b->x)*(a->x - b->x) + (c->y - b->y)*(a->y - b->y) + (c->z - b->z)*(a->z - b->z);
+				nearest=0;
 
-					if (!dot_ta <= 0&&!dot_tb <= 0){
+				dot_ta = (c->x - a->x)*(b->x - a->x) + (c->y - a->y)*(b->y - a->y) + (c->z - a->z)*(b->z - a->z);
 
-							nearest.x = a->x + ((b->x - a->x) * dot_ta)/(dot_ta + dot_tb);
+				dot_tb = (c->x - b->x)*(a->x - b->x) + (c->y - b->y)*(a->y - b->y) + (c->z - b->z)*(a->z - b->z);
 
-							nearest.y = a->y + ((b->y - a->y) * dot_ta)/(dot_ta +dot_tb);
+				if (!dot_ta <= 0&&!dot_tb <= 0){
 
-							nearest.z = a->z + ((b->z - a->z) * dot_ta)/(dot_ta +dot_tb);
+						nearest.x = a->x + ((b->x - a->x) * dot_ta)/(dot_ta + dot_tb);
 
-						}
+						nearest.y = a->y + ((b->y - a->y) * dot_ta)/(dot_ta +dot_tb);
 
-					if(nearest.x){
+						nearest.z = a->z + ((b->z - a->z) * dot_ta)/(dot_ta +dot_tb);
 
-						if(findDistancefast(nearest,camera.position)<10&&(thirdperson==2||j!=0)){
+					}
 
-							float gLoc[3];
+				if(nearest.x){
 
-							gLoc[0]=(camera.position.x+(nearest.x-camera.position.x))/soundscalefactor;
+					if(findDistancefast(nearest,camera.position)<10&&(thirdperson==2||j!=0)){
 
-							gLoc[1]=(camera.position.y+(nearest.y-camera.position.y))/soundscalefactor;
+						float gLoc[3];
 
-							gLoc[2]=(camera.position.z+(nearest.z-camera.position.z))/soundscalefactor;
+						gLoc[0]=(camera.position.x+(nearest.x-camera.position.x))/soundscalefactor;
 
-							alSourcefv(gSourceID[nearbulletsound], AL_POSITION, gLoc);
+						gLoc[1]=(camera.position.y+(nearest.y-camera.position.y))/soundscalefactor;
 
-							alSourcePlay(gSourceID[nearbulletsound]);
+						gLoc[2]=(camera.position.z+(nearest.z-camera.position.z))/soundscalefactor;
 
-						}
+						alSourcefv(gSourceID[nearbulletsound], AL_POSITION, gLoc);
 
+						alSourcePlay(gSourceID[nearbulletsound]);
 					}
-
 				}
-
-			}
-
-			}
-
 			}
+			
 		}
 	}
 
@@ -3662,36 +3642,13 @@ void Game::Tick()
 	psychicpower+=multiplier*5;
 	if(psychicpower>10)psychicpower=10;
 
-	//3d sound
-	float gLoc[3];
-	gLoc[0]=camera.position.x/soundscalefactor;
-	gLoc[1]=camera.position.y/soundscalefactor;
-	gLoc[2]=camera.position.z/soundscalefactor;
-
-	//Set listener position
-	alListenerfv(AL_POSITION, gLoc);
-
-	//Set orientation with forward and up vectors
-	XYZ upvector;
-	upvector=0;
-	upvector.z=-1;
-	upvector=DoRotation(upvector,-camera.rotation2+90,0,0);
-	upvector=DoRotation(upvector,0,0-camera.rotation,0);
-
-	float ori[6];
-	ori[0] = -facing.x;
-	ori[1] = facing.y;
-	ori[2] = facing.z;
-	ori[3] = -upvector.x;
-	ori[4] = upvector.y;
-	ori[5] = upvector.z;
-	alListenerfv(AL_ORIENTATION, ori);
-
-	if(person[0].currentanimation==throwanim||person[0].currentanimation==diveanim||paused){
-		MoveMouse(oldmouseloc.h,oldmouseloc.v,&mouseloc);
-		GetMouse(&mouseloc);
-	}
+	if (paused || person[0].currentanimation== diveanim
+	    || person[0].currentanimation == throwanim)
+		MoveMouse(oldmouseloc.h, oldmouseloc.v, &mouseloc);
+	else
+		oldmouseloc = mouseloc;
 
-	oldmouseloc=mouseloc;
-	if(score<0)score=0;
+	setListener(facing);
+	if (score < 0)
+		score = 0;
 }