Jake Albano avatar Jake Albano committed 815069e

Finally fixed audio mute toggle;
Fixed enemy behavior related to new wall raycast check;
Increased mage frost bolt damage;
Decreased amount of health gained back by fleeing enemies;

Comments (0)

Files changed (4)

obj/IfritConfig.xml

     </define>
     <define append="true">
       <name>CONFIG::timeStamp</name>
-      <value>'7/31/2012'</value>
+      <value>'8/1/2012'</value>
     </define>
     <verbose-stacktraces>true</verbose-stacktraces>
     <source-path append="true">
 								World.Mobs[l].freeze();
 								if (!World.Mobs[l].struck)
 								{
-									World.Mobs[l].hitpoints -= 6;
+									World.Mobs[l].hitpoints -= 8;
 									World.Mobs[l].struck = true;
 								}
 							}

src/ifrit/Audio.as

 	import flash.media.SoundTransform;
 	import flash.net.URLRequest;
 	import com.thaumaturgistgames.flakit.Library;
+	import flash.media.SoundMixer;
 	import flash.utils.Timer;
 	
 	/**
 		{
 			if ((muteCooldown.currentCount >= 1 && !isMuted) || !muteCooldown.running)
 			{
-				for each (var sfx:SoundEffect in this.Sfx)
-				{	if (sfx.channel)	sfx.transform.volume = 0;	}
-				
-				for each (var song:Music in this.Songs)
-				{	if (song.channel)	song.transform.volume = 0;	}
+				SoundMixer.soundTransform = new SoundTransform(0);
 				
 				isMuted = true;
 				muteCooldown.stop();
 		}
 		
 		public function unmute():void
-		{	
+		{
 			if (muteCooldown.currentCount >= 1 && isMuted)
 			{
-				for each (var sfx:SoundEffect in this.Sfx)
-				{	if (sfx.channel && sfx.transform)	sfx.transform.volume = 1;	}
-				
-				for each (var song:Music in this.Songs)
-				{	if (song.channel && song.transform)	song.transform.volume = 1;	}
+				SoundMixer.soundTransform = new SoundTransform(1);
 				
 				isMuted = false;
 				muteCooldown.stop();
 					if (item.playing)	return;
 					else
 					{
-						if (!isMuted)
-						{
-							item.channel = item.sound.play(startTime, loops);
-							item.playing = true;
-							return;
-						}
+						item.channel = item.sound.play(startTime, loops);
+						item.playing = true;
+						return;
 					}
 				}
 			}
 					{						
 						item.channel = item.sound.play(startTime, loops, item.transform);
 						item.playing = true;
-						if (isMuted)	item.transform.volume = 0;
 					}
 				}
 				

src/ifrit/Enemy.as

 		{
 			this.lastHeading = heading;
 			
+			var reverse:int = 0;
+			var facePlayer:int = 1;
+			var noChange :int = 2;
+			
+			var lookDirection:int = noChange;
+			
+			var manInView:Boolean = this.homeRect.contains(Game.man.x, Game.man.y) && !Game.man.isDestroyed && Game.man.y <= this.y + this.height / 2 && !wallIsOccluding();
+			
+			//	If the enemy isn't supposed to be standing still...
 			if (!(this.behaviorFlags & STAND_GROUND) > 0 || this.fleeMode)
 			{
 				if (!holdingGround)
 				{
+					//	...turn him around when he hits an obstacle
 					if (heading)
 					{
 						if (this.x <= this.lastPosition.x)
 						{
-							heading = !heading;
+							lookDirection = reverse;
 						}
 					}
 					else
 					{
 						if (this.x >= this.lastPosition.x)
 						{
-							heading = !heading;
-						}
-					}
-				}
-			}
-			
-			if (this.homeRect.contains(Game.man.x, Game.man.y))
-			{
-				if (!Game.man.isDestroyed)
-				{
-					if (Game.man.y <= this.y + this.height / 2)
-					{
-						if (!fleeMode)
-						{
-							if (!wallIsOccluding())
-							{
-								this.heading = this.x < Game.man.x;
-							}
+							lookDirection = reverse;
 						}
 					}
 				}
 			}
 			
 			if (!fleeMode)
-			{
+			{				
 				if (findEdge())
 				{
+					//	If the enemy is on an edge but the player is in view
+					if (manInView)
+					{
+						lookDirection = facePlayer;
+					}
+					
 					holdingGround = false;
 				}
 				else
 				{
-					if (this.homeRect.contains(Game.man.x, Game.man.y) && !wallIsOccluding())
+					//	If the enemy is on an edge but the player is in view, wait on the edge
+					if (manInView)
 					{
 						holdingGround = true;
-						this.heading = this.x < Game.man.x;
+						lookDirection = facePlayer;
 					}
 					else
 					{
+						//	Otherwise turn around so as to not fall off the edge
 						if (castDown(1))
 						{
-							this.heading = !this.heading;
+							lookDirection = reverse;
 						}
 					}
 				}
 			}
+			
+			switch (lookDirection)
+			{
+				case reverse:
+					heading = !heading;
+					break;
+				case facePlayer:
+					this.heading = this.x < Game.man.x;
+					break;
+				case noChange:
+					break;
+				default:
+					throw new Error("This will never happen while the compiler is sane");
+			}
+			
 		}
 		
 		/**
 				this.fleeCooldown.reset();
 				if (!(this.behaviorFlags & AFRAID) > 0 && !this.isFrozen)
 				{
-					this.hitpoints = this.maxHealth / 2;
+					this.hitpoints++;
 				}
 			}
 		}
 		{			
 			for (var step:uint = 0; step < steps; step++)
 			{
-				var test:Point = new Point(this.x + (step * (heading ? 10 : -10)), this.y);
+				var test:Point = new Point(this.x + (step * (this.x < Game.man.x ? 10 : -10)), this.y);
 				
 				if (debug)
 				{
 						});
 				}
 				
-				for (var i:uint = 0; i < World.Platforms.length; i++)
+				if (Game.man.collisionHull.hitTestPoint(test.x, test.y))
+				{
+					return false;
+				}
+				
+				for (var i:uint = 0; i < World.Platforms.length; ++i)
 				{
 					if (World.Platforms[i].hitTestPoint(test.x, test.y))
 					{
 						return true;
 					}
-					
-					if (Game.man.hitTestPoint(test.x, test.y))
-					{
-						return false;
-					}
 				}
 			}
 			
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.