--------------------------------------------------------------
-- 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 = 400, i64Caster = self }
	
	-- stop the player's velocity
	--local vel = {x = 0, y = 0, z = 0}
	--player:SetLinearVelocity{ linVelocity = vel }
	
	-- gravity
	--player:SetGravityScale{ scale = 0.04 }
	
	-- jump support
	--player:SetAllowJumpWithoutSupport{ bAllow = true }
	
	-- jump height
	--player:SetJumpHeightScale{ fScale = 0.1 }
	
	-- resistance
	player:SetVelocityResistance{ resistance = 0.8 }
	
	-- fx
	--player:PlayFXEffect{name = "ripples", effectType = "create", effectID = 7542}
	
	--player:DisplayChatBubble{wsText = tostring(player:GetLinearVelocity{}.linVelocity.y)}
	if ( player:GetLinearVelocity{}.linVelocity.y < -15 ) then
		--player:PlayFXEffect{name = "splash", effectType = "on-anim", effectID = 2404}
		--player:PlayFXEffect{name = "splash", effectType = "death_water", effectID = 1189}
		--player:PlayFXEffect{name = "splash", effectType = "onhitWater", effectID = 1214}
		--player:PlayFXEffect{name = "splash", effectType = "onhitWater", effectID = 359}
		player:PlayFXEffect{name = "splash", effectType = "onhitWater", effectID = 20000}
		player:Play2DAmbientSound { m_NDAudioEventGUID = "{cbfdb72d-175b-4b2d-bdd2-ef92c697ddc7}" }
		
	end
	
	player:PlayFXEffect{name = "ripples", effectType = "create", effectID = 20001}
	
	-- start water sound loop
	--player:Play2DAmbientSound { m_NDAudioEventGUID = "{c195fba8-8b22-4b17-b2ef-8cb3edbabd04}" }
	
	-- stun
	player:SetStunned
	{
		StateChangeType = "PUSH",
		bCantAttack = true,
		bCantJump = true,
		bCantInteract = true,
		bCantUseItem = true,
		bIgnoreImmunity = true
	}
	
	-- 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 = 200, 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 = "splash" }
	player:StopFXEffect{ name = "ripples" }
	
	-- water exit sound
	--player:Play2DAmbientSound { m_NDAudioEventGUID = "{7736384c-f7d5-4a2b-9b7e-2e3fdfd142c9}" }
	
	-- stop water sound loop
	--player:Stop2DAmbientSound { m_NDAudioEventGUID = "{c195fba8-8b22-4b17-b2ef-8cb3edbabd04}" }
	
	-- stun
	player:SetStunned
	{
		StateChangeType = "POP",
		bCantAttack = true,
		bCantJump = true,
		bCantInteract = true,
		bCantUseItem = true,
		bIgnoreImmunity = true
	}
	
	-- 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 = 6, z = 0}
	player:ModifyLinearVelocity{ linVelocity = vel }

end