dofile("scripts/entities/entityinclude.lua")

n = 0
myWeight = 0
function commonInit(me, gfx, r)
	-- note: if you want to add different weight to each rock, then
	-- send it through here
	if r == 0 then
		r = 80
	end
	setupEntity(me, gfx, -1)
	entity_setProperty(me, EP_MOVABLE, true)
	entity_setProperty(me, EP_BLOCKER, true)
	myWeight = 400
	entity_setCollideRadius(me, r)
	entity_setAffectedBySpells(me, 1)
	entity_setBounce(me, 0.2)	
	entity_setCanLeaveWater(me, true)
	
	entity_setAllDamageTargets(me, false)
	
	esetv(me, EV_TYPEID, EVT_ROCK)
end

function postInit(me)
	n = getNaija()
end

function commonUpdate(me, dt)
	
	--entity_updateCurrents(me)
	entity_updateMovement(me, dt)
	
	if entity_checkSplash(me) then
	end
	if not entity_isUnderWater(me) then
		if not entity_isBeingPulled(me) then
			entity_setWeight(me, myWeight*2)
			entity_setMaxSpeedLerp(me, 5, 0.1)
		end
	else
		entity_setMaxSpeedLerp(me, 1, 0.1)
		entity_setWeight(me, myWeight)
	end
	
	
	if not entity_isBeingPulled(me) then
		if entity_touchAvatarDamage(me, entity_getCollideRadius(me), 0) then
			if avatar_isBursting() and entity_setBoneLock(n, me) then
				-- yay!
			else
				--[[
				x, y = entity_getVectorToEntity(me, n, 1000)
				entity_addVel(n, x, y)
				]]--
			end
		end
	else
		if entity_getBoneLockEntity(n) == me then
			avatar_fallOffWall()
		end
	end
	
	entity_handleShotCollisions(me)
end

function damage(me, attacker, bone, damageType, dmg)
	return false
end

function enterState(me)
end

function exitState(me)
end

function hitSurface(me)
end

function activate(me)
end