Jump to content

How can I have a function that triggers when you walk nearby the ocean?


Recommended Posts

I am developing a character mod right now and I plan to have one of their abilities trigger when they are nearby the ocean in Vanillia, RoG and Hamlet, as of now I plan that when they are nearby the ocean, they gain a speed boost and dapperness bonus.

Trouble is, I have no damn idea how to make the code to work. What I had tried to do is go through the code of the game looking for some effect that was similar to what I wanted so that I could use it/rework it. I found that Penguins had a function that triggers when a player goes nearby the ocean, which was the closest thing I could find. Issue is I cannot figure out if I can fit it into working in a character file and having it trigger something else other than Penguin spawning. So far I have been unsuccessful. 

So, I need some code that triggers an effect when the player goes nearby the ocean. Anyone think that they can help me out? I would be super thankful!

Cheers fellas.

Link to comment
Share on other sites

On 5/31/2022 at 4:26 PM, minty1 said:

I am developing a character mod right now and I plan to have one of their abilities trigger when they are nearby the ocean in Vanillia, RoG and Hamlet, as of now I plan that when they are nearby the ocean, they gain a speed boost and dapperness bonus.

Trouble is, I have no damn idea how to make the code to work. What I had tried to do is go through the code of the game looking for some effect that was similar to what I wanted so that I could use it/rework it. I found that Penguins had a function that triggers when a player goes nearby the ocean, which was the closest thing I could find. Issue is I cannot figure out if I can fit it into working in a character file and having it trigger something else other than Penguin spawning. So far I have been unsuccessful. 

So, I need some code that triggers an effect when the player goes nearby the ocean. Anyone think that they can help me out? I would be super thankful!

Cheers fellas.

I use this for one of my mods:

local function IsHole(x,y,z)
    return GetGroundTypeAtPosition(Vector3(x,y,z)) == GROUND.IMPASSABLE 
end

local function IsPointNearHole(x,y,z)
    local ground = GetWorld()
    local radius = .5


    for i = -radius, radius, 1 do
        if IsHole(x - radius, y, z + i) or IsHole(x + radius, y, z + i) then
            return true
        end
    end
    for i = -(radius - 1), radius - 1, 1 do
        if IsHole(x + i, y, z -radius) or IsHole(x + i, y, z + radius) then
            return true
        end
    end
    return false
end

Change the radius for the distance. This checks if is near a hole (ocean, vacum in caves), of cource you can check if the GetWorld().prefab = "forest" for checking for surface.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...