Commits

Jake Albano  committed ace0791

Fixed bug where enemies would walk off edges when the player is in view;
Inlined pickup drop code;

  • Participants
  • Parent commits d2e1ef4

Comments (0)

Files changed (2)

File obj/IfritConfig.xml

     </define>
     <define append="true">
       <name>CONFIG::timeStamp</name>
-      <value>'12/23/2011'</value>
+      <value>'12/24/2011'</value>
     </define>
     <verbose-stacktraces>true</verbose-stacktraces>
     <source-path append="true">
-      <path-element>C:\Documents and Settings\Chris\Desktop\Ifrit\src</path-element>
-      <path-element>C:\Program Files\FlashDevelop\Library\AS3\classes</path-element>
+      <path-element>C:\Users\Jake\Documents\FlashDevelop\Ifrit\src</path-element>
+      <path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
     </source-path>
   </compiler>
   <file-specs>
-    <path-element>C:\Documents and Settings\Chris\Desktop\Ifrit\src\Game.as</path-element>
+    <path-element>C:\Users\Jake\Documents\FlashDevelop\Ifrit\src\Game.as</path-element>
   </file-specs>
   <default-background-color>#FFFFFF</default-background-color>
   <default-frame-rate>30</default-frame-rate>

File src/ifrit/Enemy.as

 				}
 				else
 				{
-					//Only drop pickups some of the time
-					if (new Boolean(Math.round(Math.random() + 0.3)))
+					
+					//	2/3 chance of dropping a pickup
+					if (new Boolean(Math.round(Math.random() + 0.5)))
 					{
-						if (Game.man.type == Player.MAGE)
+						if (HUD.ammoCount <= 0.5)
 						{
-							var typeM:uint = new Boolean(Math.round(Math.random())) ? Pickup.HEALTH : Pickup.MANA;
-							addChild(this.pickup = new Pickup(this.x, this.y, typeM));
+							switch (Game.man.type) 
+							{
+								case Player.MAGE:		addChild(this.pickup = new Pickup(this.x, this.y, new Boolean(Math.round(Math.random())) ? Pickup.HEALTH : Pickup.MANA));		break;
+								case Player.FIGHTER:	addChild(this.pickup = new Pickup(this.x, this.y, new Boolean(Math.round(Math.random())) ? Pickup.HEALTH : Pickup.ARROW));		break;
+								case Player.ROGUE:		addChild(this.pickup = new Pickup(this.x, this.y, new Boolean(Math.round(Math.random())) ? Pickup.HEALTH : Pickup.SHURIKEN));	break;
+								default:				throw new Error("How did you manage to kill an enemy without having a class?");													break;
+							}
 						}
-						else if (Game.man.type == Player.FIGHTER)
+						else
 						{
-							if (HUD.ammoCount <= 0.5)
+							switch (Game.man.type) 
 							{
-								var typeF:uint = new Boolean(Math.round(Math.random())) ? Pickup.HEALTH : Pickup.ARROW;
-								addChild(this.pickup = new Pickup(this.x, this.y, typeF));
+								case Player.MAGE:		addChild(this.pickup = new Pickup(this.x, this.y, new Boolean(Math.round(Math.random())) ? Pickup.HEALTH : Pickup.MANA));		break;
+								case Player.FIGHTER:	addChild(this.pickup = new Pickup(this.x, this.y, Pickup.HEALTH));																break;
+								case Player.ROGUE:		addChild(this.pickup = new Pickup(this.x, this.y, Pickup.HEALTH));																break;
+								default:				throw new Error("How did you manage to kill an enemy without having a class?");													break;
 							}
-							else	addChild(this.pickup = new Pickup(this.x, this.y, Pickup.HEALTH));
-						}
-						else if (Game.man.type == Player.ROGUE)
-						{
-							if (HUD.ammoCount <= 0.5)
-							{
-								var typeR:uint = new Boolean(Math.round(Math.random())) ? Pickup.HEALTH : Pickup.SHURIKEN;
-								addChild(this.pickup = new Pickup(this.x, this.y, typeR));
-							}
-							else	addChild(this.pickup = new Pickup(this.x, this.y, Pickup.HEALTH));
 						}
 					}
 				}
 		{
 			this.lastHeading = heading;
 			
+			if (this.homeRect.contains(Game.man.x, Game.man.y) && !Game.man.isDestroyed && Game.man.y <= this.y + this.height / 2)
+			{
+				if (this.x >= Game.man.x)
+				{
+					if (this.x <= this.leftBound)	heading = false;
+				}
+				else
+				{
+					if (this.x >= this.rightBound)	heading = true;
+				}
+			}
+			
 			if (!(this.behaviorFlags & STAND_GROUND) > 0 || this.fleeMode)
 			{
 				if (heading)	{	if (this.x <= this.lastPosition.x) heading = !heading;	}
 					
 					if ( ! (this.behaviorFlags & PASSIVE) > 0)
 					{
-						if (this.x >= Game.man.x) heading = false;	else heading = true;
 						if (heading)	{	if (Game.man.x > this.x && this.rotationY == 0) this.attack();	}
 						else			{	if (Game.man.x < this.x && this.rotationY == 180) this.attack();	}
 					}