--------------------------------------------------------------
-- 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}
	
	-- run speed
	--player:AddRunSpeedModifier{ uiModifier = 100, i64Caster = self }
	
	-- stop the player's velocity
	local vel = {x = 0, y = 0, z = 0}
	player:SetLinearVelocity{ linVelocity = vel }
	
	-- gravity
	player:SetGravityScale{ scale = 0.06 }
	
	-- jump support
	player:SetAllowJumpWithoutSupport{ bAllow = true }
	
	-- jump height
	player:SetJumpHeightScale{ fScale = 0.3 }
	
	-- resistance
	player:SetVelocityResistance{ resistance = 0.3 }
	
	-- fx
	-- player:PlayFXEffect{name = "sand_particles", effectType = "create", effectID = 359}
	
	-- stun
	player:SetStunned
	{
		StateChangeType = "PUSH",
		bCantAttack = true,
		bCantInteract = false,
		bCantUseItem = false
	}
	
	-- jetpack
	-- player:SetJetPackMode
	-- {
	-- 	bUse = true,
	-- 	bDoHover = false,
	-- 	effectID = -1,
	-- 	fAirspeed = 10,
	-- 	fVertVel = 1,
	-- 	fMaxAirspeed = 15,
	-- 	iWarningEffectID = -1,
	-- 	bBypassChecks = 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}
	
	-- run speed
	--player:RemoveRunSpeedModifier{ uiModifier = 100, i64Caster = self }
	
	-- gravity
	player:SetGravityScale{ scale = 1.0 }
	
	-- jump support
	player:SetAllowJumpWithoutSupport{ bAllow = false }
	
	-- jump height
	player:SetJumpHeightScale{ fScale = 1.0 }
	
	-- resistance
	player:SetVelocityResistance{ resistance = 0.0 }
	
	-- fx
	--player:StopFXEffect{ name = "sand_particles" }
	
	-- stun
	player:SetStunned
	{
		StateChangeType = "POP",
		bCantAttack = true,
		bCantInteract = false,
		bCantUseItem = false
	}
	
	-- jetpack
	-- player:SetJetPackMode
	-- {
	-- 	bUse = false,
	-- 	bDoHover = false,
	-- 	effectID = -1,
	-- 	fAirspeed = 10,
	-- 	fVertVel = 1,
	-- 	fMaxAirspeed = 15,
	-- 	iWarningEffectID = -1,
	-- 	bBypassChecks = true
	-- }
	
	-- velocity to help get out
	local vel = {x = 0, y = 10, z = 0}
	player:ModifyLinearVelocity{ linVelocity = vel }

end