
std.include("scripts/common.lua")

local this=nil
local owner=nil
local charges=2500

function init(t,o)
   this=t
   owner=o
end

function anim(t)
   local player_pos=get_object_world_pos(owner)
   local tpos=world_to_tile(player_pos)
   local type=get_tile_type(tpos)
   if (type==tile_lava_floor) then
      charges=charges-t
   end

   local player_pos=get_object_world_pos(owner)
   local spawn_pos=get_trigger_point_world_pos(get_trigger_point(1))
   local d=vec3_sqr_dist(player_pos,spawn_pos)
   if (d<25) then
      if (charges<2500) then
         say(owner,"Ah, I feel power returning\nto the Boots!",3000,{ 0.2,1.0,0.1,1 })
         charges=2500
      end
   end
end

function is_lava_immune()
   if (charges>0) then 
      return true 
   end
   return false
end

function get_energy()
   return charges/2500
end
