void mpcost(int Limit,  int iMPCost, void anim1 , void anim2 )

{

		void self = getlocalvar("self");
    		int mp = getentityproperty(self,"mp"); //Get entity's HP.


   		if (mp >= iMPCost )
                            { 
		    	  
			changeentityproperty(self, "mp", mp - iMPCost); //Subtract MP cost from caller's MP.
                        changeentityproperty(self, "animation", openborconstant("anim1")); // play the animation.
			                         	
	
		            }



   		if(mp<=Limit) 
                            {
     			changeentityproperty(self, "animation", openborconstant("anim2")); //Don't play the animation.
                            }

}