Jump to content

Left and Right click action change


Recommended Posts

Hey, I'm having trouble changing the actions of my character mod when they transform. I've tried to copy most of woodie's code since a good chunk of his code is similar to what I want but I can't seem to change the actions.  I've gotten it to a point where if I right and left click anything, it does the animation, but it doesn't do anything. 

What I'm wanting is Leftclick to basic attack(similar to moose form for woodie), while Rightclick is eat what's on the floor(like old werebeaver and wood on the floor). Is this even possible? If not, please let me know. Since my code is really long, assuming that the rest of the code is good to run, what can I do here?

 

local function ChangeLeftClickPicker(inst, target)

    return target ~= nil
        and target ~= inst
        and (   (   inst.replica.combat:CanTarget(target) and 
                    (not target:HasTag("player") or inst.components.playercontroller:IsControlPressed(CONTROL_FORCE_ATTACK)) and
                    inst.components.playeractionpicker:SortActionList({ ACTIONS.ATTACK }, target, nil)
                )
                or
                (   target:HasTag("walkingplank") and 
                    target:HasTag("interactable") and 
                    target:HasTag("plank_extended") and
                    inst.components.playeractionpicker:SortActionList({ ACTIONS.MOUNT_PLANK }, target, nil)
                )
            )
        or nil
end

local function ChangeRightClickPicker(inst, target)
    return target ~= nil
        and target ~= inst
        and (   (   inst.replica.combat:CanTarget(target) and 
                    (not target:HasTag("player") or inst.components.playercontroller:IsControlPressed(CONTROL_FORCE_CONSUME)) and
                    inst.components.playeractionpicker:SortActionList({ ACTIONS.CONSUME }, target, nil)
                )
                or
                (   
                    inst.components.playeractionpicker:SortActionList({ ACTIONS.MOUNT_PLANK }, target, nil)
                )
            )
        or nil
end
    
    
local function SetWereActions(inst, mode)
    if not isInSecondForm and not isInWereForm then
        inst.ActionStringOverride = nil
        if inst.components.playercontroller ~= nil then
            inst.components.playercontroller.actionbuttonoverride = nil
        end
        if inst.components.playeractionpicker ~= nil then
            inst.components.playeractionpicker.leftclickoverride = nil
            inst.components.playeractionpicker.rightclickoverride = nil
            inst.components.playeractionpicker.pointspecialactionsfn = nil
        end
        --EnableReticule(inst, false)
    elseif isInSecondForm and not isInWereForm then

        if inst.components.playeractionpicker ~= nil then
            inst.components.playeractionpicker.leftclickoverride = ChangeLeftClickPicker
            inst.components.playeractionpicker.rightclickoverride = ChangeRightClickPicker
            --inst.components.playeractionpicker.pointspecialactionsfn = nil
        end
        
    elseif not isInSecondForm and isInWereForm then
        inst.ActionStringOverride = nil
        if inst.components.playercontroller ~= nil then
            inst.components.playercontroller.actionbuttonoverride = Empty
        end
        if inst.components.playeractionpicker ~= nil then
            inst.components.playeractionpicker.leftclickoverride = ChangeLeftClickPicker
            inst.components.playeractionpicker.rightclickoverride = ChangeRightClickPicker
            --inst.components.playeractionpicker.pointspecialactionsfn = MoosePointSpecialActions
        end
        
    else --if mode == anything else
        inst.ActionStringOverride = nil
        if inst.components.playercontroller ~= nil then
            inst.components.playercontroller.actionbuttonoverride = nil
        end
        if inst.components.playeractionpicker ~= nil then
            inst.components.playeractionpicker.leftclickoverride = nil
            inst.components.playeractionpicker.rightclickoverride = nil
            inst.components.playeractionpicker.pointspecialactionsfn = nil
        end
    end

end

Edited by LlamaDom
Link to comment
Share on other sites

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
 Share

×
  • Create New...