Jump to content

Recommended Posts

Basically title.  I'm not sure this is even possible, as I haven't found a way yet, but is there a way to make a certain character, and that character only, to be able to ride a Beefalo and not get booted off? 

Edited by Mario384

This will make it so that Wilson won't be bucked off.

You can modify the behaviour by changing the prefab name to your target character's prefab.

Please note the 'UniqueModNameHere' portion to help avoid conflicts with other mods.

AddPrefabPostInit("beefalo",
    function(inst)
        if(inst.components~=nil and inst.components.rideable~=nil)
        then
            inst.components.rideable.Buck_Old_UniqueModNameHere = inst.components.rideable.Buck
            inst.components.rideable.Buck = function(inst, gentle)
                local rider = inst:GetRider()
                if(rider~=nil and rider.prefab=="wilson")
                then
                    -- Do nothing
                else
                    if(inst.Buck_Old_UniqueModNameHere~=nil)
                    then
                        inst:Buck_Old_UniqueModNameHere(gentle)
                    end
                end
            end
        end
    end
)

 

9 hours ago, CarlZalph said:

Please note the 'UniqueModNameHere' portion to help avoid conflicts with other mods.

If you don't need the reference to the old method in other places, you can use local variable:

AddPrefabPostInit("beefalo",
    function(inst)
        if(inst.components~=nil and inst.components.rideable~=nil)
        then
            local Buck_Old = inst.components.rideable.Buck
            inst.components.rideable.Buck = function(inst, gentle)
                local rider = inst:GetRider()
                if(rider~=nil and rider.prefab=="wilson")
                then
                    -- Do nothing
                else
                    if(Buck_Old~=nil)
                    then
                        Buck_Old(inst, gentle)
                    end
                end
            end
        end
    end
)

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...