--------------------------------------------------------------
-- modified from the monastery quicksand - jamie
--------------------------------------------------------------

function onCollisionPhantom(self, msg)

	local player = GAMEOBJ:GetObjectByID(GAMEOBJ:GetLocalCharID())
	
	-- checking to see if the player still exists
	if (not( player:GetID() == msg.objectID:GetID()) ) or ( not player:Exists() ) then return end
	
	-- swimming animations
	player:ChangeIdleFlags{on = 2}
	
	-- resistance
	player:SetVelocityResistance{ resistance = 0.8 }
	
	-- fx
	player:PlayFXEffect{name = "ripples", effectType = "create", effectID = 20001}
	
	if ( player:GetLinearVelocity{}.linVelocity.y < -15 ) then
		player:PlayFXEffect{name = "splash", effectType = "onhitWater", effectID = 20000}
		player:Play2DAmbientSound { m_NDAudioEventGUID = "{cbfdb72d-175b-4b2d-bdd2-ef92c697ddc7}" }
	end
	
	-- stun
	player:SetStunned
	{
		StateChangeType = "PUSH",
		bCantAttack = true,
		bCantJump = true,
		bCantInteract = true,
		bCantUseItem = true,
		bIgnoreImmunity = true
	}
	
end


function onOffCollisionPhantom(self, msg)

	local player = GAMEOBJ:GetObjectByID(GAMEOBJ:GetLocalCharID())
	
	-- checking to see if the player still exists
	if (not( player:GetID() == msg.objectID:GetID()) ) or ( not player:Exists() ) then return end
	
	-- swimming animations
	player:ChangeIdleFlags{off = 2}
	
	-- resistance
	player:SetVelocityResistance{ resistance = 0.0 }
	
	-- fx
	player:StopFXEffect{ name = "splash" }
	player:StopFXEffect{ name = "ripples" }
	
	-- stun
	player:SetStunned
	{
		StateChangeType = "POP",
		bCantAttack = true,
		bCantJump = true,
		bCantInteract = true,
		bCantUseItem = true,
		bIgnoreImmunity = true
	}
	
	-- velocity to help get out
	local vel = {x = 0, y = 6, z = 0}
	player:ModifyLinearVelocity{ linVelocity = vel }

end