Jump to content

Help on hiding button image popping up


Giano

Recommended Posts

 

Hi everyone!

I just can't figure out how to hide the popping up attack hint or the controller attack button hint in my function.

For example when playing with a controller going near a mob the buttons "inspect" with the Y button image and "attack" with the X button image will pop up. I just want to avoid the Attack with the X button image popping up

I hope someone can help

Thanks in advance

 

EDIT:

I write here the function that makes followers and walls not attackable. I know that the commands popup are related maybe to the "playercontroller" but i don't seem to find out which function is used to show the Button widget for the attack action.

function Combat:IsValidTarget(target)
  local isPlayerAttacker = self.inst:HasTag("player")

  --if GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_J) then
--    return true
    --end
    
    if GLOBAL.TheInput:IsControlPressed(GLOBAL.CONTROL_OPEN_DEBUG_MENU) then
    return true
    end
    
    
    if (target.components.follower ~= nil
    and target.components.follower.leader ~= nil
    and target.components.follower.leader:HasTag("player"))
    or (isPlayerAttacker and save_companion and target:HasTag("companion"))
    or (isPlayerAttacker and save_walls and target:HasTag("wall")) then
        return false
    elseif not target
       or not target:IsValid()
       or not target.components
       or not target.components.combat
       or not target.entity:IsVisible()
       or not target.components.health
       or target == self.inst
       or target.components.health:IsDead()
       or (target:HasTag("shadow") and not self.inst.components.sanity)
       or Vector3(target.Transform:GetWorldPosition()).y > self.attackrange then
        return false
    else
        return true
    end
end

 

With this i can't attack the followers anymore but the attack prompt shows up anyway. Any tips?

thanks

 

 

Link to comment
Share on other sites

 

Alternatively can anyone help me making this mod working with the controller? (the code is taken from an old reddit post)

 

local function make_no_f_able(inst)
    local combat = inst.components.combat

    if not combat then return end

    combat.canbeattackedfn = (function()
        local oldfn = combat.canbeattackedfn
        return function(inst, attacker)
            if not oldfn or oldfn(inst, attacker) then
                if attacker:HasTag("player") then
                    local status, info = pcall(getinfo, 4, 'f')
                    return not status or info.func ~= attacker.components.playercontroller.GetAttackTarget
                else
                    return true
                end
            end
        end
    end)()
end

AddComponentPostInit("repairable", function(_, inst)
    if inst:HasTag("wall") then
        inst:DoTaskInTime(0, make_no_f_able)
    end
end)
AddComponentPostInit("follower", function(_, inst)
    if inst:HasTag("companion") then
        inst:DoTaskInTime(0, make_no_f_able)
    end
end)
AddComponentPostInit("workable", function(_, inst)
      if inst:HasTag("wall") then
        inst:DoTaskInTime(0, make_no_f_able)
    end
end)

 

It works fine with keyboard and mouse but not with the controller (maybe because the controller has the attack and force attack button bound together)

 

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...