/***********************************************
 * _firepot.zes
 * 
 * Author: Lukex
 * Date:   31st December 1969
 *
 * Desc:   If any fire hits it, it should light up
 *
 * Usage:  isOpen() 
 *
 * Sprites: _MiscDungeon.spt
 *
 * Todo: "Close" after set amount of time
 *             
 ***********************************************/
#include <animation>
#include <entity>
#include <general>
#include <core>

new firepotanim[20];

main()
{
	if (FirstRun())
	{
		SetType("this", enemyType);
		CreateAnim(6, firepotanim); 
		AddAnimframe(firepotanim, 0, 0, "_firepotA1");
      AddAnimframe(firepotanim, 0, 0, "_firepotA2");
      AddAnimframe(firepotanim, 0, 0, "_firepotA3");
	}
	new width  = GetWidth("_firepot");
   new height = GetHeight("_firepot");
   new x = GetX("this");
   new y = GetY("this");

   if ( isVisible("this") && isActive("this") )
   {
   	SetCollisionRect("this", 0, true, x, y, x + width, y + height);
   	if ( isOpen("this") )
			DrawAnim(firepotanim, x, y, y + height);
		else  
			PutSprite("_firepot", x, y, y + height);
   }
	
}
//----------------------------------------
// Name: HitByWeapon(wtype[], damage, x, y)
//----------------------------------------
public HitByWeapon(wtype[], damage, x, y)
{
   // Check if pot was hit by a fire weapon
   if ( !strcmp( wtype, "fire" ) )
		SetOpenFlag("this", true);	

   return;
}
